Plugin Directory

Changeset 3402030


Ignore:
Timestamp:
11/24/2025 05:52:21 PM (7 weeks ago)
Author:
bfintal
Message:

version 1.2.0

Location:
cimo-image-optimizer
Files:
28 added
18 deleted
11 edited
18 copied

Legend:

Unmodified
Added
Removed
  • cimo-image-optimizer/tags/1.2.0/build/admin/admin-page.asset.php

    r3377045 r3402030  
    1 <?php return array('dependencies' => array('react-jsx-runtime', 'wp-api-fetch', 'wp-components', 'wp-element', 'wp-i18n'), 'version' => '458b9896520c1e2544b1');
     1<?php return array('dependencies' => array('react-jsx-runtime', 'wp-api-fetch', 'wp-components', 'wp-element', 'wp-hooks', 'wp-i18n'), 'version' => '48f89642dbaf07f34e19');
  • cimo-image-optimizer/tags/1.2.0/build/admin/admin-page.js

    r3377045 r3402030  
    1 (()=>{"use strict";var e={n:i=>{var a=i&&i.__esModule?()=>i.default:()=>i;return e.d(a,{a}),a},d:(i,a)=>{for(var s in a)e.o(a,s)&&!e.o(i,s)&&Object.defineProperty(i,s,{enumerable:!0,get:a[s]})}};e.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),e.o=(e,i)=>Object.prototype.hasOwnProperty.call(e,i),(()=>{var i;e.g.importScripts&&(i=e.g.location+"");var a=e.g.document;if(!i&&a&&(a.currentScript&&"SCRIPT"===a.currentScript.tagName.toUpperCase()&&(i=a.currentScript.src),!i)){var s=a.getElementsByTagName("script");if(s.length)for(var t=s.length-1;t>-1&&(!i||!/^http(s?):/.test(i));)i=s[t--].src}if(!i)throw new Error("Automatic publicPath is not supported in this browser");i=i.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),e.p=i+"../"})();const i=window.wp.element,a=window.wp.components,s=window.wp.apiFetch;var t=e.n(s);const n=window.wp.i18n,o=e.p+"images/logo-long.cca876ef.webp",c=window.ReactJSXRuntime,l=()=>{const[e,s]=(0,i.useState)({webpQuality:80,maxImageDimension:"",disableWpScaling:1,disableThumbnailGeneration:0,thumbnailSizes:[]}),[l,m]=(0,i.useState)([]),[r,d]=(0,i.useState)(!1),[p,h]=(0,i.useState)(""),[g,u]=(0,i.useState)(!0);(0,i.useEffect)(()=>{(async()=>{window.cimoAdmin&&window.cimoAdmin.imageSizes&&m(window.cimoAdmin.imageSizes),await x(),u(!1)})()},[]);const x=async()=>{try{const e=(await t()({path:"/wp/v2/settings"})).cimo_options||{};s({webpQuality:void 0!==e.webp_quality?e.webp_quality:80,maxImageDimension:e.max_image_dimension||"",disableWpScaling:void 0!==e.disable_wp_scaling?e.disable_wp_scaling:1,disableThumbnailGeneration:void 0!==e.disable_thumbnail_generation?e.disable_thumbnail_generation:0,thumbnailSizes:e.thumbnail_sizes||[]})}catch(e){}},w=(e,i)=>{s(a=>({...a,[e]:i}))};return g?(0,c.jsx)("div",{className:"cimo-admin-settings-wrap",children:(0,c.jsx)("div",{className:"cimo-loading",children:(0,c.jsx)("p",{children:(0,n.__)("Loading settings…","cimo-image-optimizer")})})}):(0,c.jsxs)("div",{className:"cimo-admin-settings-wrap",children:[(0,c.jsxs)("div",{className:"cimo-header",children:[(0,c.jsx)("img",{className:"cimo-logo",src:o,alt:(0,n.__)("Cimo Logo","cimo-image-optimizer"),height:"35"}),(0,c.jsxs)("div",{className:"cimo-stats-section",children:[(0,c.jsxs)("div",{className:"cimo-stats-column cimo-stats-column-big",children:[(0,c.jsx)("h3",{children:(0,n.__)("Total Storage Saved","cimo-image-optimizer")}),(0,c.jsxs)("div",{className:"cimo-stats-main",children:[(0,c.jsx)("span",{className:"cimo-stat-value",children:window.cimoAdmin.stats.total_storage_saved}),(0,c.jsxs)("span",{className:"cimo-stat-percentage",children:["↓ ",window.cimoAdmin.stats.percentage_saved,"% ",(0,n.__)("reduction","cimo-image-optimizer")]})]}),(0,c.jsx)("div",{className:"cimo-stats-details",children:(0,n.__)("Across all optimized media files","cimo-image-optimizer")})]}),(0,c.jsxs)("div",{className:"cimo-stats-column cimo-stats-column-small",children:[(0,c.jsx)("div",{className:"cimo-stat-icon",children:(0,c.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-image w-5 h-5 text-primary","data-lov-id":"src/pages/Index.tsx:66:22","data-lov-name":"Image","data-component-path":"src/pages/Index.tsx","data-component-line":"66","data-component-file":"Index.tsx","data-component-name":"Image","data-component-content":"%7B%22className%22%3A%22w-5%20h-5%20text-primary%22%7D",children:[(0,c.jsx)("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),(0,c.jsx)("circle",{cx:"9",cy:"9",r:"2"}),(0,c.jsx)("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})]})}),(0,c.jsx)("span",{className:"cimo-stat-value",children:window.cimoAdmin.stats.media_optimized}),(0,c.jsx)("span",{className:"cimo-stat-label",children:(0,n.__)("Media Files Optimized","cimo-image-optimizer")})]}),(0,c.jsxs)("div",{className:"cimo-stats-column cimo-stats-column-small",children:[(0,c.jsx)("div",{className:"cimo-stat-icon",children:(0,c.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-hard-drive w-5 h-5 text-destructive","data-lov-id":"src/pages/Index.tsx:80:22","data-lov-name":"HardDrive","data-component-path":"src/pages/Index.tsx","data-component-line":"80","data-component-file":"Index.tsx","data-component-name":"HardDrive","data-component-content":"%7B%22className%22%3A%22w-5%20h-5%20text-destructive%22%7D",children:[(0,c.jsx)("line",{x1:"22",x2:"2",y1:"12",y2:"12"}),(0,c.jsx)("path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z"}),(0,c.jsx)("line",{x1:"6",x2:"6.01",y1:"16",y2:"16"}),(0,c.jsx)("line",{x1:"10",x2:"10.01",y1:"16",y2:"16"})]})}),(0,c.jsx)("span",{className:"cimo-stat-value",children:window.cimoAdmin.stats.before}),(0,c.jsx)("span",{className:"cimo-stat-label",children:(0,n.__)("Original Size","cimo-image-optimizer")})]}),(0,c.jsxs)("div",{className:"cimo-stats-column cimo-stats-column-small",children:[(0,c.jsx)("div",{className:"cimo-stat-icon",children:(0,c.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-zap w-5 h-5 text-accent","data-lov-id":"src/pages/Index.tsx:94:22","data-lov-name":"Zap","data-component-path":"src/pages/Index.tsx","data-component-line":"94","data-component-file":"Index.tsx","data-component-name":"Zap","data-component-content":"%7B%22className%22%3A%22w-5%20h-5%20text-accent%22%7D",children:(0,c.jsx)("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})})}),(0,c.jsx)("span",{className:"cimo-stat-value",children:window.cimoAdmin.stats.after}),(0,c.jsx)("span",{className:"cimo-stat-label",children:(0,n.__)("Optimized Size","cimo-image-optimizer")})]})]})]}),(0,c.jsxs)("div",{className:"cimo-settings-section-wrapper",children:[(0,c.jsxs)("div",{className:"cimo-settings-section",children:[(0,c.jsxs)("div",{className:"cimo-settings-header",children:[(0,c.jsxs)("h2",{children:[(0,c.jsx)("span",{"aria-hidden":"true",children:(0,c.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-settings w-5 h-5 text-primary","data-lov-id":"src/components/SettingsSection.tsx:19:8","data-lov-name":"Settings","data-component-path":"src/components/SettingsSection.tsx","data-component-line":"19","data-component-file":"SettingsSection.tsx","data-component-name":"Settings","data-component-content":"%7B%22className%22%3A%22w-5%20h-5%20text-primary%22%7D",children:[(0,c.jsx)("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),(0,c.jsx)("circle",{cx:"12",cy:"12",r:"3"})]})}),(0,n.__)("Image Optimization Settings","cimo-image-optimizer")]}),(0,c.jsx)(a.Button,{variant:"secondary",onClick:()=>{s({webpQuality:80,maxImageDimension:1920,disableWpScaling:1,disableThumbnailGeneration:1,thumbnailSizes:[]})},children:(0,n.__)("Recommended","cimo-image-optimizer")})]}),(0,c.jsxs)("form",{onSubmit:async i=>{i.preventDefault(),d(!0),h("");try{await t()({path:"/wp/v2/settings",method:"POST",data:{cimo_options:{webp_quality:parseInt(e.webpQuality)||0,max_image_dimension:parseInt(e.maxImageDimension)||0,disable_wp_scaling:e.disableWpScaling,disable_thumbnail_generation:e.disableThumbnailGeneration,thumbnail_sizes:e.thumbnailSizes}}}),h((0,n.__)("Settings saved successfully!","cimo-image-optimizer"))}catch(e){h((0,n.__)("Error saving settings.","cimo-image-optimizer"))}finally{d(!1),setTimeout(()=>h(""),3e3)}},children:[(0,c.jsx)("div",{className:"cimo-setting-field",children:(0,c.jsx)(a.RangeControl,{id:"webpQuality",label:(0,n.__)("WebP Image Quality","cimo-image-optimizer"),value:e.webpQuality||"",onChange:e=>w("webpQuality",e||""),min:"1",max:"100",step:"1",__next40pxDefaultSize:!0,allowReset:!0,initialPosition:80,help:(0,n.__)("Set the quality / compression level for generated .webp images. Default is 80%. Higher values mean better quality and larger file size; lower values reduce file size with more compression but lower quality.","cimo-image-optimizer")})}),(0,c.jsx)("div",{className:"cimo-setting-field",children:(0,c.jsx)(a.TextControl,{label:(0,n.__)("Maximum Image Dimension","cimo-image-optimizer"),type:"number",value:e.maxImageDimension,onChange:e=>w("maxImageDimension",e),help:(0,n.__)("Maximum width or height in pixels for uploaded images. Images exceeding this dimension will be automatically resized while preserving aspect ratio. Leave empty to disable resizing. We recommend a value of 1920px.","cimo-image-optimizer"),__next40pxDefaultSize:!0})}),(0,c.jsx)("div",{className:"cimo-setting-field",children:(0,c.jsx)(a.ToggleControl,{__nextHasNoMarginBottom:!0,label:(0,n.__)("WordPress Automatic Image Scaling","cimo-image-optimizer"),checked:1===e.disableWpScaling,onChange:e=>w("disableWpScaling",e?1:0),help:(0,n.__)("WordPress automatically scales images larger than 2560px. Disable this option to allow uploads of any size.","cimo-image-optimizer")})}),(0,c.jsxs)("div",{className:"cimo-setting-field",children:[(0,c.jsx)(a.ToggleControl,{__nextHasNoMarginBottom:!0,label:(0,n.__)("WordPress Thumbnail Generation","cimo-image-optimizer"),checked:0===e.disableThumbnailGeneration,onChange:e=>w("disableThumbnailGeneration",e?0:1),help:(0,n.__)("By default, WordPress generates multiple image sizes (thumbnail, medium, large, etc.) when you upload images. Disable this option to save disk space.","cimo-image-optimizer")}),0===e.disableThumbnailGeneration&&(0,c.jsxs)("div",{className:"cimo-image-sizes-list",children:[(0,c.jsx)("h4",{className:"cimo-image-sizes-heading",children:(0,n.__)("Individual Image Sizes","cimo-image-optimizer")}),(0,c.jsx)("p",{className:"description",children:(0,n.__)("You can turn off generation for individual image sizes:","cimo-image-optimizer")}),l.map(i=>{const t=!e.thumbnailSizes.includes(i.name);return(0,c.jsx)(a.ToggleControl,{label:i.name,checked:t,onChange:e=>{return a=i.name,t=e,void s(e=>{let i=[...e.thumbnailSizes];return t?i=i.filter(e=>e!==a):i.includes(a)||i.push(a),{...e,thumbnailSizes:i}});var a,t}},i.name)}),0===l.length&&(0,c.jsx)("div",{className:"notice notice-warning cimo-image-sizes-warning",children:(0,c.jsx)("p",{children:(0,n.__)("No image sizes detected. If you just re-enabled thumbnail generation, please save settings and refresh this page.","cimo-image-optimizer")})})]})]}),(0,c.jsx)("div",{className:"cimo-setting-field cimo-submit-section",children:(0,c.jsxs)("div",{className:"cimo-submit-buttons",children:[(0,c.jsx)(a.Button,{variant:"primary",className:"cimo-save-button",disabled:r,__next40pxDefaultSize:!0,onClick:e=>{e.preventDefault(),r||document.querySelector("form").dispatchEvent(new Event("submit",{cancelable:!0,bubbles:!0}))},children:r?(0,n.__)("Saving…","cimo-image-optimizer"):(0,n.__)("Save Changes","cimo-image-optimizer")}),(0,c.jsx)(a.Button,{variant:"tertiary",className:"cimo-reset-button",onClick:()=>{s({webpQuality:"",maxImageDimension:"",disableWpScaling:1,disableThumbnailGeneration:0,thumbnailSizes:[]})},children:(0,n.__)("Reset to Default","cimo-image-optimizer")})]})}),p&&(0,c.jsx)("div",{className:`notice notice-${p.includes("success")?"success":"error"} is-dismissible`,children:(0,c.jsx)("p",{children:p})})]})]}),(0,c.jsxs)("div",{className:"cimo-settings-section cimo-settings-sidebar",children:[(0,c.jsxs)("div",{className:"cimo-sidebar-heading",children:[(0,c.jsx)("div",{className:"cimo-sidebar-heading-icon",children:(0,c.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-crown-icon lucide-crown",children:[(0,c.jsx)("path",{d:"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z"}),(0,c.jsx)("path",{d:"M5 21h14"})]})}),(0,c.jsx)("h2",{children:(0,n.__)("Upgrade to Premium","cimo-image-optimizer")})]}),(0,c.jsx)("p",{className:"cimo-premium-intro",children:(0,n.__)("Optimize more things and get premium support for a faster, happier site.","cimo-image-optimizer")}),(0,c.jsxs)("ul",{className:"cimo-premium-features-list",children:[(0,c.jsxs)("li",{children:[(0,c.jsx)("span",{className:"cimo-premium-icon",children:(0,c.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-video h-3 w-3 text-purple-600","data-lov-id":"src/components/WordPressAdmin.tsx:310:20","data-lov-name":"Video","data-component-path":"src/components/WordPressAdmin.tsx","data-component-line":"310","data-component-file":"WordPressAdmin.tsx","data-component-name":"Video","data-component-content":"%7B%22className%22%3A%22h-3%20w-3%20text-purple-600%22%7D",children:[(0,c.jsx)("path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5"}),(0,c.jsx)("rect",{x:"2",y:"6",width:"14",height:"12",rx:"2"})]})}),(0,c.jsx)("span",{children:(0,n.__)("Optimize videos on upload","cimo-image-optimizer")})]}),(0,c.jsxs)("li",{children:[(0,c.jsx)("span",{className:"cimo-premium-icon",children:(0,c.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-music h-3 w-3 text-purple-600","data-lov-id":"src/components/WordPressAdmin.tsx:316:20","data-lov-name":"Music","data-component-path":"src/components/WordPressAdmin.tsx","data-component-line":"316","data-component-file":"WordPressAdmin.tsx","data-component-name":"Music","data-component-content":"%7B%22className%22%3A%22h-3%20w-3%20text-purple-600%22%7D",children:[(0,c.jsx)("path",{d:"M9 18V5l12-2v13"}),(0,c.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,c.jsx)("circle",{cx:"18",cy:"16",r:"3"})]})}),(0,c.jsx)("span",{children:(0,n.__)("Optimize audio on upload","cimo-image-optimizer")})]}),(0,c.jsxs)("li",{children:[(0,c.jsx)("span",{className:"cimo-premium-icon",children:(0,c.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-zap h-3 w-3 text-purple-600","data-lov-id":"src/components/WordPressAdmin.tsx:328:20","data-lov-name":"Zap","data-component-path":"src/components/WordPressAdmin.tsx","data-component-line":"328","data-component-file":"WordPressAdmin.tsx","data-component-name":"Zap","data-component-content":"%7B%22className%22%3A%22h-3%20w-3%20text-purple-600%22%7D",children:(0,c.jsx)("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})})}),(0,c.jsx)("span",{children:(0,n.__)("Next-gen .avif image format","cimo-image-optimizer")})]}),(0,c.jsxs)("li",{children:[(0,c.jsx)("span",{className:"cimo-premium-icon",children:(0,c.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-icon customizable lucide-infinity-icon lucide-infinity lucide-icon customizable",children:(0,c.jsx)("path",{d:"M6 16c5 0 7-8 12-8a4 4 0 0 1 0 8c-5 0-7-8-12-8a4 4 0 1 0 0 8"})})}),(0,c.jsx)("span",{children:(0,n.__)("Still without limits","cimo-image-optimizer")})]}),(0,c.jsxs)("li",{children:[(0,c.jsx)("span",{className:"cimo-premium-icon",children:(0,c.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-tag-icon lucide-tag",children:[(0,c.jsx)("path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z"}),(0,c.jsx)("circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor"})]})}),(0,c.jsx)("span",{children:(0,n.__)("White label","cimo-image-optimizer")})]})]}),(0,c.jsxs)("div",{className:"cimo-premium-cta",children:[(0,c.jsx)(a.Button,{href:"https://wpcimo.com/pricing",variant:"primary",target:"_blank",rel:"noopener noreferrer",children:(0,n.__)("Upgrade Now","cimo-image-optimizer")}),(0,c.jsxs)("div",{className:"cimo-premium-guarantee",children:[(0,c.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"#16a249",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,c.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,c.jsx)("path",{d:"M8 13.5l2.5 2.5L16 9"})]}),(0,n.__)("30-day money back guarantee","cimo-image-optimizer")]})]})]})]})]})},m=document.getElementById("cimo-admin-settings");m&&(0,i.createRoot)(m).render((0,c.jsx)(l,{}))})();
     1(()=>{"use strict";var e={n:i=>{var a=i&&i.__esModule?()=>i.default:()=>i;return e.d(a,{a}),a},d:(i,a)=>{for(var t in a)e.o(a,t)&&!e.o(i,t)&&Object.defineProperty(i,t,{enumerable:!0,get:a[t]})}};e.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),e.o=(e,i)=>Object.prototype.hasOwnProperty.call(e,i),(()=>{var i;e.g.importScripts&&(i=e.g.location+"");var a=e.g.document;if(!i&&a&&(a.currentScript&&"SCRIPT"===a.currentScript.tagName.toUpperCase()&&(i=a.currentScript.src),!i)){var t=a.getElementsByTagName("script");if(t.length)for(var o=t.length-1;o>-1&&(!i||!/^http(s?):/.test(i));)i=t[o--].src}if(!i)throw new Error("Automatic publicPath is not supported in this browser");i=i.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),e.p=i+"../"})();const i=window.wp.element,a=window.wp.components,t=window.wp.hooks,o=window.wp.apiFetch;var s=e.n(o);const n=window.wp.i18n,l=e.p+"images/logo-long.cca876ef.webp",r=window.ReactJSXRuntime,m=(0,t.applyFilters)("cimo.admin.settings.buildType","free"),c=()=>{const[e,t]=(0,i.useState)({webpQuality:80,maxImageDimension:"",disableWpScaling:1,disableThumbnailGeneration:0,thumbnailSizes:[],lqipEnabled:0,lqipPulseSpeed:"",lqipBrightness:"",lqipFadeDuration:"",videoOptimizationEnabled:1,videoQuality:3,videoMaxResolution:"",audioOptimizationEnabled:1,audioQuality:128}),[o,c]=(0,i.useState)([]),[p,u]=(0,i.useState)(!1),[h,g]=(0,i.useState)(""),[x,_]=(0,i.useState)(!0),[v,w]=(0,i.useState)(!1),[j,b]=(0,i.useState)(()=>"undefined"!=typeof window&&"1"===window.cimoAdmin?.ratingDismissed);(0,i.useEffect)(()=>{(async()=>{window.cimoAdmin&&window.cimoAdmin.imageSizes&&c(window.cimoAdmin.imageSizes),await z(),_(!1)})()},[]);const z=async()=>{try{const e=(await s()({path:"/wp/v2/settings"})).cimo_options||{},i={webpQuality:void 0!==e.webp_quality?e.webp_quality:80,maxImageDimension:e.max_image_dimension||"",disableWpScaling:void 0!==e.disable_wp_scaling?e.disable_wp_scaling:1,disableThumbnailGeneration:void 0!==e.disable_thumbnail_generation?e.disable_thumbnail_generation:0,thumbnailSizes:e.thumbnail_sizes||[],lqipEnabled:void 0!==e.lqip_enabled?e.lqip_enabled:0,lqipPulseSpeed:void 0!==e.lqip_pulse_speed?e.lqip_pulse_speed:"",lqipBrightness:void 0!==e.lqip_brightness?e.lqip_brightness:"",lqipFadeDuration:void 0!==e.lqip_fade_duration?e.lqip_fade_duration:"",videoOptimizationEnabled:void 0!==e.video_optimization_enabled?e.video_optimization_enabled:1,videoQuality:void 0!==e.video_quality?e.video_quality:3,videoMaxResolution:e.video_max_resolution||"",audioOptimizationEnabled:void 0!==e.audio_optimization_enabled?e.audio_optimization_enabled:1,audioQuality:void 0!==e.audio_quality?e.audio_quality:128};t(i),w(!1)}catch(e){}},f=(0,i.useCallback)((e,i)=>{t(a=>({...a,[e]:i})),w(!0)},[]),y=(0,i.useCallback)(async()=>{b(!0);try{await s()({path:"/wp/v2/settings",method:"POST",data:{cimo_rating_dismissed:"1"}})}catch(e){b(!1)}},[]);return x?(0,r.jsx)("div",{className:"cimo-admin-settings-wrap",children:(0,r.jsx)("div",{className:"cimo-loading",children:(0,r.jsx)("p",{children:(0,n.__)("Loading settings…","cimo-image-optimizer")})})}):(0,r.jsxs)("div",{className:"cimo-admin-settings-wrap",children:[(0,r.jsxs)("div",{className:"cimo-header",children:[(0,r.jsx)("img",{className:"cimo-logo",src:l,alt:(0,n.__)("Cimo Logo","cimo-image-optimizer"),height:"35"}),(0,r.jsxs)("div",{className:"cimo-stats-section",children:[(0,r.jsxs)("div",{className:"cimo-stats-column cimo-stats-column-big",children:[(0,r.jsx)("h3",{children:(0,n.__)("Total Storage Saved","cimo-image-optimizer")}),(0,r.jsxs)("div",{className:"cimo-stats-main",children:[(0,r.jsx)("span",{className:"cimo-stat-value",children:window.cimoAdmin.stats.total_storage_saved}),(0,r.jsxs)("span",{className:"cimo-stat-percentage",children:["↓ ",window.cimoAdmin.stats.percentage_saved,"% ",(0,n.__)("reduction","cimo-image-optimizer")]})]}),(0,r.jsx)("div",{className:"cimo-stats-details",children:(0,n.__)("Across all optimized media files","cimo-image-optimizer")})]}),(0,r.jsxs)("div",{className:"cimo-stats-column cimo-stats-column-small",children:[(0,r.jsx)("div",{className:"cimo-stat-icon",children:(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-image w-5 h-5 text-primary","data-lov-id":"src/pages/Index.tsx:66:22","data-lov-name":"Image","data-component-path":"src/pages/Index.tsx","data-component-line":"66","data-component-file":"Index.tsx","data-component-name":"Image","data-component-content":"%7B%22className%22%3A%22w-5%20h-5%20text-primary%22%7D",children:[(0,r.jsx)("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),(0,r.jsx)("circle",{cx:"9",cy:"9",r:"2"}),(0,r.jsx)("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})]})}),(0,r.jsx)("span",{className:"cimo-stat-value",children:window.cimoAdmin.stats.media_optimized}),(0,r.jsx)("span",{className:"cimo-stat-label",children:(0,n.__)("Media Files Optimized","cimo-image-optimizer")})]}),(0,r.jsxs)("div",{className:"cimo-stats-column cimo-stats-column-small",children:[(0,r.jsx)("div",{className:"cimo-stat-icon",children:(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-hard-drive w-5 h-5 text-destructive","data-lov-id":"src/pages/Index.tsx:80:22","data-lov-name":"HardDrive","data-component-path":"src/pages/Index.tsx","data-component-line":"80","data-component-file":"Index.tsx","data-component-name":"HardDrive","data-component-content":"%7B%22className%22%3A%22w-5%20h-5%20text-destructive%22%7D",children:[(0,r.jsx)("line",{x1:"22",x2:"2",y1:"12",y2:"12"}),(0,r.jsx)("path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z"}),(0,r.jsx)("line",{x1:"6",x2:"6.01",y1:"16",y2:"16"}),(0,r.jsx)("line",{x1:"10",x2:"10.01",y1:"16",y2:"16"})]})}),(0,r.jsx)("span",{className:"cimo-stat-value",children:window.cimoAdmin.stats.before}),(0,r.jsx)("span",{className:"cimo-stat-label",children:(0,n.__)("Original Size","cimo-image-optimizer")})]}),(0,r.jsxs)("div",{className:"cimo-stats-column cimo-stats-column-small",children:[(0,r.jsx)("div",{className:"cimo-stat-icon",children:(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-zap w-5 h-5 text-accent","data-lov-id":"src/pages/Index.tsx:94:22","data-lov-name":"Zap","data-component-path":"src/pages/Index.tsx","data-component-line":"94","data-component-file":"Index.tsx","data-component-name":"Zap","data-component-content":"%7B%22className%22%3A%22w-5%20h-5%20text-accent%22%7D",children:(0,r.jsx)("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})})}),(0,r.jsx)("span",{className:"cimo-stat-value",children:window.cimoAdmin.stats.after}),(0,r.jsx)("span",{className:"cimo-stat-label",children:(0,n.__)("Optimized Size","cimo-image-optimizer")})]})]})]}),(()=>{const e=window.cimoAdmin?.stats?.total_storage_saved;let i=!1;if("string"==typeof e){const a=e.match(/^([\d.]+)\s*([a-zA-Z]+)/);if(a){const e=parseFloat(a[1]);"MB"===a[2].toUpperCase()&&e>100&&(i=!0)}}return i&&!j?(0,r.jsx)("div",{className:"cimo-header cimo-rating-notice",children:(0,r.jsxs)("div",{className:"cimo-rating-notice-content",children:[(0,r.jsx)("h3",{className:"cimo-rating-title",children:(0,n.__)("Loving the instant storage & server resource savings?","cimo-image-optimizer")}),(0,r.jsx)("p",{className:"cimo-rating-description",children:(0,n.sprintf)(
     2// translators: %s is replaced with the total storage saved (e.g. "1.5 GB")
     3// translators: %s is replaced with the total storage saved (e.g. "1.5 GB")
     4(0,n.__)("You've saved over %s! If Cimo is helping your site, please consider leaving us a 5-star rating and help others discover Cimo!","cimo-image-optimizer"),window.cimoAdmin.stats.total_storage_saved)}),(0,r.jsxs)("div",{className:"cimo-rating-buttons",children:[(0,r.jsxs)(a.Button,{variant:"primary",href:"https://wordpress.org/support/plugin/cimo-image-optimizer/reviews/#new-post",target:"_blank",rel:"noopener noreferrer",className:"cimo-rating-rate-now",__next40pxDefaultSize:!0,children:[(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-star-icon lucide-star",children:(0,r.jsx)("path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z"})}),(0,n.__)("Rate Now","cimo-image-optimizer")]}),(0,r.jsx)(a.Button,{variant:"secondary",className:"cimo-rating-no-thanks",onClick:y,__next40pxDefaultSize:!0,children:(0,n.__)("Don't show this again, I've already rated","cimo-image-optimizer")})]})]})}):null})(),(0,r.jsxs)("form",{onSubmit:async i=>{i.preventDefault(),u(!0),g(""),w(!1);try{await s()({path:"/wp/v2/settings",method:"POST",data:{cimo_options:{webp_quality:parseInt(e.webpQuality)||0,max_image_dimension:parseInt(e.maxImageDimension)||0,disable_wp_scaling:e.disableWpScaling,disable_thumbnail_generation:e.disableThumbnailGeneration,thumbnail_sizes:e.thumbnailSizes,lqip_enabled:e.lqipEnabled,lqip_pulse_speed:parseFloat(e.lqipPulseSpeed)||0,lqip_brightness:parseFloat(e.lqipBrightness)||0,lqip_fade_duration:parseFloat(e.lqipFadeDuration)||0,video_optimization_enabled:e.videoOptimizationEnabled,video_quality:e.videoQuality||0,video_max_resolution:e.videoMaxResolution||"",audio_optimization_enabled:e.audioOptimizationEnabled,audio_quality:e.audioQuality||0}}}),g((0,n.__)("Settings saved successfully!","cimo-image-optimizer"))}catch(e){g((0,n.__)("Error saving settings.","cimo-image-optimizer"))}finally{u(!1),setTimeout(()=>g(""),3e3)}},className:"cimo-settings-form",children:[(0,r.jsxs)("div",{className:"cimo-settings-section-wrapper",children:[(0,r.jsxs)("div",{className:"cimo-settings-section cimo-settings-section-info",children:[(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-info-icon lucide-info",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,r.jsx)("path",{d:"M12 16v-4"}),(0,r.jsx)("path",{d:"M12 8h.01"})]}),"free"===m&&(0,r.jsx)("span",{children:(0,n.__)("Your images are instantly optimized within your browser as you upload — only the optimized versions ever touch your site!","cimo-image-optimizer")}),"premium"===m&&(0,r.jsx)("span",{children:(0,n.__)("Your images, videos and audio files are instantly optimized within your browser as you upload — only the optimized versions ever touch your site!","cimo-image-optimizer")})]}),(0,r.jsxs)("div",{className:"cimo-settings-section",children:[(0,r.jsxs)("div",{className:"cimo-settings-header",children:[(0,r.jsxs)("h2",{children:[(0,r.jsx)("span",{"aria-hidden":"true",children:(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-image-icon lucide-image",children:[(0,r.jsx)("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),(0,r.jsx)("circle",{cx:"9",cy:"9",r:"2"}),(0,r.jsx)("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})]})}),(0,n.__)("Image Optimization Settings","cimo-image-optimizer")]}),(0,r.jsx)(a.Button,{variant:"secondary",onClick:()=>{t(e=>({...e,webpQuality:80,maxImageDimension:1920,disableWpScaling:1,disableThumbnailGeneration:1,thumbnailSizes:[]}))},children:(0,n.__)("Recommended","cimo-image-optimizer")})]}),(0,r.jsx)("div",{className:"cimo-setting-field",children:(0,r.jsx)(a.RangeControl,{id:"webpQuality",label:(0,n.__)("WebP Image Quality","cimo-image-optimizer"),value:e.webpQuality||"",onChange:e=>f("webpQuality",e||""),min:"1",max:"100",step:"1",__next40pxDefaultSize:!0,allowReset:!0,initialPosition:80,help:(0,n.__)("Set the quality / compression level for generated .webp images. Default is 80%. Higher values mean better quality and larger file size; lower values reduce file size with more compression but lower quality.","cimo-image-optimizer")})}),(0,r.jsx)("div",{className:"cimo-setting-field",children:(0,r.jsx)(a.TextControl,{label:(0,n.__)("Maximum Image Dimension","cimo-image-optimizer"),type:"number",value:e.maxImageDimension,onChange:e=>f("maxImageDimension",e),help:(0,n.__)("Maximum width or height in pixels for uploaded images. Images exceeding this dimension will be automatically resized while preserving aspect ratio. Leave empty to disable resizing. We recommend a value of 1920px.","cimo-image-optimizer"),__next40pxDefaultSize:!0})}),(0,r.jsx)("div",{className:"cimo-setting-field",children:(0,r.jsx)(a.ToggleControl,{__nextHasNoMarginBottom:!0,label:(0,n.__)("WordPress Automatic Image Scaling","cimo-image-optimizer"),checked:1===e.disableWpScaling,onChange:e=>f("disableWpScaling",e?1:0),help:(0,n.__)("WordPress automatically scales images larger than 2560px. Disable this option to allow uploads of any size.","cimo-image-optimizer")})}),(0,r.jsxs)("div",{className:"cimo-setting-field",children:[(0,r.jsx)(a.ToggleControl,{__nextHasNoMarginBottom:!0,label:(0,n.__)("WordPress Thumbnail Generation","cimo-image-optimizer"),checked:0===e.disableThumbnailGeneration,onChange:e=>f("disableThumbnailGeneration",e?0:1),help:(0,n.__)("By default, WordPress generates multiple image sizes (thumbnail, medium, large, etc.) when you upload images. Disable this option to save disk space.","cimo-image-optimizer")}),0===e.disableThumbnailGeneration&&(0,r.jsxs)("div",{className:"cimo-image-sizes-list",children:[(0,r.jsx)("h4",{className:"cimo-image-sizes-heading",children:(0,n.__)("Individual Image Sizes","cimo-image-optimizer")}),(0,r.jsx)("p",{className:"description",children:(0,n.__)("You can turn off generation for individual image sizes:","cimo-image-optimizer")}),o.map(i=>{const o=!e.thumbnailSizes.includes(i.name);return(0,r.jsx)(a.ToggleControl,{label:i.name,checked:o,onChange:e=>{return a=i.name,o=e,void t(e=>{let i=[...e.thumbnailSizes];return o?i=i.filter(e=>e!==a):i.includes(a)||i.push(a),{...e,thumbnailSizes:i}});var a,o}},i.name)}),0===o.length&&(0,r.jsx)("div",{className:"notice notice-warning cimo-image-sizes-warning",children:(0,r.jsx)("p",{children:(0,n.__)("No image sizes detected. If you just re-enabled thumbnail generation, please save settings and refresh this page.","cimo-image-optimizer")})})]})]}),(0,r.jsx)(a.Button,{variant:"tertiary",className:"cimo-reset-button",onClick:()=>{t(e=>({...e,webpQuality:"",maxImageDimension:"",disableWpScaling:1,disableThumbnailGeneration:0,thumbnailSizes:[]}))},children:(0,n.__)("Reset to Default","cimo-image-optimizer")})]}),(0,r.jsxs)("div",{className:"cimo-settings-section",style:{gridColumn:"1 / 2"},children:[(0,r.jsxs)("div",{className:"cimo-settings-header",children:[(0,r.jsxs)("h2",{children:[(0,r.jsx)("span",{"aria-hidden":"true",children:(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-image-icon lucide-image",children:[(0,r.jsx)("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),(0,r.jsx)("circle",{cx:"9",cy:"9",r:"2"}),(0,r.jsx)("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})]})}),(0,n.__)("Low Quality Image Placeholder Settings","cimo-image-optimizer")]}),"free"===m&&(0,r.jsxs)("span",{className:"cimo-premium-feature-label",children:[(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-lock-icon lucide-lock",children:[(0,r.jsx)("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),(0,r.jsx)("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),(0,n.__)("Premium","cimo-image-optimizer")]})]}),"free"===m&&(0,r.jsx)(d,{label:(0,n.__)("Show a low-quality preview while the image loads, then fade in the final image.","cimo-image-optimizer")}),"premium"===m&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"cimo-setting-field",children:(0,r.jsx)(a.ToggleControl,{__nextHasNoMarginBottom:!0,label:(0,n.__)("Enable LQIP","cimo-image-optimizer"),checked:1===e.lqipEnabled,onChange:e=>f("lqipEnabled",e?1:0),help:(0,n.__)("Turn this option on to enable LQIP for all images. LQIP is only supported by Native Image Blocks.","cimo-image-optimizer")})}),1===e.lqipEnabled&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"cimo-setting-field",children:(0,r.jsx)(a.RangeControl,{id:"lqipPulseSpeed",label:(0,n.__)("Placeholder Pulse Speed (seconds)","cimo-image-optimizer"),value:e.lqipPulseSpeed||"",onChange:e=>f("lqipPulseSpeed",e||""),min:"0.1",max:"5",step:"0.1",__next40pxDefaultSize:!0,allowReset:!0,initialPosition:2.5,help:(0,n.__)("Set the speed of the pulse animation when the image is loading. Default is 2.5s.","cimo-image-optimizer")})}),(0,r.jsx)("div",{className:"cimo-setting-field",children:(0,r.jsx)(a.RangeControl,{id:"lqipBrightness",label:(0,n.__)("Placeholder Pulse Brightness","cimo-image-optimizer"),value:e.lqipBrightness||"",onChange:e=>f("lqipBrightness",e||""),min:"0.5",max:"1.5",step:"0.05",__next40pxDefaultSize:!0,allowReset:!0,initialPosition:1.3,help:(0,n.__)("Set the brightness of the pulse animation when the image is loading. Default is 1.3x brightness.","cimo-image-optimizer")})}),(0,r.jsx)("div",{className:"cimo-setting-field",children:(0,r.jsx)(a.RangeControl,{id:"lqipFadeDuration",label:(0,n.__)("Image Fade In Duration (seconds)","cimo-image-optimizer"),value:e.lqipFadeDuration||"",onChange:e=>f("lqipFadeDuration",e||""),min:"0.1",max:"3",step:"0.1",__next40pxDefaultSize:!0,allowReset:!0,initialPosition:.5,help:(0,n.__)("Set the duration of the fade in animation when the image is loaded. Default is 0.5s.","cimo-image-optimizer")})}),(0,r.jsx)(a.Button,{variant:"tertiary",className:"cimo-reset-button",onClick:()=>{t(e=>({...e,lqipPulseSpeed:"",lqipBrightness:"",lqipFadeDuration:""}))},children:(0,n.__)("Reset to Default","cimo-image-optimizer")})]})]})]}),(0,r.jsxs)("div",{className:"cimo-settings-section",style:{gridColumn:"1 / 2"},children:[(0,r.jsxs)("div",{className:"cimo-settings-header",children:[(0,r.jsxs)("h2",{children:[(0,r.jsx)("span",{"aria-hidden":"true",children:(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-video-icon lucide-video",children:[(0,r.jsx)("path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5"}),(0,r.jsx)("rect",{x:"2",y:"6",width:"14",height:"12",rx:"2"})]})}),(0,n.__)("Video Optimization Settings","cimo-image-optimizer")]}),"free"===m&&(0,r.jsxs)("span",{className:"cimo-premium-feature-label",children:[(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-lock-icon lucide-lock",children:[(0,r.jsx)("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),(0,r.jsx)("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),(0,n.__)("Premium","cimo-image-optimizer")]}),"premium"===m&&(0,r.jsx)(a.Button,{variant:"secondary",onClick:()=>{t(e=>({...e,videoOptimizationEnabled:1,videoQuality:3,videoMaxResolution:"1440"}))},children:(0,n.__)("Recommended","cimo-image-optimizer")})]}),"free"===m&&(0,r.jsx)(d,{label:(0,n.__)("Upgrade to Premium to compress and optimize video files on upload","cimo-image-optimizer")}),"premium"===m&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"cimo-setting-field",children:(0,r.jsx)(a.ToggleControl,{__nextHasNoMarginBottom:!0,label:(0,n.__)("Enable Video Optimization","cimo-image-optimizer"),checked:1===e.videoOptimizationEnabled,onChange:e=>f("videoOptimizationEnabled",e?1:0),help:(0,n.__)("Turn this option off to upload videos without optimizing them.","cimo-image-optimizer")})}),1===e.videoOptimizationEnabled&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"cimo-setting-field",children:(0,r.jsxs)(a.__experimentalToggleGroupControl,{__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,label:(0,n.__)("Video Quality","cimo-image-optimizer"),value:e.videoQuality||3,onChange:e=>f("videoQuality",e),isBlock:!0,help:(0,n.__)("Set the quality / compression level for optimized .MP4 video uploads. Default is Medium (Balanced). Lower quality means a smaller file size and lower quality, higher quality means a higher quality but larger file size.","cimo-image-optimizer"),children:[(0,r.jsx)(a.__experimentalToggleGroupControlOption,{value:1,label:(0,n.__)("Very Low Quality","cimo-image-optimizer")}),(0,r.jsx)(a.__experimentalToggleGroupControlOption,{value:2,label:(0,n.__)("Low Quality","cimo-image-optimizer")}),(0,r.jsx)(a.__experimentalToggleGroupControlOption,{value:3,label:(0,n.__)("Medium","cimo-image-optimizer")}),(0,r.jsx)(a.__experimentalToggleGroupControlOption,{value:4,label:(0,n.__)("High Quality","cimo-image-optimizer")}),(0,r.jsx)(a.__experimentalToggleGroupControlOption,{value:5,label:(0,n.__)("Very High Quality","cimo-image-optimizer")})]})}),(0,r.jsx)("div",{className:"cimo-setting-field",children:(0,r.jsxs)(a.__experimentalToggleGroupControl,{__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,label:(0,n.__)("Video Maximum Resolution","cimo-image-optimizer"),value:e.videoMaxResolution||"",onChange:e=>f("videoMaxResolution",e),isBlock:!0,help:(0,n.__)("Set the maximum resolution for optimized video uploads. If the video uploaded is bigger than this, the video will not be resized down to this maximum resolution. Default is the video will not be resized.","cimo-image-optimizer"),children:[(0,r.jsx)(a.__experimentalToggleGroupControlOption,{value:"",label:(0,n.__)("Keep original","cimo-image-optimizer")}),(0,r.jsx)(a.__experimentalToggleGroupControlOption,{value:"480",label:"480p"}),(0,r.jsx)(a.__experimentalToggleGroupControlOption,{value:"720",label:"720p"}),(0,r.jsx)(a.__experimentalToggleGroupControlOption,{value:"1080",label:"1080p"}),(0,r.jsx)(a.__experimentalToggleGroupControlOption,{value:"1440",label:"1440p (2K)"}),(0,r.jsx)(a.__experimentalToggleGroupControlOption,{value:"2160",label:"2160p (4K)"})]})})]}),(0,r.jsx)(a.Button,{variant:"tertiary",className:"cimo-reset-button",onClick:()=>{t(e=>({...e,videoOptimizationEnabled:1,videoQuality:"",videoMaxResolution:""}))},children:(0,n.__)("Reset to Default","cimo-image-optimizer")})]})]}),(0,r.jsxs)("div",{className:"cimo-settings-section",style:{gridColumn:"1 / 2"},children:[(0,r.jsxs)("div",{className:"cimo-settings-header",children:[(0,r.jsxs)("h2",{children:[(0,r.jsx)("span",{"aria-hidden":"true",children:(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-music-icon lucide-music",children:[(0,r.jsx)("path",{d:"M9 18V5l12-2v13"}),(0,r.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,r.jsx)("circle",{cx:"18",cy:"16",r:"3"})]})}),(0,n.__)("Audio Optimization Settings","cimo-image-optimizer")]}),"free"===m&&(0,r.jsxs)("span",{className:"cimo-premium-feature-label",children:[(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-lock-icon lucide-lock",children:[(0,r.jsx)("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),(0,r.jsx)("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),(0,n.__)("Premium","cimo-image-optimizer")]})]}),"free"===m&&(0,r.jsx)(d,{label:(0,n.__)("Upgrade to Premium to compress and optimize audio files on upload","cimo-image-optimizer")}),"premium"===m&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"cimo-setting-field",children:(0,r.jsx)(a.ToggleControl,{__nextHasNoMarginBottom:!0,label:(0,n.__)("Enable Audio Optimization","cimo-image-optimizer"),checked:1===e.audioOptimizationEnabled,onChange:e=>f("audioOptimizationEnabled",e?1:0),help:(0,n.__)("Turn this option off to upload audio files without optimizing them.","cimo-image-optimizer")})}),1===e.audioOptimizationEnabled&&(0,r.jsx)(r.Fragment,{children:(0,r.jsx)("div",{className:"cimo-setting-field",children:(0,r.jsx)(a.RangeControl,{label:(0,n.__)("Audio Quality (kbps)","cimo-image-optimizer"),__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,value:e.audioQuality||128,onChange:e=>f("audioQuality",e),min:"32",max:"320",step:"32",help:(0,n.__)("Set the quality / compression level for optimized .MP3 audio uploads. Default is 128kbps. Lower quality means a smaller file size and lower quality, higher quality means a higher quality but larger file size.","cimo-image-optimizer")})})}),(0,r.jsx)(a.Button,{variant:"tertiary",className:"cimo-reset-button",onClick:()=>{t(e=>({...e,audioOptimizationEnabled:1,audioQuality:""}))},children:(0,n.__)("Reset to Default","cimo-image-optimizer")})]})]})]}),(0,r.jsx)("div",{className:"cimo-setting-field cimo-submit-section",children:(0,r.jsxs)("div",{className:"cimo-submit-buttons",children:[(0,r.jsx)(a.Button,{variant:"primary",className:"cimo-save-button",disabled:p,__next40pxDefaultSize:!0,onClick:e=>{e.preventDefault(),p||document.querySelector("form").dispatchEvent(new Event("submit",{cancelable:!0,bubbles:!0}))},children:p?(0,n.__)("Saving…","cimo-image-optimizer"):(0,n.__)("Save Changes","cimo-image-optimizer")}),v&&(0,r.jsx)("span",{className:"cimo-unsaved-note",children:(0,n.__)("You have unsaved changes","cimo-image-optimizer")}),h&&(0,r.jsx)("p",{children:h})]})})]}),"free"===m&&(0,r.jsxs)("div",{className:"cimo-settings-section cimo-settings-sidebar",children:[(0,r.jsxs)("div",{className:"cimo-sidebar-heading",children:[(0,r.jsx)("div",{className:"cimo-sidebar-heading-icon",children:(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-crown-icon lucide-crown",children:[(0,r.jsx)("path",{d:"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z"}),(0,r.jsx)("path",{d:"M5 21h14"})]})}),(0,r.jsx)("h2",{children:(0,n.__)("Upgrade to Premium","cimo-image-optimizer")})]}),(0,r.jsx)("p",{className:"cimo-premium-intro",children:(0,n.__)("Optimize more things and get premium support for a faster, happier site.","cimo-image-optimizer")}),(0,r.jsxs)("ul",{className:"cimo-premium-features-list",children:[(0,r.jsxs)("li",{children:[(0,r.jsx)("span",{className:"cimo-premium-icon",children:(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-video h-3 w-3 text-purple-600","data-lov-id":"src/components/WordPressAdmin.tsx:310:20","data-lov-name":"Video","data-component-path":"src/components/WordPressAdmin.tsx","data-component-line":"310","data-component-file":"WordPressAdmin.tsx","data-component-name":"Video","data-component-content":"%7B%22className%22%3A%22h-3%20w-3%20text-purple-600%22%7D",children:[(0,r.jsx)("path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5"}),(0,r.jsx)("rect",{x:"2",y:"6",width:"14",height:"12",rx:"2"})]})}),(0,r.jsx)("span",{children:(0,n.__)("Optimize videos on upload","cimo-image-optimizer")})]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("span",{className:"cimo-premium-icon",children:(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-music h-3 w-3 text-purple-600","data-lov-id":"src/components/WordPressAdmin.tsx:316:20","data-lov-name":"Music","data-component-path":"src/components/WordPressAdmin.tsx","data-component-line":"316","data-component-file":"WordPressAdmin.tsx","data-component-name":"Music","data-component-content":"%7B%22className%22%3A%22h-3%20w-3%20text-purple-600%22%7D",children:[(0,r.jsx)("path",{d:"M9 18V5l12-2v13"}),(0,r.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,r.jsx)("circle",{cx:"18",cy:"16",r:"3"})]})}),(0,r.jsx)("span",{children:(0,n.__)("Optimize audio on upload","cimo-image-optimizer")})]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("span",{className:"cimo-premium-icon",children:(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-image-icon lucide-image",children:[(0,r.jsx)("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),(0,r.jsx)("circle",{cx:"9",cy:"9",r:"2"}),(0,r.jsx)("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})]})}),(0,r.jsx)("span",{children:(0,n.__)("Low Quality Image Placeholder","cimo-image-optimizer")})]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("span",{className:"cimo-premium-icon",children:(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-icon customizable lucide-infinity-icon lucide-infinity lucide-icon customizable",children:(0,r.jsx)("path",{d:"M6 16c5 0 7-8 12-8a4 4 0 0 1 0 8c-5 0-7-8-12-8a4 4 0 1 0 0 8"})})}),(0,r.jsx)("span",{children:(0,n.__)("Still without limits","cimo-image-optimizer")})]})]}),(0,r.jsxs)("div",{className:"cimo-premium-cta",children:[(0,r.jsx)(a.Button,{href:"https://wpcimo.com/pricing",variant:"primary",target:"_blank",rel:"noopener noreferrer",children:(0,n.__)("Upgrade Now","cimo-image-optimizer")}),(0,r.jsxs)("div",{className:"cimo-premium-guarantee",children:[(0,r.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"#16a249",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,r.jsx)("path",{d:"M8 13.5l2.5 2.5L16 9"})]}),(0,n.__)("30-day money back guarantee","cimo-image-optimizer")]})]})]})]})},d=e=>(0,r.jsxs)("div",{className:"cimo-settings-premium-placeholder",children:[e.label,(0,r.jsx)(a.Button,{variant:"secondary",className:"cimo-premium-cta",href:"https://wpcimo.com/pricing",target:"_blank",rel:"noopener noreferrer",children:(0,n.__)("Upgrade to Premium","cimo-image-optimizer")})]}),p=document.getElementById("cimo-admin-settings");p&&(0,i.createRoot)(p).render((0,r.jsx)(c,{}))})();
  • cimo-image-optimizer/tags/1.2.0/build/admin/index.asset.php

    r3377996 r3402030  
    1 <?php return array('dependencies' => array(), 'version' => '6fdc286d70e31c4cffb6');
     1<?php return array('dependencies' => array('wp-hooks', 'wp-i18n'), 'version' => '545dbff2243225a6ce40');
  • cimo-image-optimizer/tags/1.2.0/build/admin/index.js

    r3377996 r3402030  
    1 (()=>{"use strict";function e(e){"undefined"!=typeof document&&("complete"!==document.readyState&&"interactive"!==document.readyState?document.addEventListener("DOMContentLoaded",e):e())}const t=[{value:"webp",mimeType:"image/webp"},{value:"jpg",mimeType:"image/jpeg"},{value:"png",mimeType:"image/png"}],a={webp:{quality:.8,width:"auto",height:"auto"},jpg:{quality:.8,width:"auto",height:"auto"},png:{quality:.8,width:"auto",height:"auto"}};function i(e){if(!e||"string"!=typeof e)return!1;const t={webp:"image/webp",avif:"image/avif"}[e.toLowerCase()]||(e.startsWith("image/")?e:null);if(!t)return!1;const a=document.createElement("canvas");a.width=1,a.height=1;try{return a.toDataURL(t).startsWith(`data:${t}`)}catch(e){return!1}}async function n(e,i){const n=null!==(i=i||{}).format?i.format:"webp";if(!e||"object"!=typeof e||"string"!=typeof e.name||"number"!=typeof e.size||"string"!=typeof e.type||"function"!=typeof e.slice)return{file:e,metadata:null};if(!e.type||!e.type.startsWith("image/"))return{file:e,metadata:null};const o=t.find(e=>e.value===n);if(o&&e.type===o.mimeType)return{file:e,metadata:null};const r=document.createElement("canvas");if(o&&!r.toDataURL(o.mimeType).startsWith(`data:${o.mimeType}`))return console.error("[Cimo] "+n+" is not supported by the browser, please use another modern browser"),{file:e,metadata:null};if("image/gif"===e.type){const t=await e.slice(0,51200).arrayBuffer(),a=new Uint8Array(t);let i=0;for(let t=0;t<a.length-2;t++)if(33===a[t]&&249===a[t+1]&&4===a[t+2]&&(i++,i>1))return{file:e,metadata:null}}const s={file:e};try{const r=performance.now(),c=await(async(e,i="webp",n={})=>{let o=(n=n||{}).quality?n.quality:.8,r=n.maxDimension?n.maxDimension:0;return"string"==typeof o&&(o=parseFloat(o)/100,o||(o=.8)),"string"==typeof r&&(r=parseFloat(r)),new Promise((n,s)=>{const c=new Image;let m=null;c.onload=async function(){const e=document.createElement("canvas"),l=a[i],{width:d,height:p}=function(e,t,a){const i=(a=a||{}).scale?a.scale:1,n=a.width?a.width:"auto",o=a.height?a.height:"auto",r=a.aspectRatio?a.aspectRatio:"auto",s=a.maxDimension?a.maxDimension:0;let c=e*i,m=t*i;if(s&&"number"==typeof s&&s>0){const e=Math.max(c,m);if(e>s){const t=s/e;c*=t,m*=t}}if("auto"!==n&&"number"==typeof n&&(c=n,"auto"===o&&(m=t/e*c)),"auto"!==o&&"number"==typeof o&&(m=o,"auto"===n&&(c=e/t*m)),"auto"!==r){if("custom"===r)return{width:c,height:m};const[e,t]=r.split(":").map(Number),a=e/t,i=c/m;if(Math.abs(i-a)>.01)if(i>a)c=m*a;else{const e=c;c=e,m=e/a}}return{width:Math.round(c),height:Math.round(m)}}(c.width,c.height,{...l,maxDimension:r});e.width=d,e.height=p;const u=e.getContext("2d"),f=c.width/c.height,g=d/p;let h=c.height,w=c.width,y=0,v=0;Math.abs(f-g)>.01&&(f>g?(w=c.height*g,y=(c.width-w)/2):(h=c.width/g,v=(c.height-h)/2)),u.drawImage(c,y,v,w,h,0,0,d,p);const b=t.find(e=>e.value===i),_="webp"===i||"jpg"===i?o:void 0;e.toBlob(function(t){URL.revokeObjectURL(m),m=null,u.clearRect(0,0,e.width,e.height),e.width=0,e.height=0,t?n(t):s(new Error("Failed to convert image"))},b.mimeType,_)},c.onerror=()=>{m&&(URL.revokeObjectURL(m),m=null),s(new Error("Failed to load image"))},m=URL.createObjectURL(e.file),c.src=m})})(s,n,{quality:i.quality,maxDimension:i.maxDimension}),m=performance.now(),l="jpeg"===n?"jpg":n,d=e.name.replace(/\.[^/.]+$/,"")+"."+l,p={filename:d,originalFormat:e.type,originalFilesize:e.size,convertedFormat:o.mimeType,convertedFilesize:c.size,conversionTime:m-r,compressionSavings:e.size>0?c.size/e.size:null};return{file:new(0,e.constructor)([c],d,{type:o.mimeType,lastModified:Date.now()}),metadata:p}}catch(e){throw new Error(`Failed to convert image: ${e.message}`)}}function o(e){return("string"!=typeof e?String(e):e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/`/g,"&#96;")}function r(e,t="editor-canvas"){const a=()=>{const a=document.querySelector(`iframe[name="${t}"]`);if(a&&a.contentDocument){const t=()=>{a.contentDocument.body?e(a.contentDocument):setTimeout(t,50)};"loading"===a.contentDocument.readyState?a.addEventListener("load",()=>{t()}):t()}};a();let i=0;const n=setInterval(()=>{i>=10?clearInterval(n):(i++,a())},1e3),o=new MutationObserver(e=>{e.forEach(e=>{e.addedNodes.forEach(e=>{e.nodeType===Node.ELEMENT_NODE&&("IFRAME"===e.tagName&&e.name===t||e.querySelector&&e.querySelector(`iframe[name="${t}"]`))&&a()})})});return o.observe(document.body,{childList:!0,subtree:!0}),o}const s=e=>Array.isArray(e)&&0!==e.length?e.every(e=>m(e.filename))?Promise.resolve():(e.forEach(e=>{e.filename&&c(e.filename,e)}),new Promise((t,a)=>{fetch(`${window.cimoSettings?.restUrl||"/wp-json/cimo/v1/"}metadata`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","X-WP-Nonce":window.cimoSettings?.nonce||window.wpApiSettings?.nonce},body:JSON.stringify({metadata:e}),credentials:"same-origin"}).then(e=>e.ok?e.json():e.json().then(t=>{throw new Error(t.message||e.statusText)})).then(e=>{t(e)}).catch(t=>{console.error(`Failed to save metadata for filenames: [${e.map(e=>e.filename).join(", ")}]:`,t),a(new Error(`Failed to save metadata: ${t.message}`))})})):Promise.resolve(),c=(e,t)=>{window.cimoMetadataCache||(window.cimoMetadataCache={}),window.cimoMetadataCache[e.replaceAll(/\s+/g,"-")]={...t}},m=e=>window.cimoMetadataCache?.[e?.replaceAll(/\s+/g,"-")]||null;async function l(e){try{return await n(e,{format:"webp",quality:window.cimoSettings?.webpQuality||.8,maxDimension:window.cimoSettings?.maxImageDimension||0})}catch(t){return console.error(t),{file:e,metadata:null}}}const d=["image/jpg","image/jpeg","image/png","image/gif"];function p(e){if(!e)return;if(!e.body)return;e.body.__cimo_dropzone_listener_attached||(e.body.addEventListener("drop",async t=>{if(t.__cimo_converted)return;if(!Array.from(t.dataTransfer.files).some(e=>d.includes(e.type)))return;if(!(t.target.closest(".media-frame-uploader")||t.target.closest(".media-upload-form")||t.target.closest(".editor-post-featured-image")||t.target.closest(".editor-styles-wrapper")||t.target.closest(".uploader-window")))return;if(!i("webp"))return;let a;for(t.preventDefault(),t.stopPropagation();a=document.querySelector('.uploader-window[style*="display: block"]');)a.style.display="none";const n=Array.from(t.dataTransfer.files);if(!n.length)return;const o=await Promise.all(n.map(l)),r=o.map(e=>e.file),c=o.map(e=>e.metadata),m=new DataTransfer;if(r.forEach(e=>{m.items.add(e)}),await s(c),t.target?.classList.contains("components-drop-zone")){const a=e!==document,i=new Event("drop",{bubbles:!a});Object.defineProperty(i,"dataTransfer",{value:m,writable:!1}),i.__cimo_converted=!0,t.target.dispatchEvent(i)}else{const a=document.querySelector('.media-modal input[type="file"]')||document.querySelector('.media-upload-form input[type="file"]')||document.querySelector('input[type="file"]');if(a){a.files=m.files;const t=e!==document,i=new Event("change",{bubbles:!t});i.__cimo_converted=!0,a.dispatchEvent(i)}else{const e=new Event("drop",{bubbles:!0});Object.defineProperty(e,"dataTransfer",{value:m,writable:!1}),e.__cimo_converted=!0,t.target.dispatchEvent(e)}}},!0),e.body.__cimo_dropzone_listener_attached=!0)}async function u(e){try{return await n(e,{format:"webp",quality:window.cimoSettings?.webpQuality||.8,maxDimension:window.cimoSettings?.maxImageDimension||0})}catch(t){return console.error(t),{file:e,metadata:null}}}e(()=>{p(document),r(e=>{p(e)})});const f=["image/jpg","image/jpeg","image/png","image/gif"];function g(e){if(!window.wp&&!e)return;if(!e.body)return;e.body.__cimo_selectfiles_listener_attached||(e.body.addEventListener("change",async e=>{if("file"!==e.target.type)return;if(e.__cimo_converted)return;if(!Array.from(e.target.files).some(e=>f.includes(e.type)))return;if(!(e.target.closest(".components-form-file-upload")||e.target.closest(".media-frame")||e.target.closest(".media-upload-form")||e.target.closest(".moxie-shim")))return;if(!i("webp"))return;e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation();const t=Array.from(e.target.files),a=await Promise.all(t.map(u)),n=a.map(e=>e.file),o=a.map(e=>e.metadata),r=new DataTransfer;n.forEach(e=>{r.items.add(e)}),await s(o),e.target.files=r.files;const c=new Event("change",{bubbles:!0});c.__cimo_converted=!0,e.target.dispatchEvent(c)},!0),e.body.__cimo_selectfiles_listener_attached=!0)}function h(e,t=2,a=!1){if(0===e)return"0 Bytes";const i=t<0?0:t,n=Math.abs(e),o=Math.floor(Math.log(n)/Math.log(1024));let r=e<0?"-":"";return a&&(r="-"===r?"":"-"),r+parseFloat((n/Math.pow(1024,o)).toFixed(i))+" "+["Bytes","KB","MB","GB"][o]}e(()=>{g(document),r(e=>{g(e)})}),e(()=>{"undefined"!=typeof wp&&wp.media&&wp.media.view&&wp.media.view.Attachment&&wp.media.view.Attachment.Details&&(wp.media.view.Attachment.Details=wp.media.view.Attachment.Details.extend({template:function(e){const t=wp.media.template("attachment-details")(e),a=document.createElement("div");a.innerHTML=t;let i=e.model.get("cimo")||null;i&&0!==Object.keys(i).length||(i=m(e.model.get("originalImageName")||e.model.get("filename")));const n=a.querySelector(".attachment-info");if(i&&n){const e=document.createElement("div");e.className="cimo-media-manager-metadata";let t='<div class="cimo-media-manager-metadata-title-container">\n\t\t\t\t<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 672 672" height="20" width="20"><path d="M132.5 132.5C182.4 82.5 253 56 336 56C419 56 489.6 82.5 539.5 132.5C589.4 182.5 616 253 616 336C616 419 589.5 489.6 539.5 539.5C489.5 589.4 419 616 336 616C253 616 182.4 589.5 132.5 539.5C82.6 489.5 56 419 56 336C56 253 82.5 182.4 132.5 132.5zM465.5 273.9C477.6 264.2 479.5 246.6 469.9 234.5C460.3 222.4 442.6 220.5 430.5 230.1C378 272.1 330.3 341.9 306.7 379.4C291.4 359.3 267.2 331.1 239.5 312.6C226.6 304 209.2 307.5 200.7 320.4C192.2 333.3 195.6 350.7 208.5 359.2C237.4 378.5 264.1 415.1 274.1 429.9C281.5 440.9 294 447.9 307.9 447.9C322.3 447.9 335.5 440.3 342.8 428C357.2 403.5 410 318.3 465.6 273.8z"/></svg>\n\t\t\t\t<h3 class="cimo-media-manager-metadata-title">Image Optimized by Cimo</h3>\n\t\t\t\t</div>\n\t\t\t\t<ul>';const a=i.compressionSavings?(100-100*i.compressionSavings).toFixed(2):null,r=h(i.originalFilesize-i.convertedFilesize,1,!0);t+=`<li class="cimo-compression-savings ${o(a>0?"cimo-optimization-savings-up":"cimo-optimization-savings-down")}">Saved ${o(a)}% <span class="cimo-compression-savings-bytes">(${o(r)})</span></li>`;const s=h(parseInt(i.originalFilesize)||0),c=h(parseInt(i.convertedFilesize)||0);t+=`<li class="cimo-filesize-original">Original: <span class="cimo-value">${o(s)}</span></li>`,t+=`<li class="cimo-filesize-optimized">Optimized: <span class="cimo-value">${o(c)}</span></li>`,t+=`<li class="cimo-converted">🏞️ Converted to <span class="cimo-value">${o(function(e){const t=e.split("/")[1];return"webp"===t?"WebP":t.charAt(0).toUpperCase()+t.slice(1)}(i.convertedFormat))}</span></li>`;let m="N/A";if(i.conversionTime){const e=parseFloat(i.conversionTime);m=e<1e3?`${e.toFixed(0)} ms`:e<6e4?`${(e/1e3).toFixed(1)} sec`:`${(e/6e4).toFixed(1)} min`}t+=`<li class="cimo-time">⚡️ Done in <span class="cimo-value">${o(m)}</span></li>`,e.innerHTML=t,n.appendChild(e)}return a.innerHTML}}))})})();
     1(()=>{"use strict";function t(t){"undefined"!=typeof document&&("complete"!==document.readyState&&"interactive"!==document.readyState?document.addEventListener("DOMContentLoaded",t):t())}const e=window.wp.i18n;class i{constructor(t,i={}){this.file=t,this.options=i,this._progress=0,this._status=(0,e.__)("Ready","cimo-image-optimizer"),this._errorMessage=null}static get mimeTypes(){throw new Error("mimeTypes getter must be implemented by subclass")}static supportsMimeType(t){if(!t||"string"!=typeof t)return!1;const e=this.mimeTypes;return!!Array.isArray(e)&&e.includes(t)}get status(){return this._status}get errorMessage(){return this._errorMessage}get progress(){return this._progress}static get showProgress(){return!0}get showProgress(){return this.constructor.showProgress}async convert(){throw new Error("convert() must be implemented by subclass")}cancel(){}}const n=[{value:"webp",mimeType:"image/webp"},{value:"jpg",mimeType:"image/jpeg"},{value:"png",mimeType:"image/png"}];class s extends i{static get mimeTypes(){return["image/jpeg","image/png","image/webp","image/jpg"]}static get showProgress(){return!1}calculateDimensions(t,e,i){const n=(i=i||{}).scale?i.scale:1,s=i.width?i.width:"auto",o=i.height?i.height:"auto",r=i.aspectRatio?i.aspectRatio:"auto",a=i.maxDimension?i.maxDimension:0;let l=t*n,c=e*n;if(a&&"number"==typeof a&&a>0){const t=Math.max(l,c);if(t>a){const e=a/t;l*=e,c*=e}}if("auto"!==s&&"number"==typeof s&&(l=s,"auto"===o&&(c=e/t*l)),"auto"!==o&&"number"==typeof o&&(c=o,"auto"===s&&(l=t/e*c)),"auto"!==r){if("custom"===r)return{width:l,height:c};const[t,e]=r.split(":").map(Number),i=t/e,n=l/c;if(Math.abs(n-i)>.01)if(n>i)l=c*i;else{const t=l;l=t,c=t/i}}return{width:Math.round(l),height:Math.round(c)}}async convertImage(t,e="webp",i={}){let s=(i=i||{}).quality?i.quality:.8,o=i.maxDimension?i.maxDimension:0;return"string"==typeof s&&(s=parseFloat(s)/100,s||(s=.8)),"string"==typeof o&&(o=parseFloat(o)),new Promise((i,r)=>{const a=new Image;let l=null;a.onload=async()=>{const t=document.createElement("canvas"),{width:c,height:m}=this.calculateDimensions(a.width,a.height,{maxDimension:o});t.width=c,t.height=m;const d=t.getContext("2d"),p=a.width/a.height,u=c/m;let h=a.height,g=a.width,f=0,w=0;Math.abs(p-u)>.01&&(p>u?(g=a.height*u,f=(a.width-g)/2):(h=a.width/u,w=(a.height-h)/2)),d.drawImage(a,f,w,g,h,0,0,c,m);const y=n.find(t=>t.value===e),v="webp"===e||"jpg"===e?s:void 0;t.toBlob(function(e){URL.revokeObjectURL(l),l=null,d.clearRect(0,0,t.width,t.height),t.width=0,t.height=0,e?i(e):r(new Error("Failed to convert image"))},y.mimeType,v)},a.onerror=()=>{l&&(URL.revokeObjectURL(l),l=null),r(new Error("Failed to load image"))},l=URL.createObjectURL(t.file),a.src=l})}async convert(){const t=this.file,e=this.options?.format||"webp";if(!t.type||!t.type.startsWith("image/"))return{file:t,metadata:null};const i=n.find(t=>t.value===e);if(i&&t.type===i.mimeType)return{file:t,metadata:null};const s=document.createElement("canvas");if(i&&!s.toDataURL(i.mimeType).startsWith(`data:${i.mimeType}`))return console.error("[Cimo] "+e+" is not supported by the browser, please use another modern browser"),{file:t,metadata:null};if("image/gif"===t.type){const e=await t.slice(0,51200).arrayBuffer(),i=new Uint8Array(e);let n=0;for(let e=0;e<i.length-2;e++)if(33===i[e]&&249===i[e+1]&&4===i[e+2]&&(n++,n>1))return{file:t,metadata:null}}const o={file:t};try{const n=performance.now(),s=await this.convertImage(o,e,{quality:this.options?.quality||.8,maxDimension:this.options?.maxDimension||0}),r=performance.now(),a="jpeg"===e?"jpg":e,l=t.name.replace(/\.[^/.]+$/,"")+"."+a,c={filename:l,originalFormat:t.type,originalFilesize:t.size,convertedFormat:i.mimeType,convertedFilesize:s.size,conversionTime:r-n,compressionSavings:t.size>0?s.size/t.size:null};return{file:new(0,t.constructor)([s],l,{type:i.mimeType,lastModified:Date.now()}),metadata:c}}catch(t){throw new Error(`Failed to convert image: ${t.message}`)}}}class o extends i{static get showProgress(){return!1}async convert(){return{file:this.file,metadata:null}}}const r=window.wp.hooks,a=t=>{let e=t;if(!e||"object"!=typeof e||"string"!=typeof e.name||"number"!=typeof e.size||"string"!=typeof e.type||"function"!=typeof e.slice)return new o(e);if(!(e instanceof File)){const t=e;e=new File(t?[t]:[],t?.name||"unknown",{type:t?.type||"application/octet-stream",lastModified:"number"==typeof t?.lastModified?t.lastModified:Date.now()})}if(e.type.startsWith("image/")){if(!function(t){const e={webp:"image/webp",avif:"image/avif"}[t.toLowerCase()]||(t.startsWith("image/")?t:null);if(!e)return!1;const i=document.createElement("canvas");i.width=1,i.height=1;try{return i.toDataURL(e).startsWith(`data:${e}`)}catch(t){return!1}}("webp"))return new o(e);if(s.supportsMimeType(e.type))return new s(e,{format:"webp",quality:window.cimoSettings?.webpQuality||.8,maxDimension:window.cimoSettings?.maxImageDimension||0})}return(0,r.applyFilters)("cimo.getFileConverter",null,e)||new o(e)};function l(t){return!t.every(t=>"NullConverter"===t.constructor.name)}function c(t){return("string"!=typeof t?String(t):t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/`/g,"&#96;")}function m(t,e="editor-canvas"){const i=()=>{const i=document.querySelector(`iframe[name="${e}"]`);if(i&&i.contentDocument){const e=()=>{i.contentDocument.body?t(i.contentDocument):setTimeout(e,50)};"loading"===i.contentDocument.readyState?i.addEventListener("load",()=>{e()}):e()}};i();let n=0;const s=setInterval(()=>{n>=10?clearInterval(s):(n++,i())},1e3),o=new MutationObserver(t=>{t.forEach(t=>{t.addedNodes.forEach(t=>{t.nodeType===Node.ELEMENT_NODE&&("IFRAME"===t.tagName&&t.name===e||t.querySelector&&t.querySelector(`iframe[name="${e}"]`))&&i()})})});return o.observe(document.body,{childList:!0,subtree:!0}),o}const d=t=>{if(!Array.isArray(t))return Promise.resolve();const e=t.filter(t=>null!==t);return 0===e.length||e.every(t=>u(t.filename))?Promise.resolve():(e.forEach(t=>{t.filename&&p(t.filename,t)}),new Promise((t,i)=>{fetch(`${window.cimoSettings?.restUrl||"/wp-json/cimo/v1/"}metadata`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","X-WP-Nonce":window.cimoSettings?.nonce||window.wpApiSettings?.nonce},body:JSON.stringify({metadata:e}),credentials:"same-origin"}).then(t=>t.ok?t.json():t.json().then(e=>{throw new Error(e.message||t.statusText)})).then(e=>{t(e)}).catch(t=>{console.error(`Failed to save metadata for filenames: [${e.map(t=>t.filename).join(", ")}]:`,t),i(new Error(`Failed to save metadata: ${t.message}`))})}))},p=(t,e)=>{window.cimoMetadataCache||(window.cimoMetadataCache={}),window.cimoMetadataCache[t.replaceAll(/\s+/g,"-")]={...e}},u=t=>window.cimoMetadataCache?.[t?.replaceAll(/\s+/g,"-")]||null;class h{constructor(t=[],e=null){this.converters=Array.isArray(t)?t.filter(t=>!0===t?.showProgress):[],this.closeHandler="function"==typeof e?e:null,this.interval=null,this.modal=null,this.progressBars=[],this._setupModal()}open(){this.modal&&0!==this.converters.length&&(this.modal.style.display="flex",this._startInterval())}_handleCloseClick(){confirm((0,e.__)("Closing this dialog will cancel the uploading process. Are you sure you want to continue?","cimo-image-optimizer"))&&(this.closeHandler&&this.closeHandler(),this.close())}close(){this.modal&&0!==this.converters.length&&setTimeout(()=>{this.modal.style.display="none",this._stopInterval(),this.modal.remove(),this.modal=null},300)}_setupModal(){this.modal=document.createElement("div"),this.modal.className="cimo-progress-modal",this.modal.style.cssText="\n\t\t\tposition: fixed;\n\t\t\ttop: 0;\n\t\t\tleft: 0;\n\t\t\twidth: 100vw;\n\t\t\theight: 100vh;\n\t\t\tbackground: rgba(0,0,0,0.35);\n\t\t\tdisplay: none;\n\t\t\tjustify-content: center;\n\t\t\talign-items: center;\n\t\t\tz-index: 9999999;\n\t\t";const t=document.createElement("div");t.className="cimo-progress-wrapper",t.style.cssText="\n\t\t\tbackground: #fff;\n\t\t\tborder-radius: 8px;\n\t\t\tpadding: 2em 2em 1em 2em;\n\t\t\tmax-width: 500px;\n\t\t\tbox-shadow: 0 6px 32px rgba(0,0,0,0.24);\n\t\t\tposition: relative;\n\t\t\twidth: 90%;\n\t\t";const i=document.createElement("h3");i.className="cimo-progress-title",i.innerText=(0,e.__)("Optimizing your files","cimo-image-optimizer"),i.style.cssText="\n\t\t\tfont-size: 1.6em !important;\n\t\t\tfont-weight: 600 !important;\n\t\t\tmargin: 0 0 0.5em !important;\n\t\t",t.appendChild(i);const n=document.createElement("div");if(n.className="cimo-progress-subtitle",n.innerText=(0,e.__)("Preparing your files for upload…","cimo-image-optimizer"),n.style.cssText="\n\t\t\tmargin-bottom: 2em;\n\t\t",t.appendChild(n),this.errorNote=document.createElement("div"),this.errorNote.className="cimo-progress-error-note",this.errorNote.innerText=(0,e.__)("Some media files could not be optimized and were uploaded in their original format.","cimo-image-optimizer"),this.errorNote.style.cssText="\n\t\t\tdisplay: none;\n\t\t\tbackground: #fff3cd;\n\t\t\tcolor: #856404;\n\t\t\tborder: 1px solid #ffeeba;\n\t\t\tborder-radius: 8px;\n\t\t\tpadding: 1em;\n\t\t\tmargin-bottom: 1.5em;\n\t\t\tfont-size: 1em;\n\t\t",t.appendChild(this.errorNote),this.closeHandler){const e=document.createElement("button");e.className="cimo-progress-close",e.type="button",e.innerHTML="&times;",e.style.cssText="\n\t\t\t\tposition: absolute;\n\t\t\t\ttop: 0.7em;\n\t\t\t\tright: 1em;\n\t\t\t\tbackground: transparent;\n\t\t\t\tborder: none;\n\t\t\t\tfont-size: 2em;\n\t\t\t\tcursor: pointer;\n\t\t\t\tcolor: #888;\n\t\t\t",e.addEventListener("click",()=>this._handleCloseClick()),t.appendChild(e)}this.progressBars=[],this.progressList=document.createElement("div"),this.progressList.className="cimo-progress-list",t.appendChild(this.progressList),this.modal.appendChild(t),document.body.appendChild(this.modal),this._renderProgressBars()}_renderProgressBars(){this.progressList.innerHTML="",this.progressBars=[],this.converters.forEach((t,e)=>{const i=document.createElement("div");i.className="cimo-progress-bar-container",i.style.cssText="\n\t\t\t\tmargin-bottom: 1em;\n\t\t\t\tpadding: 16px 16px 16px 70px;\n\t\t\t\tborder: 1px solid #e2e8f0;\n\t\t\t\tborder-radius: 12px;\n\t\t\t\tposition: relative;\n\t\t\t";const n=document.createElement("span");n.className="cimo-stat-icon",n.style.cssText="\n\t\t\t\tbackground: #16a2491a;\n        \t\tcolor: #16a249;\n\t\t\t\tpadding: 8px;\n\t\t\t\tborder-radius: 8px;\n\t\t\t\tmargin-bottom: 8px;\n\t\t\t\tdisplay: flex;\n\t\t\t\talign-items: center;\n\t\t\t\tjustify-content: center;\n\t\t\t\tposition: absolute;\n\t\t\t\tleft: 16px;\n\t\t\t\ttop: 16px;\n\t\t\t";let s="";s=t.file&&t.file.type&&t.file.type.startsWith("video/")?'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-video-icon lucide-video"><path d="m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5"/><rect x="2" y="6" width="14" height="12" rx="2"/></svg>':t.file&&t.file.type&&t.file.type.startsWith("audio/")?'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-music-icon lucide-music"><path d="M9 18V5l12-2v13"/><circle cx="6" cy="18" r="3"/><circle cx="18" cy="16" r="3"/></svg>':'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-image-icon lucide-image"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/></svg>',n.innerHTML=s,i.appendChild(n);const o=document.createElement("div");o.className="cimo-progress-label",o.innerText=t.file?.name||`File ${e+1}`,o.style.cssText="\n\t\t\t\tmargin-bottom: 0.2em;\n\t\t\t\tfont-size: 1em;\n\t\t\t\tfont-weight: 600;\n\t\t\t\tmax-width: 80%;\n\t\t\t\twhite-space: nowrap;\n\t\t\t\ttext-overflow: ellipsis;\n\t\t\t\toverflow: hidden;\n\t\t\t";const r=document.createElement("div");r.className="cimo-size-label",r.innerText=t.file&&t.file.size?t.file.size/1024/1024>=1?(t.file.size/1024/1024).toFixed(2)+" MB":(t.file.size/1024).toFixed(1)+" KB":"",r.style.cssText="\n\t\t\t\tmargin-bottom: 0.5em;\n\t\t\t\tfont-size: 1em;\n\t\t\t";const a=document.createElement("div");a.style.cssText="\n\t\t\t\tdisplay: flex;\n\t\t\t\talign-items: center;\n\t\t\t\tjustify-content: space-between;\n\t\t\t\tmargin-bottom: 0.5em;\n\t\t\t";const l=document.createElement("div");l.className="cimo-progress-status-label",l.innerText="",l.style.cssText="\n\t\t\t\tfont-size: 1em;\n\t\t\t\tcolor: #3b3b3b;\n\t\t\t";const c=document.createElement("div");c.className="cimo-percentage-label",c.innerText="0%",c.style.cssText="\n\t\t\t\tfont-size: 1em;\n\t\t\t",a.appendChild(l),a.appendChild(c);const m=document.createElement("div");m.className="cimo-progress-bar-bg",m.style.cssText="\n\t\t\t\tbackground: #e8ecef;\n\t\t\t\tborder-radius: 5px;\n\t\t\t\theight: 8px;\n\t\t\t\twidth: 100%;\n\t\t\t\toverflow: hidden;\n\t\t\t";const d=document.createElement("div");d.className="cimo-progress-bar",d.style.cssText="\n\t\t\t\tbackground: linear-gradient(90deg, #00d8f0 0%, #2bc566 100%);\n\t\t\t\twidth: 0%;\n\t\t\t\theight: 100%;\n\t\t\t\ttransition: width 0.5s linear;\n\t\t\t\tborder-radius: 5px 0 0 5px;\n\t\t\t",d.sizeLabelEl=r,d.statusLabelEl=l,d.percentageLabelEl=c,m.appendChild(d),i.appendChild(o),i.appendChild(r),i.appendChild(a),i.appendChild(m),this.progressList.appendChild(i),this.progressBars.push(d)})}_startInterval(){this.interval||(this._updateProgress(),this.interval=setInterval(()=>this._updateProgress(),500))}_stopInterval(){this.interval&&(clearInterval(this.interval),this.interval=null)}_updateProgress(){let t=!0,e=!1;this.converters.forEach((i,n)=>{let s=100*i.progress;("number"!=typeof s||isNaN(s)||s<0)&&(s=0),s>=100&&(s=100),s<100&&(t=!1),i.errorMessage&&(e=!0,this.errorNote.style.display="block"),this.progressBars[n]&&(this.progressBars[n].statusLabelEl.style.cssText=`\n\t\t\t\t\tcolor: ${i.errorMessage?"#dc3545":"inherit"};\n\t\t\t\t`,this.progressBars[n].statusLabelEl.innerText=i.errorMessage||i.status,this.progressBars[n].style.width=s+"%",this.progressBars[n].percentageLabelEl.innerText=parseInt(s)+"%")}),t&&"block"===this.modal.style.display&&(e||setTimeout(()=>this.close(),750))}}function g(t){if(!t)return;if(!t.body)return;t.body.__cimo_dropzone_listener_attached||(t.body.addEventListener("drop",async e=>{if(e.__cimo_converted)return;const i=Array.from(e.dataTransfer.files).map(t=>a(t));if(!l(i))return;if(!(e.target.closest(".media-frame-uploader")||e.target.closest(".media-upload-form")||e.target.closest(".editor-post-featured-image")||e.target.closest(".editor-styles-wrapper")||e.target.closest(".uploader-window")))return;let n;for(e.preventDefault(),e.stopPropagation();n=document.querySelector('.uploader-window[style*="display: block"]');)n.style.display="none";const s=new h(i,()=>{i.forEach(t=>t.cancel())});s.open();let o=!1;const r=await Promise.all(i.map(async t=>{try{return await t.convert()}catch(e){return o=!0,{file:t.file,metadata:null}}})),c=r.map(t=>t.file),m=r.map(t=>t.metadata),p=new DataTransfer;if(c.forEach(t=>{p.items.add(t)}),await d(m),e.target?.classList.contains("components-drop-zone")){const i=t!==document,n=new Event("drop",{bubbles:!i});Object.defineProperty(n,"dataTransfer",{value:p,writable:!1}),n.__cimo_converted=!0,e.target.dispatchEvent(n)}else{const i=document.querySelector('.media-modal input[type="file"]')||document.querySelector('.media-upload-form input[type="file"]')||document.querySelector('input[type="file"]');if(i){i.files=p.files;const e=t!==document,n=new Event("change",{bubbles:!e});n.__cimo_converted=!0,i.dispatchEvent(n)}else{const t=new Event("drop",{bubbles:!0});Object.defineProperty(t,"dataTransfer",{value:p,writable:!1}),t.__cimo_converted=!0,e.target.dispatchEvent(t)}}o||s.close()},!0),t.body.__cimo_dropzone_listener_attached=!0)}function f(t){if(!window.wp&&!t)return;if(!t.body)return;t.body.__cimo_selectfiles_listener_attached||(t.body.addEventListener("change",async t=>{if("file"!==t.target.type)return;if(t.__cimo_converted)return;const e=Array.from(t.target.files).map(t=>a(t));if(!l(e))return;if(!(t.target.closest(".components-form-file-upload")||t.target.closest(".media-frame")||t.target.closest(".media-upload-form")||t.target.closest(".moxie-shim")))return;t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation();const i=new h(e,()=>{e.forEach(t=>t.cancel())});i.open();let n=!1;const s=await Promise.all(e.map(async t=>{try{return await t.convert()}catch(e){return n=!0,{file:t.file,metadata:null}}})),o=s.map(t=>t.file),r=s.map(t=>t.metadata),c=new DataTransfer;o.forEach(t=>{c.items.add(t)}),await d(r),t.target.files=c.files;const m=new Event("change",{bubbles:!0});m.__cimo_converted=!0,t.target.dispatchEvent(m),n||i.close()},!0),t.body.__cimo_selectfiles_listener_attached=!0)}function w(t,e=2,i=!1){if(0===t)return"0 Bytes";const n=e<0?0:e,s=Math.abs(t),o=Math.floor(Math.log(s)/Math.log(1024));let r=t<0?"-":"";return i&&(r="-"===r?"":"-"),r+parseFloat((s/Math.pow(1024,o)).toFixed(n))+" "+["Bytes","KB","MB","GB"][o]}t(()=>{g(document),m(t=>{g(t)})}),t(()=>{f(document),m(t=>{f(t)})}),t(()=>{"undefined"!=typeof wp&&wp.media&&wp.media.view&&wp.media.view.Attachment&&wp.media.view.Attachment.Details&&(wp.media.view.Attachment.Details=wp.media.view.Attachment.Details.extend({template:function(t){const i=wp.media.template("attachment-details")(t),n=document.createElement("div");n.innerHTML=i;let s=t.model.get("cimo")||null;s&&0!==Object.keys(s).length||(s=u(t.model.get("originalImageName")||t.model.get("filename")));const o=n.querySelector(".attachment-info");if(s&&o){const i=document.createElement("div");i.className="cimo-media-manager-metadata";const n=function(t){if(!t)return"Media";const[e="media"]=t.split("/");switch(e.toLowerCase()){case"image":return"Image";case"video":return"Video";case"audio":return"Audio";default:return"Media"}}(s.convertedFormat||t.model.get("mime")||"");let r=`<div class="cimo-media-manager-metadata-title-container">\n\t\t\t\t<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 672 672" height="20" width="20"><path d="M132.5 132.5C182.4 82.5 253 56 336 56C419 56 489.6 82.5 539.5 132.5C589.4 182.5 616 253 616 336C616 419 589.5 489.6 539.5 539.5C489.5 589.4 419 616 336 616C253 616 182.4 589.5 132.5 539.5C82.6 489.5 56 419 56 336C56 253 82.5 182.4 132.5 132.5zM465.5 273.9C477.6 264.2 479.5 246.6 469.9 234.5C460.3 222.4 442.6 220.5 430.5 230.1C378 272.1 330.3 341.9 306.7 379.4C291.4 359.3 267.2 331.1 239.5 312.6C226.6 304 209.2 307.5 200.7 320.4C192.2 333.3 195.6 350.7 208.5 359.2C237.4 378.5 264.1 415.1 274.1 429.9C281.5 440.9 294 447.9 307.9 447.9C322.3 447.9 335.5 440.3 342.8 428C357.2 403.5 410 318.3 465.6 273.8z"/></svg>\n\t\t\t\t<h3 class="cimo-media-manager-metadata-title">${c((0,e.sprintf)((0,e.__)("%s Optimized by Cimo","cimo-image-optimizer"),n))}</h3>\n\t\t\t\t</div>\n\t\t\t\t<ul>`;const a=s.compressionSavings?(100-100*s.compressionSavings).toFixed(2):null,l=w(s.originalFilesize-s.convertedFilesize,1,!0);r+=`<li class="cimo-compression-savings ${c(a>0?"cimo-optimization-savings-up":"cimo-optimization-savings-down")}">Saved ${c(a)}% <span class="cimo-compression-savings-bytes">(${c(l)})</span></li>`;const m=w(parseInt(s.originalFilesize)||0),d=w(parseInt(s.convertedFilesize)||0);r+=`<li class="cimo-filesize-original">Original: <span class="cimo-value">${c(m)}</span></li>`,r+=`<li class="cimo-filesize-optimized">Optimized: <span class="cimo-value">${c(d)}</span></li>`,r+=`<li class="cimo-converted">🏞️ Converted to <span class="cimo-value">${c(function(t){if(!t)return"";const e=t.split("/"),i=e[1]||e[0]||"";return"webp"===i?"WebP":i.charAt(0).toUpperCase()+i.slice(1)}(s.convertedFormat))}</span></li>`;let p="N/A";if(s.conversionTime){const t=parseFloat(s.conversionTime);p=t<1e3?`${t.toFixed(0)} ms`:t<6e4?`${(t/1e3).toFixed(1)} sec`:`${(t/6e4).toFixed(1)} min`}r+=`<li class="cimo-time">⚡️ Done in <span class="cimo-value">${c(p)}</span></li>`,i.innerHTML=r,o.appendChild(i)}return n.innerHTML}}))})})();
  • cimo-image-optimizer/tags/1.2.0/cimo.php

    r3377996 r3402030  
    11<?php
    22/**
    3  * Plugin Name: Cimo - Free Instant Image Optimizer & WebP Converter
     3 * Plugin Name: Cimo - Image Optimizer
    44 * Plugin URI: https://wordpress.org/plugins/cimo-image-optimizer
    55 * Description: Unlimited free image compression and WebP conversion, done instantly as you upload them. No quotas, no external servers, no limits.
     
    88 * License: GPLv2 or later
    99 * Text Domain: cimo-image-optimizer
    10  * Version: 1.1.2
     10 * Version: 1.2.0
    1111 *
    12  * @fs_premium_only /freemius.php, /freemius/
     12 * @fs_premium_only /freemius.php, /freemius/, /lib/freemius-php-sdk
    1313 */
    1414
     
    1919
    2020defined( 'CIMO_FILE' ) || define( 'CIMO_FILE', __FILE__ );
     21defined( 'CIMO_BUILD' ) || define( 'CIMO_BUILD', 'free' );
    2122
    2223require_once __DIR__ . '/src/admin/class-script-loader.php';
     
    3536}
    3637register_activation_hook( __FILE__, 'cimo_activate' );
     38
     39if ( CIMO_BUILD === 'premium' ) {
     40    /**
     41     * Premium initialize code.
     42     */
     43    if ( file_exists( plugin_dir_path( __FILE__ ) . 'pro__premium_only/index.php' ) ) {
     44        require_once( plugin_dir_path( __FILE__ ) . 'pro__premium_only/index.php' );
     45    }
     46}
  • cimo-image-optimizer/tags/1.2.0/readme.txt

    r3381565 r3402030  
    55Tested up to: 6.8.3
    66Requires PHP: 8.0
    7 Stable tag: 1.1.2
     7Stable tag: 1.2.0
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    1515**Optimize all your images instantly and for free.**
    1616
    17 Cimo is a game-changer for image optimization. It optimizes and converts your images instantly as you upload — even before the files are added to your Media Library.
     17Cimo is a game-changer for media optimization. It optimizes, resizes and converts your images instantly as you upload — even before the files are added to your Media Library.
    1818
    1919From WordPress' point of view, it's as if you optimized your image BEFORE your uploaded it. Now, this is next-next-gen image optimization.
     
    2727* No external image-processing services
    2828
    29 > **Note:** Cimo works in all modern browsers (Chrome, Firefox, Edge, Opera). This currently doesn't work in Safari, images would just upload as they normally would, please use any of the browsers listed.
     29> **Note:** Cimo works in all modern browsers (Chrome, Firefox, Edge, Opera). Image optimization currently doesn't work in Safari, images would just upload as they normally would, please use any of the browsers listed.
    3030
    3131Image Optimization options:
     
    8787**Since Cimo's optimization works during the upload process, Cimo should be compatible with any plugin that uses images**
    8888
     89= What's in Premium? =
     90
     91If you upgrade to Cimo Premium, you will get the following:
     92
     93* **Video Optimization** – automatically optimize and optionally downscale the resolution of videos as you upload them
     94* **Audio Optimization** – auotmatically optimize audio files as you upload them
     95* **Low Quality Image Placeholders (LQIP)** – for native image blocks, display a subtle image placeholder while waiting for images to load, then fade the loaded image in.
     96
     97Video & Audio optimization are also performed as you upload your files, even before the files are added to your Media Library.
     98
    8999== Technical Details ==
    90100
     
    191201== Changelog ==
    192202
     203= 1.2.0 =
     204
     205* New: Video Optimization (premium)
     206* New: Audio Optimization (premium)
     207* New: Low Quality Image Placeholders (premium)
     208* New: Added rating notice at the right time
     209* Fixed: Now intercepts media uploads when performed inside the block editor iframe
     210
    193211= 1.1.2 =
    194212
  • cimo-image-optimizer/tags/1.2.0/src/admin/class-admin-notices.php

    r3353691 r3402030  
    1212    class Cimo_Admin_Notices {
    1313        public function __construct() {
    14             add_action( 'admin_notices', [ $this, 'show_activation_notice' ] );
    15             add_action( 'admin_init', [ $this, 'dismiss_activation_notice' ] );
    16             add_action( 'wp_ajax_cimo_dismiss_activation_ajax', [ $this, 'ajax_dismiss_activation_notice' ] );
     14            if ( CIMO_BUILD === 'free' ) {
     15                add_action( 'admin_notices', [ $this, 'show_activation_notice' ] );
     16                add_action( 'admin_init', [ $this, 'dismiss_activation_notice' ] );
     17                add_action( 'wp_ajax_cimo_dismiss_activation_ajax', [ $this, 'ajax_dismiss_activation_notice' ] );
     18            }
    1719        }
    1820
  • cimo-image-optimizer/tags/1.2.0/src/admin/class-admin.php

    r3377045 r3402030  
    7575                                    ],
    7676                                ],
     77
     78                                // LQIP settings
     79                                'lqip_enabled' => [
     80                                    'type' => 'integer',
     81                                ],
     82                                'lqip_pulse_speed' => [
     83                                    'type' => 'number',
     84                                    'format' => 'float',
     85                                ],
     86                                'lqip_brightness' => [
     87                                    'type' => 'number',
     88                                    'format' => 'float',
     89                                ],
     90                                'lqip_fade_duration' => [
     91                                    'type' => 'number',
     92                                    'format' => 'float',
     93                                ],
     94
     95                                // Video Optimization settings
     96                                'video_optimization_enabled' => [
     97                                    'type' => 'integer',
     98                                ],
     99                                'video_quality' => [
     100                                    'type' => 'integer',
     101                                ],
     102                                'video_max_resolution' => [
     103                                    'type' => 'string',
     104                                ],
     105
     106                                // Audio Optimization settings
     107                                'audio_optimization_enabled' => [
     108                                    'type' => 'integer',
     109                                ],
     110                                'audio_quality' => [
     111                                    'type' => 'integer',
     112                                ],
    77113                            ],
    78114                        ],
     
    80116                ]
    81117            );
     118
     119            register_setting(
     120                'cimo_rating',
     121                'cimo_rating_dismissed',
     122                [
     123                    'type'              => 'string',
     124                    'description'       => __( 'Tracks if the rating notice has been dismissed.', 'cimo-image-optimizer' ),
     125                    'sanitize_callback' => [ $this, 'sanitize_rating_dismissed' ],
     126                    'show_in_rest'      => [
     127                        'schema' => [
     128                            'type' => 'string',
     129                            'enum' => [ '0', '1' ],
     130                        ],
     131                    ],
     132                    'default'           => '0',
     133                ]
     134            );
    82135        }
    83136
     
    90143                return;
    91144            }
     145           
     146            // Enqueue WordPress component styles
     147            wp_enqueue_style( 'wp-components' );
     148
     149            // This should return the dependencies for both css and js, these will be merged with the default dependencies.
     150            $dependencies = apply_filters( 'cimo/admin/enqueue_admin_scripts', ['css' => [], 'js' => []] );
    92151
    93152            // Get the build files
     
    95154            $build_url = plugin_dir_url( CIMO_FILE ) . 'build/admin/';
    96155           
    97             // Enqueue WordPress component styles
    98             wp_enqueue_style( 'wp-components' );
    99            
    100156            // Enqueue CSS
    101             $script_asset = include $build_dir . 'admin-settings.asset.php';
     157            $script_asset = include $build_dir . 'admin-page-styles.asset.php';
    102158            wp_enqueue_style(
    103                 'cimo-admin-settings',
    104                 $build_url . 'admin-settings.css',
    105                 [ 'wp-components' ],
     159                'cimo-admin-page-styles',
     160                $build_url . 'admin-page-styles.css',
     161                array_merge( [ 'wp-components' ], $dependencies['css'] ),
    106162                $script_asset['version']
    107163            );
     
    112168                'cimo-admin-page',
    113169                $build_url . 'admin-page.js',
    114                 $script_asset['dependencies'],
     170                array_merge( $script_asset['dependencies'], $dependencies['js'] ),
    115171                $script_asset['version'],
    116172                true
     
    135191                'stats' => $stats,
    136192                'imageSizes' => $formatted_sizes,
     193                'ratingDismissed' => '1' === get_option( 'cimo_rating_dismissed', '0' ) ? '1' : '0',
    137194            ] );
    138195        }
     
    158215         */
    159216        public function sanitize_options( $options ) {
    160             $sanitized = [];
     217            // Load up the complete options so we don't lose any existing settings.
     218            $current = get_option( 'cimo_options', [] );
     219            $sanitized = is_array( $current ) ? $current : [];
    161220
    162221            // Sanitize webp quality
     
    189248            }
    190249
     250            // Sanitize lqip_enabled
     251            if ( isset( $options['lqip_enabled'] ) ) {
     252                $sanitized['lqip_enabled'] = $options['lqip_enabled'] ? 1 : 0;
     253            }
     254            if ( isset( $options['lqip_pulse_speed'] ) ) {
     255                $sanitized['lqip_pulse_speed'] = floatval( $options['lqip_pulse_speed'] );
     256            }
     257            if ( isset( $options['lqip_brightness'] ) ) {
     258                $sanitized['lqip_brightness'] = floatval( $options['lqip_brightness'] );
     259            }
     260            if ( isset( $options['lqip_fade_duration'] ) ) {
     261                $sanitized['lqip_fade_duration'] = floatval( $options['lqip_fade_duration'] );
     262            }
     263
     264            // Sanitize video quality
     265            if ( isset( $options['video_optimization_enabled'] ) ) {
     266                $sanitized['video_optimization_enabled'] = $options['video_optimization_enabled'] ? 1 : 0;
     267            }
     268            if ( isset( $options['video_quality'] ) ) {
     269                $sanitized['video_quality'] = intval( $options['video_quality'] );
     270            }
     271            if ( isset( $options['video_max_resolution'] ) ) {
     272                $sanitized['video_max_resolution'] = sanitize_text_field( $options['video_max_resolution'] );
     273            }
     274
     275            // Sanitize audio quality
     276            if ( isset( $options['audio_optimization_enabled'] ) ) {
     277                $sanitized['audio_optimization_enabled'] = $options['audio_optimization_enabled'] ? 1 : 0;
     278            }
     279            if ( isset( $options['audio_quality'] ) ) {
     280                $sanitized['audio_quality'] = intval( $options['audio_quality'] );
     281            }
     282
    191283            return $sanitized;
     284        }
     285
     286        /**
     287         * Sanitize rating dismissed flag
     288         */
     289        public function sanitize_rating_dismissed( $value ) {
     290            return '1' === (string) $value ? '1' : '0';
    192291        }
    193292
  • cimo-image-optimizer/tags/1.2.0/src/admin/class-meta-box.php

    r3352840 r3402030  
    6464                        }
    6565
     66                        // Helper to get media type label from mimetype.
     67                        function cimo_get_media_type_label( $mimetype ) {
     68                            if ( ! is_string( $mimetype ) || strpos( $mimetype, '/' ) === false ) {
     69                                return esc_html__( 'Media', 'cimo-image-optimizer' );
     70                            }
     71                            $parts = explode( '/', $mimetype );
     72                            $category = strtolower( $parts[0] );
     73
     74                            switch ( $category ) {
     75                                case 'image':
     76                                    return esc_html__( 'Image', 'cimo-image-optimizer' );
     77                                case 'video':
     78                                    return esc_html__( 'Video', 'cimo-image-optimizer' );
     79                                case 'audio':
     80                                    return esc_html__( 'Audio', 'cimo-image-optimizer' );
     81                                default:
     82                                    return esc_html__( 'Media', 'cimo-image-optimizer' );
     83                            }
     84                        }
     85
    6686                        $cimo = $metadata['cimo'];
    6787
     
    7797                        $converted_size = cimo_format_filesize( $converted_filesize );
    7898
    79                         $converted_format = isset( $cimo['convertedFormat'] ) ? cimo_convert_mimetype_to_format( $cimo['convertedFormat'] ) : '';
     99                        $converted_format_raw = isset( $cimo['convertedFormat'] ) ? $cimo['convertedFormat'] : ( isset( $post->post_mime_type ) ? $post->post_mime_type : '' );
     100                        $converted_format = $converted_format_raw ? cimo_convert_mimetype_to_format( $converted_format_raw ) : '';
     101                        $media_type_label = cimo_get_media_type_label( $converted_format_raw );
    80102                        $converttime = isset( $cimo['conversionTime'] ) ? floatval( $cimo['conversionTime'] ) : null;
    81103                        if ( $converttime !== null ) {
     
    94116                        echo '<div class="cimo-media-manager-metadata-title-container">';
    95117                        echo '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 672 672" height="20" width="20"><path d="M132.5 132.5C182.4 82.5 253 56 336 56C419 56 489.6 82.5 539.5 132.5C589.4 182.5 616 253 616 336C616 419 589.5 489.6 539.5 539.5C489.5 589.4 419 616 336 616C253 616 182.4 589.5 132.5 539.5C82.6 489.5 56 419 56 336C56 253 82.5 182.4 132.5 132.5zM465.5 273.9C477.6 264.2 479.5 246.6 469.9 234.5C460.3 222.4 442.6 220.5 430.5 230.1C378 272.1 330.3 341.9 306.7 379.4C291.4 359.3 267.2 331.1 239.5 312.6C226.6 304 209.2 307.5 200.7 320.4C192.2 333.3 195.6 350.7 208.5 359.2C237.4 378.5 264.1 415.1 274.1 429.9C281.5 440.9 294 447.9 307.9 447.9C322.3 447.9 335.5 440.3 342.8 428C357.2 403.5 410 318.3 465.6 273.8z"/></svg>';
    96                         echo '<h3 class="cimo-media-manager-metadata-title">Image Optimized by Cimo</h3>';
     118                        echo '<h3 class="cimo-media-manager-metadata-title">' . sprintf( esc_html__( '%s Optimized by Cimo', 'cimo-image-optimizer' ), esc_html( $media_type_label ) ) . '</h3>';
    97119                        echo '</div>';
    98120                        echo '<ul>';
  • cimo-image-optimizer/tags/1.2.0/src/admin/class-script-loader.php

    r3377045 r3402030  
    1313        public function __construct() {
    1414            // Enqueue for the block editor.
    15             add_action( 'enqueue_block_editor_assets', [ $this, 'enqueue_media_assets' ] );
     15            add_action( 'enqueue_block_editor_assets', [ $this, 'enqueue_cimo_assets' ] );
    1616            // Enqueue for Elementor.
    17             add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'enqueue_media_assets' ] );
     17            add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'enqueue_cimo_assets' ] );
    1818            // Enqueue for Beaver Builder main window (outside BB's iframe).
    1919            if ( class_exists( 'FLBuilderModel' ) ) {
     
    2323            add_action( 'bricks_before_site_wrapper', [ $this, 'maybe_enqueue_for_bricks_builder' ] );
    2424            // Enqueue for Oxygen Builder
    25             add_action( 'oxygen_enqueue_ui_scripts', [ $this, 'enqueue_media_assets' ] );
     25            add_action( 'oxygen_enqueue_ui_scripts', [ $this, 'enqueue_cimo_assets' ] );
    2626            // Enqueue for Divi
    27             add_action( 'et_fb_enqueue_assets', [ $this, 'enqueue_media_assets' ] );
     27            add_action( 'et_fb_enqueue_assets', [ $this, 'enqueue_cimo_assets' ] );
    2828            // Enqueue for the admin area in general.
    29             add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_media_assets' ] );
     29            add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_cimo_assets' ] );
    3030        }
    3131
     
    3636            // Check if we're in the Beaver Builder editor context.
    3737            if ( class_exists( 'FLBuilderModel' ) && FLBuilderModel::is_builder_active() ) {
    38                 $this->enqueue_media_assets();
     38                $this->enqueue_cimo_assets();
    3939            }
    4040        }
     
    4545        public function maybe_enqueue_for_bricks_builder() {
    4646            if ( function_exists( 'bricks_is_builder' ) && bricks_is_builder() ) {
    47                 $this->enqueue_media_assets();
     47                $this->enqueue_cimo_assets();
    4848            }
    4949        }
    5050
    51         public function enqueue_media_assets() {
    52             // If cimo-editor is already enqueued, don't enqueue again.
    53             if ( wp_script_is( 'cimo-editor', 'enqueued' ) ) {
     51        public function enqueue_cimo_assets() {
     52            // If cimo-script is already enqueued, don't enqueue again.
     53            if ( wp_script_is( 'cimo-script', 'enqueued' ) ) {
    5454                return;
    5555            }
     56
     57            // This should return the dependencies for both css and js, these will be merged with the default dependencies.
     58            $dependencies = apply_filters( 'cimo/script_loader/enqueue_cimo_assets', ['css' => [], 'js' => []] );
    5659
    5760            $build_dir = plugin_dir_path( CIMO_FILE ) . 'build/admin/';
     
    6164            $script_asset = include $build_dir . 'index.asset.php';
    6265            wp_enqueue_script(
    63                 'cimo-editor',
     66                'cimo-script',
    6467                $build_url . 'index.js',
    65                 // Remove wp-dom-ready since it's not really a dependency, but wp-scripts includes it.
    66                 array_values( array_diff( $script_asset['dependencies'], [ 'wp-dom-ready' ] ) ),
     68                array_merge(
     69                    // Remove wp-dom-ready since it's not really a dependency, but wp-scripts includes it.
     70                    array_values( array_diff( $script_asset['dependencies'], [ 'wp-dom-ready' ] ) ),
     71                    $dependencies['js']
     72                ),
    6773                $script_asset['version'],
    6874                true
     
    7480            // Localize script with REST API URL, nonce, and settings
    7581            wp_localize_script(
    76                 'cimo-editor',
     82                'cimo-script',
    7783                'cimoSettings',
    7884                [
     
    8187                    'webpQuality' => ! empty( $settings['webp_quality'] ) ? (int) $settings['webp_quality'] : 80,
    8288                    'maxImageDimension' => ! empty( $settings['max_image_dimension'] ) ? (int) $settings['max_image_dimension'] : 0,
     89                    'videoOptimizationEnabled' => isset( $settings['video_optimization_enabled'] ) ? (int) $settings['video_optimization_enabled'] : 1,
     90                    'videoQuality' => ! empty( $settings['video_quality'] ) ? (int) $settings['video_quality'] : 3,
     91                    'videoMaxResolution' => ! empty( $settings['video_max_resolution'] ) ? $settings['video_max_resolution'] : '',
     92                    'audioOptimizationEnabled' => isset( $settings['audio_optimization_enabled'] ) ? (int) $settings['audio_optimization_enabled'] : 1,
     93                    'audioQuality' => ! empty( $settings['audio_quality'] ) ? (int) $settings['audio_quality'] : 128,
    8394                ]
    8495            );
    8596
    86             // Enqueue the admin CSS file
    87             $style_asset = include $build_dir . 'admin.asset.php';
     97            // Enqueue the main admin CSS file
     98            $style_asset = include $build_dir . 'index-styles.asset.php';
    8899            wp_enqueue_style(
    89                 'cimo-admin',
    90                 $build_url . 'admin.css',
    91                 $style_asset['dependencies'],
     100                'cimo-script-styles',
     101                $build_url . 'index-styles.css',
     102                array_merge( $style_asset['dependencies'], $dependencies['css'] ),
    92103                $style_asset['version']
    93104            );
  • cimo-image-optimizer/trunk/build/admin/admin-page.asset.php

    r3377045 r3402030  
    1 <?php return array('dependencies' => array('react-jsx-runtime', 'wp-api-fetch', 'wp-components', 'wp-element', 'wp-i18n'), 'version' => '458b9896520c1e2544b1');
     1<?php return array('dependencies' => array('react-jsx-runtime', 'wp-api-fetch', 'wp-components', 'wp-element', 'wp-hooks', 'wp-i18n'), 'version' => '48f89642dbaf07f34e19');
  • cimo-image-optimizer/trunk/build/admin/admin-page.js

    r3377045 r3402030  
    1 (()=>{"use strict";var e={n:i=>{var a=i&&i.__esModule?()=>i.default:()=>i;return e.d(a,{a}),a},d:(i,a)=>{for(var s in a)e.o(a,s)&&!e.o(i,s)&&Object.defineProperty(i,s,{enumerable:!0,get:a[s]})}};e.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),e.o=(e,i)=>Object.prototype.hasOwnProperty.call(e,i),(()=>{var i;e.g.importScripts&&(i=e.g.location+"");var a=e.g.document;if(!i&&a&&(a.currentScript&&"SCRIPT"===a.currentScript.tagName.toUpperCase()&&(i=a.currentScript.src),!i)){var s=a.getElementsByTagName("script");if(s.length)for(var t=s.length-1;t>-1&&(!i||!/^http(s?):/.test(i));)i=s[t--].src}if(!i)throw new Error("Automatic publicPath is not supported in this browser");i=i.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),e.p=i+"../"})();const i=window.wp.element,a=window.wp.components,s=window.wp.apiFetch;var t=e.n(s);const n=window.wp.i18n,o=e.p+"images/logo-long.cca876ef.webp",c=window.ReactJSXRuntime,l=()=>{const[e,s]=(0,i.useState)({webpQuality:80,maxImageDimension:"",disableWpScaling:1,disableThumbnailGeneration:0,thumbnailSizes:[]}),[l,m]=(0,i.useState)([]),[r,d]=(0,i.useState)(!1),[p,h]=(0,i.useState)(""),[g,u]=(0,i.useState)(!0);(0,i.useEffect)(()=>{(async()=>{window.cimoAdmin&&window.cimoAdmin.imageSizes&&m(window.cimoAdmin.imageSizes),await x(),u(!1)})()},[]);const x=async()=>{try{const e=(await t()({path:"/wp/v2/settings"})).cimo_options||{};s({webpQuality:void 0!==e.webp_quality?e.webp_quality:80,maxImageDimension:e.max_image_dimension||"",disableWpScaling:void 0!==e.disable_wp_scaling?e.disable_wp_scaling:1,disableThumbnailGeneration:void 0!==e.disable_thumbnail_generation?e.disable_thumbnail_generation:0,thumbnailSizes:e.thumbnail_sizes||[]})}catch(e){}},w=(e,i)=>{s(a=>({...a,[e]:i}))};return g?(0,c.jsx)("div",{className:"cimo-admin-settings-wrap",children:(0,c.jsx)("div",{className:"cimo-loading",children:(0,c.jsx)("p",{children:(0,n.__)("Loading settings…","cimo-image-optimizer")})})}):(0,c.jsxs)("div",{className:"cimo-admin-settings-wrap",children:[(0,c.jsxs)("div",{className:"cimo-header",children:[(0,c.jsx)("img",{className:"cimo-logo",src:o,alt:(0,n.__)("Cimo Logo","cimo-image-optimizer"),height:"35"}),(0,c.jsxs)("div",{className:"cimo-stats-section",children:[(0,c.jsxs)("div",{className:"cimo-stats-column cimo-stats-column-big",children:[(0,c.jsx)("h3",{children:(0,n.__)("Total Storage Saved","cimo-image-optimizer")}),(0,c.jsxs)("div",{className:"cimo-stats-main",children:[(0,c.jsx)("span",{className:"cimo-stat-value",children:window.cimoAdmin.stats.total_storage_saved}),(0,c.jsxs)("span",{className:"cimo-stat-percentage",children:["↓ ",window.cimoAdmin.stats.percentage_saved,"% ",(0,n.__)("reduction","cimo-image-optimizer")]})]}),(0,c.jsx)("div",{className:"cimo-stats-details",children:(0,n.__)("Across all optimized media files","cimo-image-optimizer")})]}),(0,c.jsxs)("div",{className:"cimo-stats-column cimo-stats-column-small",children:[(0,c.jsx)("div",{className:"cimo-stat-icon",children:(0,c.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-image w-5 h-5 text-primary","data-lov-id":"src/pages/Index.tsx:66:22","data-lov-name":"Image","data-component-path":"src/pages/Index.tsx","data-component-line":"66","data-component-file":"Index.tsx","data-component-name":"Image","data-component-content":"%7B%22className%22%3A%22w-5%20h-5%20text-primary%22%7D",children:[(0,c.jsx)("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),(0,c.jsx)("circle",{cx:"9",cy:"9",r:"2"}),(0,c.jsx)("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})]})}),(0,c.jsx)("span",{className:"cimo-stat-value",children:window.cimoAdmin.stats.media_optimized}),(0,c.jsx)("span",{className:"cimo-stat-label",children:(0,n.__)("Media Files Optimized","cimo-image-optimizer")})]}),(0,c.jsxs)("div",{className:"cimo-stats-column cimo-stats-column-small",children:[(0,c.jsx)("div",{className:"cimo-stat-icon",children:(0,c.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-hard-drive w-5 h-5 text-destructive","data-lov-id":"src/pages/Index.tsx:80:22","data-lov-name":"HardDrive","data-component-path":"src/pages/Index.tsx","data-component-line":"80","data-component-file":"Index.tsx","data-component-name":"HardDrive","data-component-content":"%7B%22className%22%3A%22w-5%20h-5%20text-destructive%22%7D",children:[(0,c.jsx)("line",{x1:"22",x2:"2",y1:"12",y2:"12"}),(0,c.jsx)("path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z"}),(0,c.jsx)("line",{x1:"6",x2:"6.01",y1:"16",y2:"16"}),(0,c.jsx)("line",{x1:"10",x2:"10.01",y1:"16",y2:"16"})]})}),(0,c.jsx)("span",{className:"cimo-stat-value",children:window.cimoAdmin.stats.before}),(0,c.jsx)("span",{className:"cimo-stat-label",children:(0,n.__)("Original Size","cimo-image-optimizer")})]}),(0,c.jsxs)("div",{className:"cimo-stats-column cimo-stats-column-small",children:[(0,c.jsx)("div",{className:"cimo-stat-icon",children:(0,c.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-zap w-5 h-5 text-accent","data-lov-id":"src/pages/Index.tsx:94:22","data-lov-name":"Zap","data-component-path":"src/pages/Index.tsx","data-component-line":"94","data-component-file":"Index.tsx","data-component-name":"Zap","data-component-content":"%7B%22className%22%3A%22w-5%20h-5%20text-accent%22%7D",children:(0,c.jsx)("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})})}),(0,c.jsx)("span",{className:"cimo-stat-value",children:window.cimoAdmin.stats.after}),(0,c.jsx)("span",{className:"cimo-stat-label",children:(0,n.__)("Optimized Size","cimo-image-optimizer")})]})]})]}),(0,c.jsxs)("div",{className:"cimo-settings-section-wrapper",children:[(0,c.jsxs)("div",{className:"cimo-settings-section",children:[(0,c.jsxs)("div",{className:"cimo-settings-header",children:[(0,c.jsxs)("h2",{children:[(0,c.jsx)("span",{"aria-hidden":"true",children:(0,c.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-settings w-5 h-5 text-primary","data-lov-id":"src/components/SettingsSection.tsx:19:8","data-lov-name":"Settings","data-component-path":"src/components/SettingsSection.tsx","data-component-line":"19","data-component-file":"SettingsSection.tsx","data-component-name":"Settings","data-component-content":"%7B%22className%22%3A%22w-5%20h-5%20text-primary%22%7D",children:[(0,c.jsx)("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),(0,c.jsx)("circle",{cx:"12",cy:"12",r:"3"})]})}),(0,n.__)("Image Optimization Settings","cimo-image-optimizer")]}),(0,c.jsx)(a.Button,{variant:"secondary",onClick:()=>{s({webpQuality:80,maxImageDimension:1920,disableWpScaling:1,disableThumbnailGeneration:1,thumbnailSizes:[]})},children:(0,n.__)("Recommended","cimo-image-optimizer")})]}),(0,c.jsxs)("form",{onSubmit:async i=>{i.preventDefault(),d(!0),h("");try{await t()({path:"/wp/v2/settings",method:"POST",data:{cimo_options:{webp_quality:parseInt(e.webpQuality)||0,max_image_dimension:parseInt(e.maxImageDimension)||0,disable_wp_scaling:e.disableWpScaling,disable_thumbnail_generation:e.disableThumbnailGeneration,thumbnail_sizes:e.thumbnailSizes}}}),h((0,n.__)("Settings saved successfully!","cimo-image-optimizer"))}catch(e){h((0,n.__)("Error saving settings.","cimo-image-optimizer"))}finally{d(!1),setTimeout(()=>h(""),3e3)}},children:[(0,c.jsx)("div",{className:"cimo-setting-field",children:(0,c.jsx)(a.RangeControl,{id:"webpQuality",label:(0,n.__)("WebP Image Quality","cimo-image-optimizer"),value:e.webpQuality||"",onChange:e=>w("webpQuality",e||""),min:"1",max:"100",step:"1",__next40pxDefaultSize:!0,allowReset:!0,initialPosition:80,help:(0,n.__)("Set the quality / compression level for generated .webp images. Default is 80%. Higher values mean better quality and larger file size; lower values reduce file size with more compression but lower quality.","cimo-image-optimizer")})}),(0,c.jsx)("div",{className:"cimo-setting-field",children:(0,c.jsx)(a.TextControl,{label:(0,n.__)("Maximum Image Dimension","cimo-image-optimizer"),type:"number",value:e.maxImageDimension,onChange:e=>w("maxImageDimension",e),help:(0,n.__)("Maximum width or height in pixels for uploaded images. Images exceeding this dimension will be automatically resized while preserving aspect ratio. Leave empty to disable resizing. We recommend a value of 1920px.","cimo-image-optimizer"),__next40pxDefaultSize:!0})}),(0,c.jsx)("div",{className:"cimo-setting-field",children:(0,c.jsx)(a.ToggleControl,{__nextHasNoMarginBottom:!0,label:(0,n.__)("WordPress Automatic Image Scaling","cimo-image-optimizer"),checked:1===e.disableWpScaling,onChange:e=>w("disableWpScaling",e?1:0),help:(0,n.__)("WordPress automatically scales images larger than 2560px. Disable this option to allow uploads of any size.","cimo-image-optimizer")})}),(0,c.jsxs)("div",{className:"cimo-setting-field",children:[(0,c.jsx)(a.ToggleControl,{__nextHasNoMarginBottom:!0,label:(0,n.__)("WordPress Thumbnail Generation","cimo-image-optimizer"),checked:0===e.disableThumbnailGeneration,onChange:e=>w("disableThumbnailGeneration",e?0:1),help:(0,n.__)("By default, WordPress generates multiple image sizes (thumbnail, medium, large, etc.) when you upload images. Disable this option to save disk space.","cimo-image-optimizer")}),0===e.disableThumbnailGeneration&&(0,c.jsxs)("div",{className:"cimo-image-sizes-list",children:[(0,c.jsx)("h4",{className:"cimo-image-sizes-heading",children:(0,n.__)("Individual Image Sizes","cimo-image-optimizer")}),(0,c.jsx)("p",{className:"description",children:(0,n.__)("You can turn off generation for individual image sizes:","cimo-image-optimizer")}),l.map(i=>{const t=!e.thumbnailSizes.includes(i.name);return(0,c.jsx)(a.ToggleControl,{label:i.name,checked:t,onChange:e=>{return a=i.name,t=e,void s(e=>{let i=[...e.thumbnailSizes];return t?i=i.filter(e=>e!==a):i.includes(a)||i.push(a),{...e,thumbnailSizes:i}});var a,t}},i.name)}),0===l.length&&(0,c.jsx)("div",{className:"notice notice-warning cimo-image-sizes-warning",children:(0,c.jsx)("p",{children:(0,n.__)("No image sizes detected. If you just re-enabled thumbnail generation, please save settings and refresh this page.","cimo-image-optimizer")})})]})]}),(0,c.jsx)("div",{className:"cimo-setting-field cimo-submit-section",children:(0,c.jsxs)("div",{className:"cimo-submit-buttons",children:[(0,c.jsx)(a.Button,{variant:"primary",className:"cimo-save-button",disabled:r,__next40pxDefaultSize:!0,onClick:e=>{e.preventDefault(),r||document.querySelector("form").dispatchEvent(new Event("submit",{cancelable:!0,bubbles:!0}))},children:r?(0,n.__)("Saving…","cimo-image-optimizer"):(0,n.__)("Save Changes","cimo-image-optimizer")}),(0,c.jsx)(a.Button,{variant:"tertiary",className:"cimo-reset-button",onClick:()=>{s({webpQuality:"",maxImageDimension:"",disableWpScaling:1,disableThumbnailGeneration:0,thumbnailSizes:[]})},children:(0,n.__)("Reset to Default","cimo-image-optimizer")})]})}),p&&(0,c.jsx)("div",{className:`notice notice-${p.includes("success")?"success":"error"} is-dismissible`,children:(0,c.jsx)("p",{children:p})})]})]}),(0,c.jsxs)("div",{className:"cimo-settings-section cimo-settings-sidebar",children:[(0,c.jsxs)("div",{className:"cimo-sidebar-heading",children:[(0,c.jsx)("div",{className:"cimo-sidebar-heading-icon",children:(0,c.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-crown-icon lucide-crown",children:[(0,c.jsx)("path",{d:"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z"}),(0,c.jsx)("path",{d:"M5 21h14"})]})}),(0,c.jsx)("h2",{children:(0,n.__)("Upgrade to Premium","cimo-image-optimizer")})]}),(0,c.jsx)("p",{className:"cimo-premium-intro",children:(0,n.__)("Optimize more things and get premium support for a faster, happier site.","cimo-image-optimizer")}),(0,c.jsxs)("ul",{className:"cimo-premium-features-list",children:[(0,c.jsxs)("li",{children:[(0,c.jsx)("span",{className:"cimo-premium-icon",children:(0,c.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-video h-3 w-3 text-purple-600","data-lov-id":"src/components/WordPressAdmin.tsx:310:20","data-lov-name":"Video","data-component-path":"src/components/WordPressAdmin.tsx","data-component-line":"310","data-component-file":"WordPressAdmin.tsx","data-component-name":"Video","data-component-content":"%7B%22className%22%3A%22h-3%20w-3%20text-purple-600%22%7D",children:[(0,c.jsx)("path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5"}),(0,c.jsx)("rect",{x:"2",y:"6",width:"14",height:"12",rx:"2"})]})}),(0,c.jsx)("span",{children:(0,n.__)("Optimize videos on upload","cimo-image-optimizer")})]}),(0,c.jsxs)("li",{children:[(0,c.jsx)("span",{className:"cimo-premium-icon",children:(0,c.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-music h-3 w-3 text-purple-600","data-lov-id":"src/components/WordPressAdmin.tsx:316:20","data-lov-name":"Music","data-component-path":"src/components/WordPressAdmin.tsx","data-component-line":"316","data-component-file":"WordPressAdmin.tsx","data-component-name":"Music","data-component-content":"%7B%22className%22%3A%22h-3%20w-3%20text-purple-600%22%7D",children:[(0,c.jsx)("path",{d:"M9 18V5l12-2v13"}),(0,c.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,c.jsx)("circle",{cx:"18",cy:"16",r:"3"})]})}),(0,c.jsx)("span",{children:(0,n.__)("Optimize audio on upload","cimo-image-optimizer")})]}),(0,c.jsxs)("li",{children:[(0,c.jsx)("span",{className:"cimo-premium-icon",children:(0,c.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-zap h-3 w-3 text-purple-600","data-lov-id":"src/components/WordPressAdmin.tsx:328:20","data-lov-name":"Zap","data-component-path":"src/components/WordPressAdmin.tsx","data-component-line":"328","data-component-file":"WordPressAdmin.tsx","data-component-name":"Zap","data-component-content":"%7B%22className%22%3A%22h-3%20w-3%20text-purple-600%22%7D",children:(0,c.jsx)("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})})}),(0,c.jsx)("span",{children:(0,n.__)("Next-gen .avif image format","cimo-image-optimizer")})]}),(0,c.jsxs)("li",{children:[(0,c.jsx)("span",{className:"cimo-premium-icon",children:(0,c.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-icon customizable lucide-infinity-icon lucide-infinity lucide-icon customizable",children:(0,c.jsx)("path",{d:"M6 16c5 0 7-8 12-8a4 4 0 0 1 0 8c-5 0-7-8-12-8a4 4 0 1 0 0 8"})})}),(0,c.jsx)("span",{children:(0,n.__)("Still without limits","cimo-image-optimizer")})]}),(0,c.jsxs)("li",{children:[(0,c.jsx)("span",{className:"cimo-premium-icon",children:(0,c.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-tag-icon lucide-tag",children:[(0,c.jsx)("path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z"}),(0,c.jsx)("circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor"})]})}),(0,c.jsx)("span",{children:(0,n.__)("White label","cimo-image-optimizer")})]})]}),(0,c.jsxs)("div",{className:"cimo-premium-cta",children:[(0,c.jsx)(a.Button,{href:"https://wpcimo.com/pricing",variant:"primary",target:"_blank",rel:"noopener noreferrer",children:(0,n.__)("Upgrade Now","cimo-image-optimizer")}),(0,c.jsxs)("div",{className:"cimo-premium-guarantee",children:[(0,c.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"#16a249",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,c.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,c.jsx)("path",{d:"M8 13.5l2.5 2.5L16 9"})]}),(0,n.__)("30-day money back guarantee","cimo-image-optimizer")]})]})]})]})]})},m=document.getElementById("cimo-admin-settings");m&&(0,i.createRoot)(m).render((0,c.jsx)(l,{}))})();
     1(()=>{"use strict";var e={n:i=>{var a=i&&i.__esModule?()=>i.default:()=>i;return e.d(a,{a}),a},d:(i,a)=>{for(var t in a)e.o(a,t)&&!e.o(i,t)&&Object.defineProperty(i,t,{enumerable:!0,get:a[t]})}};e.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),e.o=(e,i)=>Object.prototype.hasOwnProperty.call(e,i),(()=>{var i;e.g.importScripts&&(i=e.g.location+"");var a=e.g.document;if(!i&&a&&(a.currentScript&&"SCRIPT"===a.currentScript.tagName.toUpperCase()&&(i=a.currentScript.src),!i)){var t=a.getElementsByTagName("script");if(t.length)for(var o=t.length-1;o>-1&&(!i||!/^http(s?):/.test(i));)i=t[o--].src}if(!i)throw new Error("Automatic publicPath is not supported in this browser");i=i.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),e.p=i+"../"})();const i=window.wp.element,a=window.wp.components,t=window.wp.hooks,o=window.wp.apiFetch;var s=e.n(o);const n=window.wp.i18n,l=e.p+"images/logo-long.cca876ef.webp",r=window.ReactJSXRuntime,m=(0,t.applyFilters)("cimo.admin.settings.buildType","free"),c=()=>{const[e,t]=(0,i.useState)({webpQuality:80,maxImageDimension:"",disableWpScaling:1,disableThumbnailGeneration:0,thumbnailSizes:[],lqipEnabled:0,lqipPulseSpeed:"",lqipBrightness:"",lqipFadeDuration:"",videoOptimizationEnabled:1,videoQuality:3,videoMaxResolution:"",audioOptimizationEnabled:1,audioQuality:128}),[o,c]=(0,i.useState)([]),[p,u]=(0,i.useState)(!1),[h,g]=(0,i.useState)(""),[x,_]=(0,i.useState)(!0),[v,w]=(0,i.useState)(!1),[j,b]=(0,i.useState)(()=>"undefined"!=typeof window&&"1"===window.cimoAdmin?.ratingDismissed);(0,i.useEffect)(()=>{(async()=>{window.cimoAdmin&&window.cimoAdmin.imageSizes&&c(window.cimoAdmin.imageSizes),await z(),_(!1)})()},[]);const z=async()=>{try{const e=(await s()({path:"/wp/v2/settings"})).cimo_options||{},i={webpQuality:void 0!==e.webp_quality?e.webp_quality:80,maxImageDimension:e.max_image_dimension||"",disableWpScaling:void 0!==e.disable_wp_scaling?e.disable_wp_scaling:1,disableThumbnailGeneration:void 0!==e.disable_thumbnail_generation?e.disable_thumbnail_generation:0,thumbnailSizes:e.thumbnail_sizes||[],lqipEnabled:void 0!==e.lqip_enabled?e.lqip_enabled:0,lqipPulseSpeed:void 0!==e.lqip_pulse_speed?e.lqip_pulse_speed:"",lqipBrightness:void 0!==e.lqip_brightness?e.lqip_brightness:"",lqipFadeDuration:void 0!==e.lqip_fade_duration?e.lqip_fade_duration:"",videoOptimizationEnabled:void 0!==e.video_optimization_enabled?e.video_optimization_enabled:1,videoQuality:void 0!==e.video_quality?e.video_quality:3,videoMaxResolution:e.video_max_resolution||"",audioOptimizationEnabled:void 0!==e.audio_optimization_enabled?e.audio_optimization_enabled:1,audioQuality:void 0!==e.audio_quality?e.audio_quality:128};t(i),w(!1)}catch(e){}},f=(0,i.useCallback)((e,i)=>{t(a=>({...a,[e]:i})),w(!0)},[]),y=(0,i.useCallback)(async()=>{b(!0);try{await s()({path:"/wp/v2/settings",method:"POST",data:{cimo_rating_dismissed:"1"}})}catch(e){b(!1)}},[]);return x?(0,r.jsx)("div",{className:"cimo-admin-settings-wrap",children:(0,r.jsx)("div",{className:"cimo-loading",children:(0,r.jsx)("p",{children:(0,n.__)("Loading settings…","cimo-image-optimizer")})})}):(0,r.jsxs)("div",{className:"cimo-admin-settings-wrap",children:[(0,r.jsxs)("div",{className:"cimo-header",children:[(0,r.jsx)("img",{className:"cimo-logo",src:l,alt:(0,n.__)("Cimo Logo","cimo-image-optimizer"),height:"35"}),(0,r.jsxs)("div",{className:"cimo-stats-section",children:[(0,r.jsxs)("div",{className:"cimo-stats-column cimo-stats-column-big",children:[(0,r.jsx)("h3",{children:(0,n.__)("Total Storage Saved","cimo-image-optimizer")}),(0,r.jsxs)("div",{className:"cimo-stats-main",children:[(0,r.jsx)("span",{className:"cimo-stat-value",children:window.cimoAdmin.stats.total_storage_saved}),(0,r.jsxs)("span",{className:"cimo-stat-percentage",children:["↓ ",window.cimoAdmin.stats.percentage_saved,"% ",(0,n.__)("reduction","cimo-image-optimizer")]})]}),(0,r.jsx)("div",{className:"cimo-stats-details",children:(0,n.__)("Across all optimized media files","cimo-image-optimizer")})]}),(0,r.jsxs)("div",{className:"cimo-stats-column cimo-stats-column-small",children:[(0,r.jsx)("div",{className:"cimo-stat-icon",children:(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-image w-5 h-5 text-primary","data-lov-id":"src/pages/Index.tsx:66:22","data-lov-name":"Image","data-component-path":"src/pages/Index.tsx","data-component-line":"66","data-component-file":"Index.tsx","data-component-name":"Image","data-component-content":"%7B%22className%22%3A%22w-5%20h-5%20text-primary%22%7D",children:[(0,r.jsx)("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),(0,r.jsx)("circle",{cx:"9",cy:"9",r:"2"}),(0,r.jsx)("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})]})}),(0,r.jsx)("span",{className:"cimo-stat-value",children:window.cimoAdmin.stats.media_optimized}),(0,r.jsx)("span",{className:"cimo-stat-label",children:(0,n.__)("Media Files Optimized","cimo-image-optimizer")})]}),(0,r.jsxs)("div",{className:"cimo-stats-column cimo-stats-column-small",children:[(0,r.jsx)("div",{className:"cimo-stat-icon",children:(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-hard-drive w-5 h-5 text-destructive","data-lov-id":"src/pages/Index.tsx:80:22","data-lov-name":"HardDrive","data-component-path":"src/pages/Index.tsx","data-component-line":"80","data-component-file":"Index.tsx","data-component-name":"HardDrive","data-component-content":"%7B%22className%22%3A%22w-5%20h-5%20text-destructive%22%7D",children:[(0,r.jsx)("line",{x1:"22",x2:"2",y1:"12",y2:"12"}),(0,r.jsx)("path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z"}),(0,r.jsx)("line",{x1:"6",x2:"6.01",y1:"16",y2:"16"}),(0,r.jsx)("line",{x1:"10",x2:"10.01",y1:"16",y2:"16"})]})}),(0,r.jsx)("span",{className:"cimo-stat-value",children:window.cimoAdmin.stats.before}),(0,r.jsx)("span",{className:"cimo-stat-label",children:(0,n.__)("Original Size","cimo-image-optimizer")})]}),(0,r.jsxs)("div",{className:"cimo-stats-column cimo-stats-column-small",children:[(0,r.jsx)("div",{className:"cimo-stat-icon",children:(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-zap w-5 h-5 text-accent","data-lov-id":"src/pages/Index.tsx:94:22","data-lov-name":"Zap","data-component-path":"src/pages/Index.tsx","data-component-line":"94","data-component-file":"Index.tsx","data-component-name":"Zap","data-component-content":"%7B%22className%22%3A%22w-5%20h-5%20text-accent%22%7D",children:(0,r.jsx)("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})})}),(0,r.jsx)("span",{className:"cimo-stat-value",children:window.cimoAdmin.stats.after}),(0,r.jsx)("span",{className:"cimo-stat-label",children:(0,n.__)("Optimized Size","cimo-image-optimizer")})]})]})]}),(()=>{const e=window.cimoAdmin?.stats?.total_storage_saved;let i=!1;if("string"==typeof e){const a=e.match(/^([\d.]+)\s*([a-zA-Z]+)/);if(a){const e=parseFloat(a[1]);"MB"===a[2].toUpperCase()&&e>100&&(i=!0)}}return i&&!j?(0,r.jsx)("div",{className:"cimo-header cimo-rating-notice",children:(0,r.jsxs)("div",{className:"cimo-rating-notice-content",children:[(0,r.jsx)("h3",{className:"cimo-rating-title",children:(0,n.__)("Loving the instant storage & server resource savings?","cimo-image-optimizer")}),(0,r.jsx)("p",{className:"cimo-rating-description",children:(0,n.sprintf)(
     2// translators: %s is replaced with the total storage saved (e.g. "1.5 GB")
     3// translators: %s is replaced with the total storage saved (e.g. "1.5 GB")
     4(0,n.__)("You've saved over %s! If Cimo is helping your site, please consider leaving us a 5-star rating and help others discover Cimo!","cimo-image-optimizer"),window.cimoAdmin.stats.total_storage_saved)}),(0,r.jsxs)("div",{className:"cimo-rating-buttons",children:[(0,r.jsxs)(a.Button,{variant:"primary",href:"https://wordpress.org/support/plugin/cimo-image-optimizer/reviews/#new-post",target:"_blank",rel:"noopener noreferrer",className:"cimo-rating-rate-now",__next40pxDefaultSize:!0,children:[(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-star-icon lucide-star",children:(0,r.jsx)("path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z"})}),(0,n.__)("Rate Now","cimo-image-optimizer")]}),(0,r.jsx)(a.Button,{variant:"secondary",className:"cimo-rating-no-thanks",onClick:y,__next40pxDefaultSize:!0,children:(0,n.__)("Don't show this again, I've already rated","cimo-image-optimizer")})]})]})}):null})(),(0,r.jsxs)("form",{onSubmit:async i=>{i.preventDefault(),u(!0),g(""),w(!1);try{await s()({path:"/wp/v2/settings",method:"POST",data:{cimo_options:{webp_quality:parseInt(e.webpQuality)||0,max_image_dimension:parseInt(e.maxImageDimension)||0,disable_wp_scaling:e.disableWpScaling,disable_thumbnail_generation:e.disableThumbnailGeneration,thumbnail_sizes:e.thumbnailSizes,lqip_enabled:e.lqipEnabled,lqip_pulse_speed:parseFloat(e.lqipPulseSpeed)||0,lqip_brightness:parseFloat(e.lqipBrightness)||0,lqip_fade_duration:parseFloat(e.lqipFadeDuration)||0,video_optimization_enabled:e.videoOptimizationEnabled,video_quality:e.videoQuality||0,video_max_resolution:e.videoMaxResolution||"",audio_optimization_enabled:e.audioOptimizationEnabled,audio_quality:e.audioQuality||0}}}),g((0,n.__)("Settings saved successfully!","cimo-image-optimizer"))}catch(e){g((0,n.__)("Error saving settings.","cimo-image-optimizer"))}finally{u(!1),setTimeout(()=>g(""),3e3)}},className:"cimo-settings-form",children:[(0,r.jsxs)("div",{className:"cimo-settings-section-wrapper",children:[(0,r.jsxs)("div",{className:"cimo-settings-section cimo-settings-section-info",children:[(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-info-icon lucide-info",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,r.jsx)("path",{d:"M12 16v-4"}),(0,r.jsx)("path",{d:"M12 8h.01"})]}),"free"===m&&(0,r.jsx)("span",{children:(0,n.__)("Your images are instantly optimized within your browser as you upload — only the optimized versions ever touch your site!","cimo-image-optimizer")}),"premium"===m&&(0,r.jsx)("span",{children:(0,n.__)("Your images, videos and audio files are instantly optimized within your browser as you upload — only the optimized versions ever touch your site!","cimo-image-optimizer")})]}),(0,r.jsxs)("div",{className:"cimo-settings-section",children:[(0,r.jsxs)("div",{className:"cimo-settings-header",children:[(0,r.jsxs)("h2",{children:[(0,r.jsx)("span",{"aria-hidden":"true",children:(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-image-icon lucide-image",children:[(0,r.jsx)("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),(0,r.jsx)("circle",{cx:"9",cy:"9",r:"2"}),(0,r.jsx)("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})]})}),(0,n.__)("Image Optimization Settings","cimo-image-optimizer")]}),(0,r.jsx)(a.Button,{variant:"secondary",onClick:()=>{t(e=>({...e,webpQuality:80,maxImageDimension:1920,disableWpScaling:1,disableThumbnailGeneration:1,thumbnailSizes:[]}))},children:(0,n.__)("Recommended","cimo-image-optimizer")})]}),(0,r.jsx)("div",{className:"cimo-setting-field",children:(0,r.jsx)(a.RangeControl,{id:"webpQuality",label:(0,n.__)("WebP Image Quality","cimo-image-optimizer"),value:e.webpQuality||"",onChange:e=>f("webpQuality",e||""),min:"1",max:"100",step:"1",__next40pxDefaultSize:!0,allowReset:!0,initialPosition:80,help:(0,n.__)("Set the quality / compression level for generated .webp images. Default is 80%. Higher values mean better quality and larger file size; lower values reduce file size with more compression but lower quality.","cimo-image-optimizer")})}),(0,r.jsx)("div",{className:"cimo-setting-field",children:(0,r.jsx)(a.TextControl,{label:(0,n.__)("Maximum Image Dimension","cimo-image-optimizer"),type:"number",value:e.maxImageDimension,onChange:e=>f("maxImageDimension",e),help:(0,n.__)("Maximum width or height in pixels for uploaded images. Images exceeding this dimension will be automatically resized while preserving aspect ratio. Leave empty to disable resizing. We recommend a value of 1920px.","cimo-image-optimizer"),__next40pxDefaultSize:!0})}),(0,r.jsx)("div",{className:"cimo-setting-field",children:(0,r.jsx)(a.ToggleControl,{__nextHasNoMarginBottom:!0,label:(0,n.__)("WordPress Automatic Image Scaling","cimo-image-optimizer"),checked:1===e.disableWpScaling,onChange:e=>f("disableWpScaling",e?1:0),help:(0,n.__)("WordPress automatically scales images larger than 2560px. Disable this option to allow uploads of any size.","cimo-image-optimizer")})}),(0,r.jsxs)("div",{className:"cimo-setting-field",children:[(0,r.jsx)(a.ToggleControl,{__nextHasNoMarginBottom:!0,label:(0,n.__)("WordPress Thumbnail Generation","cimo-image-optimizer"),checked:0===e.disableThumbnailGeneration,onChange:e=>f("disableThumbnailGeneration",e?0:1),help:(0,n.__)("By default, WordPress generates multiple image sizes (thumbnail, medium, large, etc.) when you upload images. Disable this option to save disk space.","cimo-image-optimizer")}),0===e.disableThumbnailGeneration&&(0,r.jsxs)("div",{className:"cimo-image-sizes-list",children:[(0,r.jsx)("h4",{className:"cimo-image-sizes-heading",children:(0,n.__)("Individual Image Sizes","cimo-image-optimizer")}),(0,r.jsx)("p",{className:"description",children:(0,n.__)("You can turn off generation for individual image sizes:","cimo-image-optimizer")}),o.map(i=>{const o=!e.thumbnailSizes.includes(i.name);return(0,r.jsx)(a.ToggleControl,{label:i.name,checked:o,onChange:e=>{return a=i.name,o=e,void t(e=>{let i=[...e.thumbnailSizes];return o?i=i.filter(e=>e!==a):i.includes(a)||i.push(a),{...e,thumbnailSizes:i}});var a,o}},i.name)}),0===o.length&&(0,r.jsx)("div",{className:"notice notice-warning cimo-image-sizes-warning",children:(0,r.jsx)("p",{children:(0,n.__)("No image sizes detected. If you just re-enabled thumbnail generation, please save settings and refresh this page.","cimo-image-optimizer")})})]})]}),(0,r.jsx)(a.Button,{variant:"tertiary",className:"cimo-reset-button",onClick:()=>{t(e=>({...e,webpQuality:"",maxImageDimension:"",disableWpScaling:1,disableThumbnailGeneration:0,thumbnailSizes:[]}))},children:(0,n.__)("Reset to Default","cimo-image-optimizer")})]}),(0,r.jsxs)("div",{className:"cimo-settings-section",style:{gridColumn:"1 / 2"},children:[(0,r.jsxs)("div",{className:"cimo-settings-header",children:[(0,r.jsxs)("h2",{children:[(0,r.jsx)("span",{"aria-hidden":"true",children:(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-image-icon lucide-image",children:[(0,r.jsx)("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),(0,r.jsx)("circle",{cx:"9",cy:"9",r:"2"}),(0,r.jsx)("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})]})}),(0,n.__)("Low Quality Image Placeholder Settings","cimo-image-optimizer")]}),"free"===m&&(0,r.jsxs)("span",{className:"cimo-premium-feature-label",children:[(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-lock-icon lucide-lock",children:[(0,r.jsx)("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),(0,r.jsx)("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),(0,n.__)("Premium","cimo-image-optimizer")]})]}),"free"===m&&(0,r.jsx)(d,{label:(0,n.__)("Show a low-quality preview while the image loads, then fade in the final image.","cimo-image-optimizer")}),"premium"===m&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"cimo-setting-field",children:(0,r.jsx)(a.ToggleControl,{__nextHasNoMarginBottom:!0,label:(0,n.__)("Enable LQIP","cimo-image-optimizer"),checked:1===e.lqipEnabled,onChange:e=>f("lqipEnabled",e?1:0),help:(0,n.__)("Turn this option on to enable LQIP for all images. LQIP is only supported by Native Image Blocks.","cimo-image-optimizer")})}),1===e.lqipEnabled&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"cimo-setting-field",children:(0,r.jsx)(a.RangeControl,{id:"lqipPulseSpeed",label:(0,n.__)("Placeholder Pulse Speed (seconds)","cimo-image-optimizer"),value:e.lqipPulseSpeed||"",onChange:e=>f("lqipPulseSpeed",e||""),min:"0.1",max:"5",step:"0.1",__next40pxDefaultSize:!0,allowReset:!0,initialPosition:2.5,help:(0,n.__)("Set the speed of the pulse animation when the image is loading. Default is 2.5s.","cimo-image-optimizer")})}),(0,r.jsx)("div",{className:"cimo-setting-field",children:(0,r.jsx)(a.RangeControl,{id:"lqipBrightness",label:(0,n.__)("Placeholder Pulse Brightness","cimo-image-optimizer"),value:e.lqipBrightness||"",onChange:e=>f("lqipBrightness",e||""),min:"0.5",max:"1.5",step:"0.05",__next40pxDefaultSize:!0,allowReset:!0,initialPosition:1.3,help:(0,n.__)("Set the brightness of the pulse animation when the image is loading. Default is 1.3x brightness.","cimo-image-optimizer")})}),(0,r.jsx)("div",{className:"cimo-setting-field",children:(0,r.jsx)(a.RangeControl,{id:"lqipFadeDuration",label:(0,n.__)("Image Fade In Duration (seconds)","cimo-image-optimizer"),value:e.lqipFadeDuration||"",onChange:e=>f("lqipFadeDuration",e||""),min:"0.1",max:"3",step:"0.1",__next40pxDefaultSize:!0,allowReset:!0,initialPosition:.5,help:(0,n.__)("Set the duration of the fade in animation when the image is loaded. Default is 0.5s.","cimo-image-optimizer")})}),(0,r.jsx)(a.Button,{variant:"tertiary",className:"cimo-reset-button",onClick:()=>{t(e=>({...e,lqipPulseSpeed:"",lqipBrightness:"",lqipFadeDuration:""}))},children:(0,n.__)("Reset to Default","cimo-image-optimizer")})]})]})]}),(0,r.jsxs)("div",{className:"cimo-settings-section",style:{gridColumn:"1 / 2"},children:[(0,r.jsxs)("div",{className:"cimo-settings-header",children:[(0,r.jsxs)("h2",{children:[(0,r.jsx)("span",{"aria-hidden":"true",children:(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-video-icon lucide-video",children:[(0,r.jsx)("path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5"}),(0,r.jsx)("rect",{x:"2",y:"6",width:"14",height:"12",rx:"2"})]})}),(0,n.__)("Video Optimization Settings","cimo-image-optimizer")]}),"free"===m&&(0,r.jsxs)("span",{className:"cimo-premium-feature-label",children:[(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-lock-icon lucide-lock",children:[(0,r.jsx)("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),(0,r.jsx)("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),(0,n.__)("Premium","cimo-image-optimizer")]}),"premium"===m&&(0,r.jsx)(a.Button,{variant:"secondary",onClick:()=>{t(e=>({...e,videoOptimizationEnabled:1,videoQuality:3,videoMaxResolution:"1440"}))},children:(0,n.__)("Recommended","cimo-image-optimizer")})]}),"free"===m&&(0,r.jsx)(d,{label:(0,n.__)("Upgrade to Premium to compress and optimize video files on upload","cimo-image-optimizer")}),"premium"===m&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"cimo-setting-field",children:(0,r.jsx)(a.ToggleControl,{__nextHasNoMarginBottom:!0,label:(0,n.__)("Enable Video Optimization","cimo-image-optimizer"),checked:1===e.videoOptimizationEnabled,onChange:e=>f("videoOptimizationEnabled",e?1:0),help:(0,n.__)("Turn this option off to upload videos without optimizing them.","cimo-image-optimizer")})}),1===e.videoOptimizationEnabled&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"cimo-setting-field",children:(0,r.jsxs)(a.__experimentalToggleGroupControl,{__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,label:(0,n.__)("Video Quality","cimo-image-optimizer"),value:e.videoQuality||3,onChange:e=>f("videoQuality",e),isBlock:!0,help:(0,n.__)("Set the quality / compression level for optimized .MP4 video uploads. Default is Medium (Balanced). Lower quality means a smaller file size and lower quality, higher quality means a higher quality but larger file size.","cimo-image-optimizer"),children:[(0,r.jsx)(a.__experimentalToggleGroupControlOption,{value:1,label:(0,n.__)("Very Low Quality","cimo-image-optimizer")}),(0,r.jsx)(a.__experimentalToggleGroupControlOption,{value:2,label:(0,n.__)("Low Quality","cimo-image-optimizer")}),(0,r.jsx)(a.__experimentalToggleGroupControlOption,{value:3,label:(0,n.__)("Medium","cimo-image-optimizer")}),(0,r.jsx)(a.__experimentalToggleGroupControlOption,{value:4,label:(0,n.__)("High Quality","cimo-image-optimizer")}),(0,r.jsx)(a.__experimentalToggleGroupControlOption,{value:5,label:(0,n.__)("Very High Quality","cimo-image-optimizer")})]})}),(0,r.jsx)("div",{className:"cimo-setting-field",children:(0,r.jsxs)(a.__experimentalToggleGroupControl,{__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,label:(0,n.__)("Video Maximum Resolution","cimo-image-optimizer"),value:e.videoMaxResolution||"",onChange:e=>f("videoMaxResolution",e),isBlock:!0,help:(0,n.__)("Set the maximum resolution for optimized video uploads. If the video uploaded is bigger than this, the video will not be resized down to this maximum resolution. Default is the video will not be resized.","cimo-image-optimizer"),children:[(0,r.jsx)(a.__experimentalToggleGroupControlOption,{value:"",label:(0,n.__)("Keep original","cimo-image-optimizer")}),(0,r.jsx)(a.__experimentalToggleGroupControlOption,{value:"480",label:"480p"}),(0,r.jsx)(a.__experimentalToggleGroupControlOption,{value:"720",label:"720p"}),(0,r.jsx)(a.__experimentalToggleGroupControlOption,{value:"1080",label:"1080p"}),(0,r.jsx)(a.__experimentalToggleGroupControlOption,{value:"1440",label:"1440p (2K)"}),(0,r.jsx)(a.__experimentalToggleGroupControlOption,{value:"2160",label:"2160p (4K)"})]})})]}),(0,r.jsx)(a.Button,{variant:"tertiary",className:"cimo-reset-button",onClick:()=>{t(e=>({...e,videoOptimizationEnabled:1,videoQuality:"",videoMaxResolution:""}))},children:(0,n.__)("Reset to Default","cimo-image-optimizer")})]})]}),(0,r.jsxs)("div",{className:"cimo-settings-section",style:{gridColumn:"1 / 2"},children:[(0,r.jsxs)("div",{className:"cimo-settings-header",children:[(0,r.jsxs)("h2",{children:[(0,r.jsx)("span",{"aria-hidden":"true",children:(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-music-icon lucide-music",children:[(0,r.jsx)("path",{d:"M9 18V5l12-2v13"}),(0,r.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,r.jsx)("circle",{cx:"18",cy:"16",r:"3"})]})}),(0,n.__)("Audio Optimization Settings","cimo-image-optimizer")]}),"free"===m&&(0,r.jsxs)("span",{className:"cimo-premium-feature-label",children:[(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-lock-icon lucide-lock",children:[(0,r.jsx)("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),(0,r.jsx)("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),(0,n.__)("Premium","cimo-image-optimizer")]})]}),"free"===m&&(0,r.jsx)(d,{label:(0,n.__)("Upgrade to Premium to compress and optimize audio files on upload","cimo-image-optimizer")}),"premium"===m&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"cimo-setting-field",children:(0,r.jsx)(a.ToggleControl,{__nextHasNoMarginBottom:!0,label:(0,n.__)("Enable Audio Optimization","cimo-image-optimizer"),checked:1===e.audioOptimizationEnabled,onChange:e=>f("audioOptimizationEnabled",e?1:0),help:(0,n.__)("Turn this option off to upload audio files without optimizing them.","cimo-image-optimizer")})}),1===e.audioOptimizationEnabled&&(0,r.jsx)(r.Fragment,{children:(0,r.jsx)("div",{className:"cimo-setting-field",children:(0,r.jsx)(a.RangeControl,{label:(0,n.__)("Audio Quality (kbps)","cimo-image-optimizer"),__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,value:e.audioQuality||128,onChange:e=>f("audioQuality",e),min:"32",max:"320",step:"32",help:(0,n.__)("Set the quality / compression level for optimized .MP3 audio uploads. Default is 128kbps. Lower quality means a smaller file size and lower quality, higher quality means a higher quality but larger file size.","cimo-image-optimizer")})})}),(0,r.jsx)(a.Button,{variant:"tertiary",className:"cimo-reset-button",onClick:()=>{t(e=>({...e,audioOptimizationEnabled:1,audioQuality:""}))},children:(0,n.__)("Reset to Default","cimo-image-optimizer")})]})]})]}),(0,r.jsx)("div",{className:"cimo-setting-field cimo-submit-section",children:(0,r.jsxs)("div",{className:"cimo-submit-buttons",children:[(0,r.jsx)(a.Button,{variant:"primary",className:"cimo-save-button",disabled:p,__next40pxDefaultSize:!0,onClick:e=>{e.preventDefault(),p||document.querySelector("form").dispatchEvent(new Event("submit",{cancelable:!0,bubbles:!0}))},children:p?(0,n.__)("Saving…","cimo-image-optimizer"):(0,n.__)("Save Changes","cimo-image-optimizer")}),v&&(0,r.jsx)("span",{className:"cimo-unsaved-note",children:(0,n.__)("You have unsaved changes","cimo-image-optimizer")}),h&&(0,r.jsx)("p",{children:h})]})})]}),"free"===m&&(0,r.jsxs)("div",{className:"cimo-settings-section cimo-settings-sidebar",children:[(0,r.jsxs)("div",{className:"cimo-sidebar-heading",children:[(0,r.jsx)("div",{className:"cimo-sidebar-heading-icon",children:(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-crown-icon lucide-crown",children:[(0,r.jsx)("path",{d:"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z"}),(0,r.jsx)("path",{d:"M5 21h14"})]})}),(0,r.jsx)("h2",{children:(0,n.__)("Upgrade to Premium","cimo-image-optimizer")})]}),(0,r.jsx)("p",{className:"cimo-premium-intro",children:(0,n.__)("Optimize more things and get premium support for a faster, happier site.","cimo-image-optimizer")}),(0,r.jsxs)("ul",{className:"cimo-premium-features-list",children:[(0,r.jsxs)("li",{children:[(0,r.jsx)("span",{className:"cimo-premium-icon",children:(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-video h-3 w-3 text-purple-600","data-lov-id":"src/components/WordPressAdmin.tsx:310:20","data-lov-name":"Video","data-component-path":"src/components/WordPressAdmin.tsx","data-component-line":"310","data-component-file":"WordPressAdmin.tsx","data-component-name":"Video","data-component-content":"%7B%22className%22%3A%22h-3%20w-3%20text-purple-600%22%7D",children:[(0,r.jsx)("path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5"}),(0,r.jsx)("rect",{x:"2",y:"6",width:"14",height:"12",rx:"2"})]})}),(0,r.jsx)("span",{children:(0,n.__)("Optimize videos on upload","cimo-image-optimizer")})]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("span",{className:"cimo-premium-icon",children:(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-music h-3 w-3 text-purple-600","data-lov-id":"src/components/WordPressAdmin.tsx:316:20","data-lov-name":"Music","data-component-path":"src/components/WordPressAdmin.tsx","data-component-line":"316","data-component-file":"WordPressAdmin.tsx","data-component-name":"Music","data-component-content":"%7B%22className%22%3A%22h-3%20w-3%20text-purple-600%22%7D",children:[(0,r.jsx)("path",{d:"M9 18V5l12-2v13"}),(0,r.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,r.jsx)("circle",{cx:"18",cy:"16",r:"3"})]})}),(0,r.jsx)("span",{children:(0,n.__)("Optimize audio on upload","cimo-image-optimizer")})]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("span",{className:"cimo-premium-icon",children:(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-image-icon lucide-image",children:[(0,r.jsx)("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),(0,r.jsx)("circle",{cx:"9",cy:"9",r:"2"}),(0,r.jsx)("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})]})}),(0,r.jsx)("span",{children:(0,n.__)("Low Quality Image Placeholder","cimo-image-optimizer")})]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("span",{className:"cimo-premium-icon",children:(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-icon customizable lucide-infinity-icon lucide-infinity lucide-icon customizable",children:(0,r.jsx)("path",{d:"M6 16c5 0 7-8 12-8a4 4 0 0 1 0 8c-5 0-7-8-12-8a4 4 0 1 0 0 8"})})}),(0,r.jsx)("span",{children:(0,n.__)("Still without limits","cimo-image-optimizer")})]})]}),(0,r.jsxs)("div",{className:"cimo-premium-cta",children:[(0,r.jsx)(a.Button,{href:"https://wpcimo.com/pricing",variant:"primary",target:"_blank",rel:"noopener noreferrer",children:(0,n.__)("Upgrade Now","cimo-image-optimizer")}),(0,r.jsxs)("div",{className:"cimo-premium-guarantee",children:[(0,r.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"#16a249",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,r.jsx)("path",{d:"M8 13.5l2.5 2.5L16 9"})]}),(0,n.__)("30-day money back guarantee","cimo-image-optimizer")]})]})]})]})},d=e=>(0,r.jsxs)("div",{className:"cimo-settings-premium-placeholder",children:[e.label,(0,r.jsx)(a.Button,{variant:"secondary",className:"cimo-premium-cta",href:"https://wpcimo.com/pricing",target:"_blank",rel:"noopener noreferrer",children:(0,n.__)("Upgrade to Premium","cimo-image-optimizer")})]}),p=document.getElementById("cimo-admin-settings");p&&(0,i.createRoot)(p).render((0,r.jsx)(c,{}))})();
  • cimo-image-optimizer/trunk/build/admin/index.asset.php

    r3377996 r3402030  
    1 <?php return array('dependencies' => array(), 'version' => '6fdc286d70e31c4cffb6');
     1<?php return array('dependencies' => array('wp-hooks', 'wp-i18n'), 'version' => '545dbff2243225a6ce40');
  • cimo-image-optimizer/trunk/build/admin/index.js

    r3377996 r3402030  
    1 (()=>{"use strict";function e(e){"undefined"!=typeof document&&("complete"!==document.readyState&&"interactive"!==document.readyState?document.addEventListener("DOMContentLoaded",e):e())}const t=[{value:"webp",mimeType:"image/webp"},{value:"jpg",mimeType:"image/jpeg"},{value:"png",mimeType:"image/png"}],a={webp:{quality:.8,width:"auto",height:"auto"},jpg:{quality:.8,width:"auto",height:"auto"},png:{quality:.8,width:"auto",height:"auto"}};function i(e){if(!e||"string"!=typeof e)return!1;const t={webp:"image/webp",avif:"image/avif"}[e.toLowerCase()]||(e.startsWith("image/")?e:null);if(!t)return!1;const a=document.createElement("canvas");a.width=1,a.height=1;try{return a.toDataURL(t).startsWith(`data:${t}`)}catch(e){return!1}}async function n(e,i){const n=null!==(i=i||{}).format?i.format:"webp";if(!e||"object"!=typeof e||"string"!=typeof e.name||"number"!=typeof e.size||"string"!=typeof e.type||"function"!=typeof e.slice)return{file:e,metadata:null};if(!e.type||!e.type.startsWith("image/"))return{file:e,metadata:null};const o=t.find(e=>e.value===n);if(o&&e.type===o.mimeType)return{file:e,metadata:null};const r=document.createElement("canvas");if(o&&!r.toDataURL(o.mimeType).startsWith(`data:${o.mimeType}`))return console.error("[Cimo] "+n+" is not supported by the browser, please use another modern browser"),{file:e,metadata:null};if("image/gif"===e.type){const t=await e.slice(0,51200).arrayBuffer(),a=new Uint8Array(t);let i=0;for(let t=0;t<a.length-2;t++)if(33===a[t]&&249===a[t+1]&&4===a[t+2]&&(i++,i>1))return{file:e,metadata:null}}const s={file:e};try{const r=performance.now(),c=await(async(e,i="webp",n={})=>{let o=(n=n||{}).quality?n.quality:.8,r=n.maxDimension?n.maxDimension:0;return"string"==typeof o&&(o=parseFloat(o)/100,o||(o=.8)),"string"==typeof r&&(r=parseFloat(r)),new Promise((n,s)=>{const c=new Image;let m=null;c.onload=async function(){const e=document.createElement("canvas"),l=a[i],{width:d,height:p}=function(e,t,a){const i=(a=a||{}).scale?a.scale:1,n=a.width?a.width:"auto",o=a.height?a.height:"auto",r=a.aspectRatio?a.aspectRatio:"auto",s=a.maxDimension?a.maxDimension:0;let c=e*i,m=t*i;if(s&&"number"==typeof s&&s>0){const e=Math.max(c,m);if(e>s){const t=s/e;c*=t,m*=t}}if("auto"!==n&&"number"==typeof n&&(c=n,"auto"===o&&(m=t/e*c)),"auto"!==o&&"number"==typeof o&&(m=o,"auto"===n&&(c=e/t*m)),"auto"!==r){if("custom"===r)return{width:c,height:m};const[e,t]=r.split(":").map(Number),a=e/t,i=c/m;if(Math.abs(i-a)>.01)if(i>a)c=m*a;else{const e=c;c=e,m=e/a}}return{width:Math.round(c),height:Math.round(m)}}(c.width,c.height,{...l,maxDimension:r});e.width=d,e.height=p;const u=e.getContext("2d"),f=c.width/c.height,g=d/p;let h=c.height,w=c.width,y=0,v=0;Math.abs(f-g)>.01&&(f>g?(w=c.height*g,y=(c.width-w)/2):(h=c.width/g,v=(c.height-h)/2)),u.drawImage(c,y,v,w,h,0,0,d,p);const b=t.find(e=>e.value===i),_="webp"===i||"jpg"===i?o:void 0;e.toBlob(function(t){URL.revokeObjectURL(m),m=null,u.clearRect(0,0,e.width,e.height),e.width=0,e.height=0,t?n(t):s(new Error("Failed to convert image"))},b.mimeType,_)},c.onerror=()=>{m&&(URL.revokeObjectURL(m),m=null),s(new Error("Failed to load image"))},m=URL.createObjectURL(e.file),c.src=m})})(s,n,{quality:i.quality,maxDimension:i.maxDimension}),m=performance.now(),l="jpeg"===n?"jpg":n,d=e.name.replace(/\.[^/.]+$/,"")+"."+l,p={filename:d,originalFormat:e.type,originalFilesize:e.size,convertedFormat:o.mimeType,convertedFilesize:c.size,conversionTime:m-r,compressionSavings:e.size>0?c.size/e.size:null};return{file:new(0,e.constructor)([c],d,{type:o.mimeType,lastModified:Date.now()}),metadata:p}}catch(e){throw new Error(`Failed to convert image: ${e.message}`)}}function o(e){return("string"!=typeof e?String(e):e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/`/g,"&#96;")}function r(e,t="editor-canvas"){const a=()=>{const a=document.querySelector(`iframe[name="${t}"]`);if(a&&a.contentDocument){const t=()=>{a.contentDocument.body?e(a.contentDocument):setTimeout(t,50)};"loading"===a.contentDocument.readyState?a.addEventListener("load",()=>{t()}):t()}};a();let i=0;const n=setInterval(()=>{i>=10?clearInterval(n):(i++,a())},1e3),o=new MutationObserver(e=>{e.forEach(e=>{e.addedNodes.forEach(e=>{e.nodeType===Node.ELEMENT_NODE&&("IFRAME"===e.tagName&&e.name===t||e.querySelector&&e.querySelector(`iframe[name="${t}"]`))&&a()})})});return o.observe(document.body,{childList:!0,subtree:!0}),o}const s=e=>Array.isArray(e)&&0!==e.length?e.every(e=>m(e.filename))?Promise.resolve():(e.forEach(e=>{e.filename&&c(e.filename,e)}),new Promise((t,a)=>{fetch(`${window.cimoSettings?.restUrl||"/wp-json/cimo/v1/"}metadata`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","X-WP-Nonce":window.cimoSettings?.nonce||window.wpApiSettings?.nonce},body:JSON.stringify({metadata:e}),credentials:"same-origin"}).then(e=>e.ok?e.json():e.json().then(t=>{throw new Error(t.message||e.statusText)})).then(e=>{t(e)}).catch(t=>{console.error(`Failed to save metadata for filenames: [${e.map(e=>e.filename).join(", ")}]:`,t),a(new Error(`Failed to save metadata: ${t.message}`))})})):Promise.resolve(),c=(e,t)=>{window.cimoMetadataCache||(window.cimoMetadataCache={}),window.cimoMetadataCache[e.replaceAll(/\s+/g,"-")]={...t}},m=e=>window.cimoMetadataCache?.[e?.replaceAll(/\s+/g,"-")]||null;async function l(e){try{return await n(e,{format:"webp",quality:window.cimoSettings?.webpQuality||.8,maxDimension:window.cimoSettings?.maxImageDimension||0})}catch(t){return console.error(t),{file:e,metadata:null}}}const d=["image/jpg","image/jpeg","image/png","image/gif"];function p(e){if(!e)return;if(!e.body)return;e.body.__cimo_dropzone_listener_attached||(e.body.addEventListener("drop",async t=>{if(t.__cimo_converted)return;if(!Array.from(t.dataTransfer.files).some(e=>d.includes(e.type)))return;if(!(t.target.closest(".media-frame-uploader")||t.target.closest(".media-upload-form")||t.target.closest(".editor-post-featured-image")||t.target.closest(".editor-styles-wrapper")||t.target.closest(".uploader-window")))return;if(!i("webp"))return;let a;for(t.preventDefault(),t.stopPropagation();a=document.querySelector('.uploader-window[style*="display: block"]');)a.style.display="none";const n=Array.from(t.dataTransfer.files);if(!n.length)return;const o=await Promise.all(n.map(l)),r=o.map(e=>e.file),c=o.map(e=>e.metadata),m=new DataTransfer;if(r.forEach(e=>{m.items.add(e)}),await s(c),t.target?.classList.contains("components-drop-zone")){const a=e!==document,i=new Event("drop",{bubbles:!a});Object.defineProperty(i,"dataTransfer",{value:m,writable:!1}),i.__cimo_converted=!0,t.target.dispatchEvent(i)}else{const a=document.querySelector('.media-modal input[type="file"]')||document.querySelector('.media-upload-form input[type="file"]')||document.querySelector('input[type="file"]');if(a){a.files=m.files;const t=e!==document,i=new Event("change",{bubbles:!t});i.__cimo_converted=!0,a.dispatchEvent(i)}else{const e=new Event("drop",{bubbles:!0});Object.defineProperty(e,"dataTransfer",{value:m,writable:!1}),e.__cimo_converted=!0,t.target.dispatchEvent(e)}}},!0),e.body.__cimo_dropzone_listener_attached=!0)}async function u(e){try{return await n(e,{format:"webp",quality:window.cimoSettings?.webpQuality||.8,maxDimension:window.cimoSettings?.maxImageDimension||0})}catch(t){return console.error(t),{file:e,metadata:null}}}e(()=>{p(document),r(e=>{p(e)})});const f=["image/jpg","image/jpeg","image/png","image/gif"];function g(e){if(!window.wp&&!e)return;if(!e.body)return;e.body.__cimo_selectfiles_listener_attached||(e.body.addEventListener("change",async e=>{if("file"!==e.target.type)return;if(e.__cimo_converted)return;if(!Array.from(e.target.files).some(e=>f.includes(e.type)))return;if(!(e.target.closest(".components-form-file-upload")||e.target.closest(".media-frame")||e.target.closest(".media-upload-form")||e.target.closest(".moxie-shim")))return;if(!i("webp"))return;e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation();const t=Array.from(e.target.files),a=await Promise.all(t.map(u)),n=a.map(e=>e.file),o=a.map(e=>e.metadata),r=new DataTransfer;n.forEach(e=>{r.items.add(e)}),await s(o),e.target.files=r.files;const c=new Event("change",{bubbles:!0});c.__cimo_converted=!0,e.target.dispatchEvent(c)},!0),e.body.__cimo_selectfiles_listener_attached=!0)}function h(e,t=2,a=!1){if(0===e)return"0 Bytes";const i=t<0?0:t,n=Math.abs(e),o=Math.floor(Math.log(n)/Math.log(1024));let r=e<0?"-":"";return a&&(r="-"===r?"":"-"),r+parseFloat((n/Math.pow(1024,o)).toFixed(i))+" "+["Bytes","KB","MB","GB"][o]}e(()=>{g(document),r(e=>{g(e)})}),e(()=>{"undefined"!=typeof wp&&wp.media&&wp.media.view&&wp.media.view.Attachment&&wp.media.view.Attachment.Details&&(wp.media.view.Attachment.Details=wp.media.view.Attachment.Details.extend({template:function(e){const t=wp.media.template("attachment-details")(e),a=document.createElement("div");a.innerHTML=t;let i=e.model.get("cimo")||null;i&&0!==Object.keys(i).length||(i=m(e.model.get("originalImageName")||e.model.get("filename")));const n=a.querySelector(".attachment-info");if(i&&n){const e=document.createElement("div");e.className="cimo-media-manager-metadata";let t='<div class="cimo-media-manager-metadata-title-container">\n\t\t\t\t<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 672 672" height="20" width="20"><path d="M132.5 132.5C182.4 82.5 253 56 336 56C419 56 489.6 82.5 539.5 132.5C589.4 182.5 616 253 616 336C616 419 589.5 489.6 539.5 539.5C489.5 589.4 419 616 336 616C253 616 182.4 589.5 132.5 539.5C82.6 489.5 56 419 56 336C56 253 82.5 182.4 132.5 132.5zM465.5 273.9C477.6 264.2 479.5 246.6 469.9 234.5C460.3 222.4 442.6 220.5 430.5 230.1C378 272.1 330.3 341.9 306.7 379.4C291.4 359.3 267.2 331.1 239.5 312.6C226.6 304 209.2 307.5 200.7 320.4C192.2 333.3 195.6 350.7 208.5 359.2C237.4 378.5 264.1 415.1 274.1 429.9C281.5 440.9 294 447.9 307.9 447.9C322.3 447.9 335.5 440.3 342.8 428C357.2 403.5 410 318.3 465.6 273.8z"/></svg>\n\t\t\t\t<h3 class="cimo-media-manager-metadata-title">Image Optimized by Cimo</h3>\n\t\t\t\t</div>\n\t\t\t\t<ul>';const a=i.compressionSavings?(100-100*i.compressionSavings).toFixed(2):null,r=h(i.originalFilesize-i.convertedFilesize,1,!0);t+=`<li class="cimo-compression-savings ${o(a>0?"cimo-optimization-savings-up":"cimo-optimization-savings-down")}">Saved ${o(a)}% <span class="cimo-compression-savings-bytes">(${o(r)})</span></li>`;const s=h(parseInt(i.originalFilesize)||0),c=h(parseInt(i.convertedFilesize)||0);t+=`<li class="cimo-filesize-original">Original: <span class="cimo-value">${o(s)}</span></li>`,t+=`<li class="cimo-filesize-optimized">Optimized: <span class="cimo-value">${o(c)}</span></li>`,t+=`<li class="cimo-converted">🏞️ Converted to <span class="cimo-value">${o(function(e){const t=e.split("/")[1];return"webp"===t?"WebP":t.charAt(0).toUpperCase()+t.slice(1)}(i.convertedFormat))}</span></li>`;let m="N/A";if(i.conversionTime){const e=parseFloat(i.conversionTime);m=e<1e3?`${e.toFixed(0)} ms`:e<6e4?`${(e/1e3).toFixed(1)} sec`:`${(e/6e4).toFixed(1)} min`}t+=`<li class="cimo-time">⚡️ Done in <span class="cimo-value">${o(m)}</span></li>`,e.innerHTML=t,n.appendChild(e)}return a.innerHTML}}))})})();
     1(()=>{"use strict";function t(t){"undefined"!=typeof document&&("complete"!==document.readyState&&"interactive"!==document.readyState?document.addEventListener("DOMContentLoaded",t):t())}const e=window.wp.i18n;class i{constructor(t,i={}){this.file=t,this.options=i,this._progress=0,this._status=(0,e.__)("Ready","cimo-image-optimizer"),this._errorMessage=null}static get mimeTypes(){throw new Error("mimeTypes getter must be implemented by subclass")}static supportsMimeType(t){if(!t||"string"!=typeof t)return!1;const e=this.mimeTypes;return!!Array.isArray(e)&&e.includes(t)}get status(){return this._status}get errorMessage(){return this._errorMessage}get progress(){return this._progress}static get showProgress(){return!0}get showProgress(){return this.constructor.showProgress}async convert(){throw new Error("convert() must be implemented by subclass")}cancel(){}}const n=[{value:"webp",mimeType:"image/webp"},{value:"jpg",mimeType:"image/jpeg"},{value:"png",mimeType:"image/png"}];class s extends i{static get mimeTypes(){return["image/jpeg","image/png","image/webp","image/jpg"]}static get showProgress(){return!1}calculateDimensions(t,e,i){const n=(i=i||{}).scale?i.scale:1,s=i.width?i.width:"auto",o=i.height?i.height:"auto",r=i.aspectRatio?i.aspectRatio:"auto",a=i.maxDimension?i.maxDimension:0;let l=t*n,c=e*n;if(a&&"number"==typeof a&&a>0){const t=Math.max(l,c);if(t>a){const e=a/t;l*=e,c*=e}}if("auto"!==s&&"number"==typeof s&&(l=s,"auto"===o&&(c=e/t*l)),"auto"!==o&&"number"==typeof o&&(c=o,"auto"===s&&(l=t/e*c)),"auto"!==r){if("custom"===r)return{width:l,height:c};const[t,e]=r.split(":").map(Number),i=t/e,n=l/c;if(Math.abs(n-i)>.01)if(n>i)l=c*i;else{const t=l;l=t,c=t/i}}return{width:Math.round(l),height:Math.round(c)}}async convertImage(t,e="webp",i={}){let s=(i=i||{}).quality?i.quality:.8,o=i.maxDimension?i.maxDimension:0;return"string"==typeof s&&(s=parseFloat(s)/100,s||(s=.8)),"string"==typeof o&&(o=parseFloat(o)),new Promise((i,r)=>{const a=new Image;let l=null;a.onload=async()=>{const t=document.createElement("canvas"),{width:c,height:m}=this.calculateDimensions(a.width,a.height,{maxDimension:o});t.width=c,t.height=m;const d=t.getContext("2d"),p=a.width/a.height,u=c/m;let h=a.height,g=a.width,f=0,w=0;Math.abs(p-u)>.01&&(p>u?(g=a.height*u,f=(a.width-g)/2):(h=a.width/u,w=(a.height-h)/2)),d.drawImage(a,f,w,g,h,0,0,c,m);const y=n.find(t=>t.value===e),v="webp"===e||"jpg"===e?s:void 0;t.toBlob(function(e){URL.revokeObjectURL(l),l=null,d.clearRect(0,0,t.width,t.height),t.width=0,t.height=0,e?i(e):r(new Error("Failed to convert image"))},y.mimeType,v)},a.onerror=()=>{l&&(URL.revokeObjectURL(l),l=null),r(new Error("Failed to load image"))},l=URL.createObjectURL(t.file),a.src=l})}async convert(){const t=this.file,e=this.options?.format||"webp";if(!t.type||!t.type.startsWith("image/"))return{file:t,metadata:null};const i=n.find(t=>t.value===e);if(i&&t.type===i.mimeType)return{file:t,metadata:null};const s=document.createElement("canvas");if(i&&!s.toDataURL(i.mimeType).startsWith(`data:${i.mimeType}`))return console.error("[Cimo] "+e+" is not supported by the browser, please use another modern browser"),{file:t,metadata:null};if("image/gif"===t.type){const e=await t.slice(0,51200).arrayBuffer(),i=new Uint8Array(e);let n=0;for(let e=0;e<i.length-2;e++)if(33===i[e]&&249===i[e+1]&&4===i[e+2]&&(n++,n>1))return{file:t,metadata:null}}const o={file:t};try{const n=performance.now(),s=await this.convertImage(o,e,{quality:this.options?.quality||.8,maxDimension:this.options?.maxDimension||0}),r=performance.now(),a="jpeg"===e?"jpg":e,l=t.name.replace(/\.[^/.]+$/,"")+"."+a,c={filename:l,originalFormat:t.type,originalFilesize:t.size,convertedFormat:i.mimeType,convertedFilesize:s.size,conversionTime:r-n,compressionSavings:t.size>0?s.size/t.size:null};return{file:new(0,t.constructor)([s],l,{type:i.mimeType,lastModified:Date.now()}),metadata:c}}catch(t){throw new Error(`Failed to convert image: ${t.message}`)}}}class o extends i{static get showProgress(){return!1}async convert(){return{file:this.file,metadata:null}}}const r=window.wp.hooks,a=t=>{let e=t;if(!e||"object"!=typeof e||"string"!=typeof e.name||"number"!=typeof e.size||"string"!=typeof e.type||"function"!=typeof e.slice)return new o(e);if(!(e instanceof File)){const t=e;e=new File(t?[t]:[],t?.name||"unknown",{type:t?.type||"application/octet-stream",lastModified:"number"==typeof t?.lastModified?t.lastModified:Date.now()})}if(e.type.startsWith("image/")){if(!function(t){const e={webp:"image/webp",avif:"image/avif"}[t.toLowerCase()]||(t.startsWith("image/")?t:null);if(!e)return!1;const i=document.createElement("canvas");i.width=1,i.height=1;try{return i.toDataURL(e).startsWith(`data:${e}`)}catch(t){return!1}}("webp"))return new o(e);if(s.supportsMimeType(e.type))return new s(e,{format:"webp",quality:window.cimoSettings?.webpQuality||.8,maxDimension:window.cimoSettings?.maxImageDimension||0})}return(0,r.applyFilters)("cimo.getFileConverter",null,e)||new o(e)};function l(t){return!t.every(t=>"NullConverter"===t.constructor.name)}function c(t){return("string"!=typeof t?String(t):t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/`/g,"&#96;")}function m(t,e="editor-canvas"){const i=()=>{const i=document.querySelector(`iframe[name="${e}"]`);if(i&&i.contentDocument){const e=()=>{i.contentDocument.body?t(i.contentDocument):setTimeout(e,50)};"loading"===i.contentDocument.readyState?i.addEventListener("load",()=>{e()}):e()}};i();let n=0;const s=setInterval(()=>{n>=10?clearInterval(s):(n++,i())},1e3),o=new MutationObserver(t=>{t.forEach(t=>{t.addedNodes.forEach(t=>{t.nodeType===Node.ELEMENT_NODE&&("IFRAME"===t.tagName&&t.name===e||t.querySelector&&t.querySelector(`iframe[name="${e}"]`))&&i()})})});return o.observe(document.body,{childList:!0,subtree:!0}),o}const d=t=>{if(!Array.isArray(t))return Promise.resolve();const e=t.filter(t=>null!==t);return 0===e.length||e.every(t=>u(t.filename))?Promise.resolve():(e.forEach(t=>{t.filename&&p(t.filename,t)}),new Promise((t,i)=>{fetch(`${window.cimoSettings?.restUrl||"/wp-json/cimo/v1/"}metadata`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","X-WP-Nonce":window.cimoSettings?.nonce||window.wpApiSettings?.nonce},body:JSON.stringify({metadata:e}),credentials:"same-origin"}).then(t=>t.ok?t.json():t.json().then(e=>{throw new Error(e.message||t.statusText)})).then(e=>{t(e)}).catch(t=>{console.error(`Failed to save metadata for filenames: [${e.map(t=>t.filename).join(", ")}]:`,t),i(new Error(`Failed to save metadata: ${t.message}`))})}))},p=(t,e)=>{window.cimoMetadataCache||(window.cimoMetadataCache={}),window.cimoMetadataCache[t.replaceAll(/\s+/g,"-")]={...e}},u=t=>window.cimoMetadataCache?.[t?.replaceAll(/\s+/g,"-")]||null;class h{constructor(t=[],e=null){this.converters=Array.isArray(t)?t.filter(t=>!0===t?.showProgress):[],this.closeHandler="function"==typeof e?e:null,this.interval=null,this.modal=null,this.progressBars=[],this._setupModal()}open(){this.modal&&0!==this.converters.length&&(this.modal.style.display="flex",this._startInterval())}_handleCloseClick(){confirm((0,e.__)("Closing this dialog will cancel the uploading process. Are you sure you want to continue?","cimo-image-optimizer"))&&(this.closeHandler&&this.closeHandler(),this.close())}close(){this.modal&&0!==this.converters.length&&setTimeout(()=>{this.modal.style.display="none",this._stopInterval(),this.modal.remove(),this.modal=null},300)}_setupModal(){this.modal=document.createElement("div"),this.modal.className="cimo-progress-modal",this.modal.style.cssText="\n\t\t\tposition: fixed;\n\t\t\ttop: 0;\n\t\t\tleft: 0;\n\t\t\twidth: 100vw;\n\t\t\theight: 100vh;\n\t\t\tbackground: rgba(0,0,0,0.35);\n\t\t\tdisplay: none;\n\t\t\tjustify-content: center;\n\t\t\talign-items: center;\n\t\t\tz-index: 9999999;\n\t\t";const t=document.createElement("div");t.className="cimo-progress-wrapper",t.style.cssText="\n\t\t\tbackground: #fff;\n\t\t\tborder-radius: 8px;\n\t\t\tpadding: 2em 2em 1em 2em;\n\t\t\tmax-width: 500px;\n\t\t\tbox-shadow: 0 6px 32px rgba(0,0,0,0.24);\n\t\t\tposition: relative;\n\t\t\twidth: 90%;\n\t\t";const i=document.createElement("h3");i.className="cimo-progress-title",i.innerText=(0,e.__)("Optimizing your files","cimo-image-optimizer"),i.style.cssText="\n\t\t\tfont-size: 1.6em !important;\n\t\t\tfont-weight: 600 !important;\n\t\t\tmargin: 0 0 0.5em !important;\n\t\t",t.appendChild(i);const n=document.createElement("div");if(n.className="cimo-progress-subtitle",n.innerText=(0,e.__)("Preparing your files for upload…","cimo-image-optimizer"),n.style.cssText="\n\t\t\tmargin-bottom: 2em;\n\t\t",t.appendChild(n),this.errorNote=document.createElement("div"),this.errorNote.className="cimo-progress-error-note",this.errorNote.innerText=(0,e.__)("Some media files could not be optimized and were uploaded in their original format.","cimo-image-optimizer"),this.errorNote.style.cssText="\n\t\t\tdisplay: none;\n\t\t\tbackground: #fff3cd;\n\t\t\tcolor: #856404;\n\t\t\tborder: 1px solid #ffeeba;\n\t\t\tborder-radius: 8px;\n\t\t\tpadding: 1em;\n\t\t\tmargin-bottom: 1.5em;\n\t\t\tfont-size: 1em;\n\t\t",t.appendChild(this.errorNote),this.closeHandler){const e=document.createElement("button");e.className="cimo-progress-close",e.type="button",e.innerHTML="&times;",e.style.cssText="\n\t\t\t\tposition: absolute;\n\t\t\t\ttop: 0.7em;\n\t\t\t\tright: 1em;\n\t\t\t\tbackground: transparent;\n\t\t\t\tborder: none;\n\t\t\t\tfont-size: 2em;\n\t\t\t\tcursor: pointer;\n\t\t\t\tcolor: #888;\n\t\t\t",e.addEventListener("click",()=>this._handleCloseClick()),t.appendChild(e)}this.progressBars=[],this.progressList=document.createElement("div"),this.progressList.className="cimo-progress-list",t.appendChild(this.progressList),this.modal.appendChild(t),document.body.appendChild(this.modal),this._renderProgressBars()}_renderProgressBars(){this.progressList.innerHTML="",this.progressBars=[],this.converters.forEach((t,e)=>{const i=document.createElement("div");i.className="cimo-progress-bar-container",i.style.cssText="\n\t\t\t\tmargin-bottom: 1em;\n\t\t\t\tpadding: 16px 16px 16px 70px;\n\t\t\t\tborder: 1px solid #e2e8f0;\n\t\t\t\tborder-radius: 12px;\n\t\t\t\tposition: relative;\n\t\t\t";const n=document.createElement("span");n.className="cimo-stat-icon",n.style.cssText="\n\t\t\t\tbackground: #16a2491a;\n        \t\tcolor: #16a249;\n\t\t\t\tpadding: 8px;\n\t\t\t\tborder-radius: 8px;\n\t\t\t\tmargin-bottom: 8px;\n\t\t\t\tdisplay: flex;\n\t\t\t\talign-items: center;\n\t\t\t\tjustify-content: center;\n\t\t\t\tposition: absolute;\n\t\t\t\tleft: 16px;\n\t\t\t\ttop: 16px;\n\t\t\t";let s="";s=t.file&&t.file.type&&t.file.type.startsWith("video/")?'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-video-icon lucide-video"><path d="m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5"/><rect x="2" y="6" width="14" height="12" rx="2"/></svg>':t.file&&t.file.type&&t.file.type.startsWith("audio/")?'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-music-icon lucide-music"><path d="M9 18V5l12-2v13"/><circle cx="6" cy="18" r="3"/><circle cx="18" cy="16" r="3"/></svg>':'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-image-icon lucide-image"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/></svg>',n.innerHTML=s,i.appendChild(n);const o=document.createElement("div");o.className="cimo-progress-label",o.innerText=t.file?.name||`File ${e+1}`,o.style.cssText="\n\t\t\t\tmargin-bottom: 0.2em;\n\t\t\t\tfont-size: 1em;\n\t\t\t\tfont-weight: 600;\n\t\t\t\tmax-width: 80%;\n\t\t\t\twhite-space: nowrap;\n\t\t\t\ttext-overflow: ellipsis;\n\t\t\t\toverflow: hidden;\n\t\t\t";const r=document.createElement("div");r.className="cimo-size-label",r.innerText=t.file&&t.file.size?t.file.size/1024/1024>=1?(t.file.size/1024/1024).toFixed(2)+" MB":(t.file.size/1024).toFixed(1)+" KB":"",r.style.cssText="\n\t\t\t\tmargin-bottom: 0.5em;\n\t\t\t\tfont-size: 1em;\n\t\t\t";const a=document.createElement("div");a.style.cssText="\n\t\t\t\tdisplay: flex;\n\t\t\t\talign-items: center;\n\t\t\t\tjustify-content: space-between;\n\t\t\t\tmargin-bottom: 0.5em;\n\t\t\t";const l=document.createElement("div");l.className="cimo-progress-status-label",l.innerText="",l.style.cssText="\n\t\t\t\tfont-size: 1em;\n\t\t\t\tcolor: #3b3b3b;\n\t\t\t";const c=document.createElement("div");c.className="cimo-percentage-label",c.innerText="0%",c.style.cssText="\n\t\t\t\tfont-size: 1em;\n\t\t\t",a.appendChild(l),a.appendChild(c);const m=document.createElement("div");m.className="cimo-progress-bar-bg",m.style.cssText="\n\t\t\t\tbackground: #e8ecef;\n\t\t\t\tborder-radius: 5px;\n\t\t\t\theight: 8px;\n\t\t\t\twidth: 100%;\n\t\t\t\toverflow: hidden;\n\t\t\t";const d=document.createElement("div");d.className="cimo-progress-bar",d.style.cssText="\n\t\t\t\tbackground: linear-gradient(90deg, #00d8f0 0%, #2bc566 100%);\n\t\t\t\twidth: 0%;\n\t\t\t\theight: 100%;\n\t\t\t\ttransition: width 0.5s linear;\n\t\t\t\tborder-radius: 5px 0 0 5px;\n\t\t\t",d.sizeLabelEl=r,d.statusLabelEl=l,d.percentageLabelEl=c,m.appendChild(d),i.appendChild(o),i.appendChild(r),i.appendChild(a),i.appendChild(m),this.progressList.appendChild(i),this.progressBars.push(d)})}_startInterval(){this.interval||(this._updateProgress(),this.interval=setInterval(()=>this._updateProgress(),500))}_stopInterval(){this.interval&&(clearInterval(this.interval),this.interval=null)}_updateProgress(){let t=!0,e=!1;this.converters.forEach((i,n)=>{let s=100*i.progress;("number"!=typeof s||isNaN(s)||s<0)&&(s=0),s>=100&&(s=100),s<100&&(t=!1),i.errorMessage&&(e=!0,this.errorNote.style.display="block"),this.progressBars[n]&&(this.progressBars[n].statusLabelEl.style.cssText=`\n\t\t\t\t\tcolor: ${i.errorMessage?"#dc3545":"inherit"};\n\t\t\t\t`,this.progressBars[n].statusLabelEl.innerText=i.errorMessage||i.status,this.progressBars[n].style.width=s+"%",this.progressBars[n].percentageLabelEl.innerText=parseInt(s)+"%")}),t&&"block"===this.modal.style.display&&(e||setTimeout(()=>this.close(),750))}}function g(t){if(!t)return;if(!t.body)return;t.body.__cimo_dropzone_listener_attached||(t.body.addEventListener("drop",async e=>{if(e.__cimo_converted)return;const i=Array.from(e.dataTransfer.files).map(t=>a(t));if(!l(i))return;if(!(e.target.closest(".media-frame-uploader")||e.target.closest(".media-upload-form")||e.target.closest(".editor-post-featured-image")||e.target.closest(".editor-styles-wrapper")||e.target.closest(".uploader-window")))return;let n;for(e.preventDefault(),e.stopPropagation();n=document.querySelector('.uploader-window[style*="display: block"]');)n.style.display="none";const s=new h(i,()=>{i.forEach(t=>t.cancel())});s.open();let o=!1;const r=await Promise.all(i.map(async t=>{try{return await t.convert()}catch(e){return o=!0,{file:t.file,metadata:null}}})),c=r.map(t=>t.file),m=r.map(t=>t.metadata),p=new DataTransfer;if(c.forEach(t=>{p.items.add(t)}),await d(m),e.target?.classList.contains("components-drop-zone")){const i=t!==document,n=new Event("drop",{bubbles:!i});Object.defineProperty(n,"dataTransfer",{value:p,writable:!1}),n.__cimo_converted=!0,e.target.dispatchEvent(n)}else{const i=document.querySelector('.media-modal input[type="file"]')||document.querySelector('.media-upload-form input[type="file"]')||document.querySelector('input[type="file"]');if(i){i.files=p.files;const e=t!==document,n=new Event("change",{bubbles:!e});n.__cimo_converted=!0,i.dispatchEvent(n)}else{const t=new Event("drop",{bubbles:!0});Object.defineProperty(t,"dataTransfer",{value:p,writable:!1}),t.__cimo_converted=!0,e.target.dispatchEvent(t)}}o||s.close()},!0),t.body.__cimo_dropzone_listener_attached=!0)}function f(t){if(!window.wp&&!t)return;if(!t.body)return;t.body.__cimo_selectfiles_listener_attached||(t.body.addEventListener("change",async t=>{if("file"!==t.target.type)return;if(t.__cimo_converted)return;const e=Array.from(t.target.files).map(t=>a(t));if(!l(e))return;if(!(t.target.closest(".components-form-file-upload")||t.target.closest(".media-frame")||t.target.closest(".media-upload-form")||t.target.closest(".moxie-shim")))return;t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation();const i=new h(e,()=>{e.forEach(t=>t.cancel())});i.open();let n=!1;const s=await Promise.all(e.map(async t=>{try{return await t.convert()}catch(e){return n=!0,{file:t.file,metadata:null}}})),o=s.map(t=>t.file),r=s.map(t=>t.metadata),c=new DataTransfer;o.forEach(t=>{c.items.add(t)}),await d(r),t.target.files=c.files;const m=new Event("change",{bubbles:!0});m.__cimo_converted=!0,t.target.dispatchEvent(m),n||i.close()},!0),t.body.__cimo_selectfiles_listener_attached=!0)}function w(t,e=2,i=!1){if(0===t)return"0 Bytes";const n=e<0?0:e,s=Math.abs(t),o=Math.floor(Math.log(s)/Math.log(1024));let r=t<0?"-":"";return i&&(r="-"===r?"":"-"),r+parseFloat((s/Math.pow(1024,o)).toFixed(n))+" "+["Bytes","KB","MB","GB"][o]}t(()=>{g(document),m(t=>{g(t)})}),t(()=>{f(document),m(t=>{f(t)})}),t(()=>{"undefined"!=typeof wp&&wp.media&&wp.media.view&&wp.media.view.Attachment&&wp.media.view.Attachment.Details&&(wp.media.view.Attachment.Details=wp.media.view.Attachment.Details.extend({template:function(t){const i=wp.media.template("attachment-details")(t),n=document.createElement("div");n.innerHTML=i;let s=t.model.get("cimo")||null;s&&0!==Object.keys(s).length||(s=u(t.model.get("originalImageName")||t.model.get("filename")));const o=n.querySelector(".attachment-info");if(s&&o){const i=document.createElement("div");i.className="cimo-media-manager-metadata";const n=function(t){if(!t)return"Media";const[e="media"]=t.split("/");switch(e.toLowerCase()){case"image":return"Image";case"video":return"Video";case"audio":return"Audio";default:return"Media"}}(s.convertedFormat||t.model.get("mime")||"");let r=`<div class="cimo-media-manager-metadata-title-container">\n\t\t\t\t<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 672 672" height="20" width="20"><path d="M132.5 132.5C182.4 82.5 253 56 336 56C419 56 489.6 82.5 539.5 132.5C589.4 182.5 616 253 616 336C616 419 589.5 489.6 539.5 539.5C489.5 589.4 419 616 336 616C253 616 182.4 589.5 132.5 539.5C82.6 489.5 56 419 56 336C56 253 82.5 182.4 132.5 132.5zM465.5 273.9C477.6 264.2 479.5 246.6 469.9 234.5C460.3 222.4 442.6 220.5 430.5 230.1C378 272.1 330.3 341.9 306.7 379.4C291.4 359.3 267.2 331.1 239.5 312.6C226.6 304 209.2 307.5 200.7 320.4C192.2 333.3 195.6 350.7 208.5 359.2C237.4 378.5 264.1 415.1 274.1 429.9C281.5 440.9 294 447.9 307.9 447.9C322.3 447.9 335.5 440.3 342.8 428C357.2 403.5 410 318.3 465.6 273.8z"/></svg>\n\t\t\t\t<h3 class="cimo-media-manager-metadata-title">${c((0,e.sprintf)((0,e.__)("%s Optimized by Cimo","cimo-image-optimizer"),n))}</h3>\n\t\t\t\t</div>\n\t\t\t\t<ul>`;const a=s.compressionSavings?(100-100*s.compressionSavings).toFixed(2):null,l=w(s.originalFilesize-s.convertedFilesize,1,!0);r+=`<li class="cimo-compression-savings ${c(a>0?"cimo-optimization-savings-up":"cimo-optimization-savings-down")}">Saved ${c(a)}% <span class="cimo-compression-savings-bytes">(${c(l)})</span></li>`;const m=w(parseInt(s.originalFilesize)||0),d=w(parseInt(s.convertedFilesize)||0);r+=`<li class="cimo-filesize-original">Original: <span class="cimo-value">${c(m)}</span></li>`,r+=`<li class="cimo-filesize-optimized">Optimized: <span class="cimo-value">${c(d)}</span></li>`,r+=`<li class="cimo-converted">🏞️ Converted to <span class="cimo-value">${c(function(t){if(!t)return"";const e=t.split("/"),i=e[1]||e[0]||"";return"webp"===i?"WebP":i.charAt(0).toUpperCase()+i.slice(1)}(s.convertedFormat))}</span></li>`;let p="N/A";if(s.conversionTime){const t=parseFloat(s.conversionTime);p=t<1e3?`${t.toFixed(0)} ms`:t<6e4?`${(t/1e3).toFixed(1)} sec`:`${(t/6e4).toFixed(1)} min`}r+=`<li class="cimo-time">⚡️ Done in <span class="cimo-value">${c(p)}</span></li>`,i.innerHTML=r,o.appendChild(i)}return n.innerHTML}}))})})();
  • cimo-image-optimizer/trunk/cimo.php

    r3377996 r3402030  
    11<?php
    22/**
    3  * Plugin Name: Cimo - Free Instant Image Optimizer & WebP Converter
     3 * Plugin Name: Cimo - Image Optimizer
    44 * Plugin URI: https://wordpress.org/plugins/cimo-image-optimizer
    55 * Description: Unlimited free image compression and WebP conversion, done instantly as you upload them. No quotas, no external servers, no limits.
     
    88 * License: GPLv2 or later
    99 * Text Domain: cimo-image-optimizer
    10  * Version: 1.1.2
     10 * Version: 1.2.0
    1111 *
    12  * @fs_premium_only /freemius.php, /freemius/
     12 * @fs_premium_only /freemius.php, /freemius/, /lib/freemius-php-sdk
    1313 */
    1414
     
    1919
    2020defined( 'CIMO_FILE' ) || define( 'CIMO_FILE', __FILE__ );
     21defined( 'CIMO_BUILD' ) || define( 'CIMO_BUILD', 'free' );
    2122
    2223require_once __DIR__ . '/src/admin/class-script-loader.php';
     
    3536}
    3637register_activation_hook( __FILE__, 'cimo_activate' );
     38
     39if ( CIMO_BUILD === 'premium' ) {
     40    /**
     41     * Premium initialize code.
     42     */
     43    if ( file_exists( plugin_dir_path( __FILE__ ) . 'pro__premium_only/index.php' ) ) {
     44        require_once( plugin_dir_path( __FILE__ ) . 'pro__premium_only/index.php' );
     45    }
     46}
  • cimo-image-optimizer/trunk/readme.txt

    r3381565 r3402030  
    55Tested up to: 6.8.3
    66Requires PHP: 8.0
    7 Stable tag: 1.1.2
     7Stable tag: 1.2.0
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    1515**Optimize all your images instantly and for free.**
    1616
    17 Cimo is a game-changer for image optimization. It optimizes and converts your images instantly as you upload — even before the files are added to your Media Library.
     17Cimo is a game-changer for media optimization. It optimizes, resizes and converts your images instantly as you upload — even before the files are added to your Media Library.
    1818
    1919From WordPress' point of view, it's as if you optimized your image BEFORE your uploaded it. Now, this is next-next-gen image optimization.
     
    2727* No external image-processing services
    2828
    29 > **Note:** Cimo works in all modern browsers (Chrome, Firefox, Edge, Opera). This currently doesn't work in Safari, images would just upload as they normally would, please use any of the browsers listed.
     29> **Note:** Cimo works in all modern browsers (Chrome, Firefox, Edge, Opera). Image optimization currently doesn't work in Safari, images would just upload as they normally would, please use any of the browsers listed.
    3030
    3131Image Optimization options:
     
    8787**Since Cimo's optimization works during the upload process, Cimo should be compatible with any plugin that uses images**
    8888
     89= What's in Premium? =
     90
     91If you upgrade to Cimo Premium, you will get the following:
     92
     93* **Video Optimization** – automatically optimize and optionally downscale the resolution of videos as you upload them
     94* **Audio Optimization** – auotmatically optimize audio files as you upload them
     95* **Low Quality Image Placeholders (LQIP)** – for native image blocks, display a subtle image placeholder while waiting for images to load, then fade the loaded image in.
     96
     97Video & Audio optimization are also performed as you upload your files, even before the files are added to your Media Library.
     98
    8999== Technical Details ==
    90100
     
    191201== Changelog ==
    192202
     203= 1.2.0 =
     204
     205* New: Video Optimization (premium)
     206* New: Audio Optimization (premium)
     207* New: Low Quality Image Placeholders (premium)
     208* New: Added rating notice at the right time
     209* Fixed: Now intercepts media uploads when performed inside the block editor iframe
     210
    193211= 1.1.2 =
    194212
  • cimo-image-optimizer/trunk/src/admin/class-admin-notices.php

    r3353691 r3402030  
    1212    class Cimo_Admin_Notices {
    1313        public function __construct() {
    14             add_action( 'admin_notices', [ $this, 'show_activation_notice' ] );
    15             add_action( 'admin_init', [ $this, 'dismiss_activation_notice' ] );
    16             add_action( 'wp_ajax_cimo_dismiss_activation_ajax', [ $this, 'ajax_dismiss_activation_notice' ] );
     14            if ( CIMO_BUILD === 'free' ) {
     15                add_action( 'admin_notices', [ $this, 'show_activation_notice' ] );
     16                add_action( 'admin_init', [ $this, 'dismiss_activation_notice' ] );
     17                add_action( 'wp_ajax_cimo_dismiss_activation_ajax', [ $this, 'ajax_dismiss_activation_notice' ] );
     18            }
    1719        }
    1820
  • cimo-image-optimizer/trunk/src/admin/class-admin.php

    r3377045 r3402030  
    7575                                    ],
    7676                                ],
     77
     78                                // LQIP settings
     79                                'lqip_enabled' => [
     80                                    'type' => 'integer',
     81                                ],
     82                                'lqip_pulse_speed' => [
     83                                    'type' => 'number',
     84                                    'format' => 'float',
     85                                ],
     86                                'lqip_brightness' => [
     87                                    'type' => 'number',
     88                                    'format' => 'float',
     89                                ],
     90                                'lqip_fade_duration' => [
     91                                    'type' => 'number',
     92                                    'format' => 'float',
     93                                ],
     94
     95                                // Video Optimization settings
     96                                'video_optimization_enabled' => [
     97                                    'type' => 'integer',
     98                                ],
     99                                'video_quality' => [
     100                                    'type' => 'integer',
     101                                ],
     102                                'video_max_resolution' => [
     103                                    'type' => 'string',
     104                                ],
     105
     106                                // Audio Optimization settings
     107                                'audio_optimization_enabled' => [
     108                                    'type' => 'integer',
     109                                ],
     110                                'audio_quality' => [
     111                                    'type' => 'integer',
     112                                ],
    77113                            ],
    78114                        ],
     
    80116                ]
    81117            );
     118
     119            register_setting(
     120                'cimo_rating',
     121                'cimo_rating_dismissed',
     122                [
     123                    'type'              => 'string',
     124                    'description'       => __( 'Tracks if the rating notice has been dismissed.', 'cimo-image-optimizer' ),
     125                    'sanitize_callback' => [ $this, 'sanitize_rating_dismissed' ],
     126                    'show_in_rest'      => [
     127                        'schema' => [
     128                            'type' => 'string',
     129                            'enum' => [ '0', '1' ],
     130                        ],
     131                    ],
     132                    'default'           => '0',
     133                ]
     134            );
    82135        }
    83136
     
    90143                return;
    91144            }
     145           
     146            // Enqueue WordPress component styles
     147            wp_enqueue_style( 'wp-components' );
     148
     149            // This should return the dependencies for both css and js, these will be merged with the default dependencies.
     150            $dependencies = apply_filters( 'cimo/admin/enqueue_admin_scripts', ['css' => [], 'js' => []] );
    92151
    93152            // Get the build files
     
    95154            $build_url = plugin_dir_url( CIMO_FILE ) . 'build/admin/';
    96155           
    97             // Enqueue WordPress component styles
    98             wp_enqueue_style( 'wp-components' );
    99            
    100156            // Enqueue CSS
    101             $script_asset = include $build_dir . 'admin-settings.asset.php';
     157            $script_asset = include $build_dir . 'admin-page-styles.asset.php';
    102158            wp_enqueue_style(
    103                 'cimo-admin-settings',
    104                 $build_url . 'admin-settings.css',
    105                 [ 'wp-components' ],
     159                'cimo-admin-page-styles',
     160                $build_url . 'admin-page-styles.css',
     161                array_merge( [ 'wp-components' ], $dependencies['css'] ),
    106162                $script_asset['version']
    107163            );
     
    112168                'cimo-admin-page',
    113169                $build_url . 'admin-page.js',
    114                 $script_asset['dependencies'],
     170                array_merge( $script_asset['dependencies'], $dependencies['js'] ),
    115171                $script_asset['version'],
    116172                true
     
    135191                'stats' => $stats,
    136192                'imageSizes' => $formatted_sizes,
     193                'ratingDismissed' => '1' === get_option( 'cimo_rating_dismissed', '0' ) ? '1' : '0',
    137194            ] );
    138195        }
     
    158215         */
    159216        public function sanitize_options( $options ) {
    160             $sanitized = [];
     217            // Load up the complete options so we don't lose any existing settings.
     218            $current = get_option( 'cimo_options', [] );
     219            $sanitized = is_array( $current ) ? $current : [];
    161220
    162221            // Sanitize webp quality
     
    189248            }
    190249
     250            // Sanitize lqip_enabled
     251            if ( isset( $options['lqip_enabled'] ) ) {
     252                $sanitized['lqip_enabled'] = $options['lqip_enabled'] ? 1 : 0;
     253            }
     254            if ( isset( $options['lqip_pulse_speed'] ) ) {
     255                $sanitized['lqip_pulse_speed'] = floatval( $options['lqip_pulse_speed'] );
     256            }
     257            if ( isset( $options['lqip_brightness'] ) ) {
     258                $sanitized['lqip_brightness'] = floatval( $options['lqip_brightness'] );
     259            }
     260            if ( isset( $options['lqip_fade_duration'] ) ) {
     261                $sanitized['lqip_fade_duration'] = floatval( $options['lqip_fade_duration'] );
     262            }
     263
     264            // Sanitize video quality
     265            if ( isset( $options['video_optimization_enabled'] ) ) {
     266                $sanitized['video_optimization_enabled'] = $options['video_optimization_enabled'] ? 1 : 0;
     267            }
     268            if ( isset( $options['video_quality'] ) ) {
     269                $sanitized['video_quality'] = intval( $options['video_quality'] );
     270            }
     271            if ( isset( $options['video_max_resolution'] ) ) {
     272                $sanitized['video_max_resolution'] = sanitize_text_field( $options['video_max_resolution'] );
     273            }
     274
     275            // Sanitize audio quality
     276            if ( isset( $options['audio_optimization_enabled'] ) ) {
     277                $sanitized['audio_optimization_enabled'] = $options['audio_optimization_enabled'] ? 1 : 0;
     278            }
     279            if ( isset( $options['audio_quality'] ) ) {
     280                $sanitized['audio_quality'] = intval( $options['audio_quality'] );
     281            }
     282
    191283            return $sanitized;
     284        }
     285
     286        /**
     287         * Sanitize rating dismissed flag
     288         */
     289        public function sanitize_rating_dismissed( $value ) {
     290            return '1' === (string) $value ? '1' : '0';
    192291        }
    193292
  • cimo-image-optimizer/trunk/src/admin/class-meta-box.php

    r3352840 r3402030  
    6464                        }
    6565
     66                        // Helper to get media type label from mimetype.
     67                        function cimo_get_media_type_label( $mimetype ) {
     68                            if ( ! is_string( $mimetype ) || strpos( $mimetype, '/' ) === false ) {
     69                                return esc_html__( 'Media', 'cimo-image-optimizer' );
     70                            }
     71                            $parts = explode( '/', $mimetype );
     72                            $category = strtolower( $parts[0] );
     73
     74                            switch ( $category ) {
     75                                case 'image':
     76                                    return esc_html__( 'Image', 'cimo-image-optimizer' );
     77                                case 'video':
     78                                    return esc_html__( 'Video', 'cimo-image-optimizer' );
     79                                case 'audio':
     80                                    return esc_html__( 'Audio', 'cimo-image-optimizer' );
     81                                default:
     82                                    return esc_html__( 'Media', 'cimo-image-optimizer' );
     83                            }
     84                        }
     85
    6686                        $cimo = $metadata['cimo'];
    6787
     
    7797                        $converted_size = cimo_format_filesize( $converted_filesize );
    7898
    79                         $converted_format = isset( $cimo['convertedFormat'] ) ? cimo_convert_mimetype_to_format( $cimo['convertedFormat'] ) : '';
     99                        $converted_format_raw = isset( $cimo['convertedFormat'] ) ? $cimo['convertedFormat'] : ( isset( $post->post_mime_type ) ? $post->post_mime_type : '' );
     100                        $converted_format = $converted_format_raw ? cimo_convert_mimetype_to_format( $converted_format_raw ) : '';
     101                        $media_type_label = cimo_get_media_type_label( $converted_format_raw );
    80102                        $converttime = isset( $cimo['conversionTime'] ) ? floatval( $cimo['conversionTime'] ) : null;
    81103                        if ( $converttime !== null ) {
     
    94116                        echo '<div class="cimo-media-manager-metadata-title-container">';
    95117                        echo '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 672 672" height="20" width="20"><path d="M132.5 132.5C182.4 82.5 253 56 336 56C419 56 489.6 82.5 539.5 132.5C589.4 182.5 616 253 616 336C616 419 589.5 489.6 539.5 539.5C489.5 589.4 419 616 336 616C253 616 182.4 589.5 132.5 539.5C82.6 489.5 56 419 56 336C56 253 82.5 182.4 132.5 132.5zM465.5 273.9C477.6 264.2 479.5 246.6 469.9 234.5C460.3 222.4 442.6 220.5 430.5 230.1C378 272.1 330.3 341.9 306.7 379.4C291.4 359.3 267.2 331.1 239.5 312.6C226.6 304 209.2 307.5 200.7 320.4C192.2 333.3 195.6 350.7 208.5 359.2C237.4 378.5 264.1 415.1 274.1 429.9C281.5 440.9 294 447.9 307.9 447.9C322.3 447.9 335.5 440.3 342.8 428C357.2 403.5 410 318.3 465.6 273.8z"/></svg>';
    96                         echo '<h3 class="cimo-media-manager-metadata-title">Image Optimized by Cimo</h3>';
     118                        echo '<h3 class="cimo-media-manager-metadata-title">' . sprintf( esc_html__( '%s Optimized by Cimo', 'cimo-image-optimizer' ), esc_html( $media_type_label ) ) . '</h3>';
    97119                        echo '</div>';
    98120                        echo '<ul>';
  • cimo-image-optimizer/trunk/src/admin/class-script-loader.php

    r3377045 r3402030  
    1313        public function __construct() {
    1414            // Enqueue for the block editor.
    15             add_action( 'enqueue_block_editor_assets', [ $this, 'enqueue_media_assets' ] );
     15            add_action( 'enqueue_block_editor_assets', [ $this, 'enqueue_cimo_assets' ] );
    1616            // Enqueue for Elementor.
    17             add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'enqueue_media_assets' ] );
     17            add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'enqueue_cimo_assets' ] );
    1818            // Enqueue for Beaver Builder main window (outside BB's iframe).
    1919            if ( class_exists( 'FLBuilderModel' ) ) {
     
    2323            add_action( 'bricks_before_site_wrapper', [ $this, 'maybe_enqueue_for_bricks_builder' ] );
    2424            // Enqueue for Oxygen Builder
    25             add_action( 'oxygen_enqueue_ui_scripts', [ $this, 'enqueue_media_assets' ] );
     25            add_action( 'oxygen_enqueue_ui_scripts', [ $this, 'enqueue_cimo_assets' ] );
    2626            // Enqueue for Divi
    27             add_action( 'et_fb_enqueue_assets', [ $this, 'enqueue_media_assets' ] );
     27            add_action( 'et_fb_enqueue_assets', [ $this, 'enqueue_cimo_assets' ] );
    2828            // Enqueue for the admin area in general.
    29             add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_media_assets' ] );
     29            add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_cimo_assets' ] );
    3030        }
    3131
     
    3636            // Check if we're in the Beaver Builder editor context.
    3737            if ( class_exists( 'FLBuilderModel' ) && FLBuilderModel::is_builder_active() ) {
    38                 $this->enqueue_media_assets();
     38                $this->enqueue_cimo_assets();
    3939            }
    4040        }
     
    4545        public function maybe_enqueue_for_bricks_builder() {
    4646            if ( function_exists( 'bricks_is_builder' ) && bricks_is_builder() ) {
    47                 $this->enqueue_media_assets();
     47                $this->enqueue_cimo_assets();
    4848            }
    4949        }
    5050
    51         public function enqueue_media_assets() {
    52             // If cimo-editor is already enqueued, don't enqueue again.
    53             if ( wp_script_is( 'cimo-editor', 'enqueued' ) ) {
     51        public function enqueue_cimo_assets() {
     52            // If cimo-script is already enqueued, don't enqueue again.
     53            if ( wp_script_is( 'cimo-script', 'enqueued' ) ) {
    5454                return;
    5555            }
     56
     57            // This should return the dependencies for both css and js, these will be merged with the default dependencies.
     58            $dependencies = apply_filters( 'cimo/script_loader/enqueue_cimo_assets', ['css' => [], 'js' => []] );
    5659
    5760            $build_dir = plugin_dir_path( CIMO_FILE ) . 'build/admin/';
     
    6164            $script_asset = include $build_dir . 'index.asset.php';
    6265            wp_enqueue_script(
    63                 'cimo-editor',
     66                'cimo-script',
    6467                $build_url . 'index.js',
    65                 // Remove wp-dom-ready since it's not really a dependency, but wp-scripts includes it.
    66                 array_values( array_diff( $script_asset['dependencies'], [ 'wp-dom-ready' ] ) ),
     68                array_merge(
     69                    // Remove wp-dom-ready since it's not really a dependency, but wp-scripts includes it.
     70                    array_values( array_diff( $script_asset['dependencies'], [ 'wp-dom-ready' ] ) ),
     71                    $dependencies['js']
     72                ),
    6773                $script_asset['version'],
    6874                true
     
    7480            // Localize script with REST API URL, nonce, and settings
    7581            wp_localize_script(
    76                 'cimo-editor',
     82                'cimo-script',
    7783                'cimoSettings',
    7884                [
     
    8187                    'webpQuality' => ! empty( $settings['webp_quality'] ) ? (int) $settings['webp_quality'] : 80,
    8288                    'maxImageDimension' => ! empty( $settings['max_image_dimension'] ) ? (int) $settings['max_image_dimension'] : 0,
     89                    'videoOptimizationEnabled' => isset( $settings['video_optimization_enabled'] ) ? (int) $settings['video_optimization_enabled'] : 1,
     90                    'videoQuality' => ! empty( $settings['video_quality'] ) ? (int) $settings['video_quality'] : 3,
     91                    'videoMaxResolution' => ! empty( $settings['video_max_resolution'] ) ? $settings['video_max_resolution'] : '',
     92                    'audioOptimizationEnabled' => isset( $settings['audio_optimization_enabled'] ) ? (int) $settings['audio_optimization_enabled'] : 1,
     93                    'audioQuality' => ! empty( $settings['audio_quality'] ) ? (int) $settings['audio_quality'] : 128,
    8394                ]
    8495            );
    8596
    86             // Enqueue the admin CSS file
    87             $style_asset = include $build_dir . 'admin.asset.php';
     97            // Enqueue the main admin CSS file
     98            $style_asset = include $build_dir . 'index-styles.asset.php';
    8899            wp_enqueue_style(
    89                 'cimo-admin',
    90                 $build_url . 'admin.css',
    91                 $style_asset['dependencies'],
     100                'cimo-script-styles',
     101                $build_url . 'index-styles.css',
     102                array_merge( $style_asset['dependencies'], $dependencies['css'] ),
    92103                $style_asset['version']
    93104            );
Note: See TracChangeset for help on using the changeset viewer.