(()=>{"use strict";var e={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var l in n)e.o(n,l)&&!e.o(t,l)&&Object.defineProperty(t,l,{enumerable:!0,get:n[l]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t);const n=window.React,l=window.wp.i18n,o=window.wp.element,a=window.wp.domReady;var r=e.n(a);const c=window.lodash,i=window.wp.components;function s(e){const[t,a]=(0,o.useState)(kbIconJson),r=(0,c.get)(t,["preferences","imagePref","prefix"],""),s=(0,c.get)(t,["height"],"");return(0,n.createElement)(o.Fragment,null,r?(0,n.createElement)(o.Fragment,null,(0,l.__)("Icon Set Prefix:","kadence-blocks-pro")," ",(0,n.createElement)("strong",null,r)):null,(0,n.createElement)((()=>{var e;const[r,c]=(0,o.useState)(!1),[s,d]=(0,o.useState)(!1),[p,m]=(0,o.useState)(),u=0===Object.keys(t).length,f=()=>c(!1);return(0,n.createElement)(o.Fragment,null,(0,n.createElement)(i.Button,{variant:"primary",className:"is-primary",style:{float:u?"left":"right"},onClick:()=>c(!0)},u?(0,n.createElement)(o.Fragment,null,(0,l.__)("Upload an Icon file","kadence-blocks-pro")):(0,l.__)("Replace Icon file","kadence-blocks-pro")),r&&(0,n.createElement)(i.Modal,{title:(0,l.__)("Upload Icon JSON file","kadence-blocks-pro"),onRequestClose:f},null!==(e=!1!==s)&&void 0!==e?e:(0,n.createElement)(i.Notice,{status:"error",onRemove:()=>d(!1)},(0,n.createElement)("p",null,s)),(0,l.__)("Upload the .json file from within the IcoMoon .zip file (Make sure each set has a unique prefix)","kadence-blocks-pro"),(0,n.createElement)("br",null),(0,n.createElement)("br",null),(0,l.__)("Need help?","kadence-blocks-pro")," ",(0,n.createElement)("a",{href:"https://www.kadencewp.com/kadence-blocks/documentation/pro-addon/custom-icons/",target:"_blank"},(0,l.__)("Visit the documentation here","kadence-blocks-pro")),(0,n.createElement)("br",null),(0,n.createElement)("br",null),(0,n.createElement)(i.FormFileUpload,{accept:"application/json",className:"is-primary",align:"center",onChange:e=>{m(e.target.files[0])}},(0,l.__)("Browse","kadence-blocks-pro")),p?null:(0,l.__)("Select a file","kadence-blocks-pro"),(0,n.createElement)("br",null),(0,n.createElement)("br",null),(0,n.createElement)(i.Button,{className:"is-secondary",onClick:f,text:(0,l.__)("Cancel","kadence-blocks-pro")}),"   ",(0,n.createElement)(i.Button,{className:"is-primary",disabled:!p,onClick:()=>function(e,t){const n=new FileReader;let o;n.onload=function(e){try{o=JSON.parse(e.target.result)}catch(e){return void t((0,l.__)("Invalid JSON file","kadence-blocks-pro"))}"object"==typeof o?a(o):t((0,l.__)("Invalid JSON file. File not an object.","kadence-blocks-pro"))},n.readAsText(e)}(p,d),text:(0,l.__)("Upload","kadence-blocks-pro")})))}),null),(0,n.createElement)("div",{style:{display:"done"}},(0,n.createElement)("input",{type:"hidden",name:"_kb_icon_json",value:JSON.stringify(t)})),(0,n.createElement)("div",null,(0,n.createElement)("ul",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(100px, 1fr))",gridGap:"20px",padding:"15px 15px 0",overflowY:"auto",maxHeight:"575px",listStyle:"none"}},(0,c.has)(t,["icons"])&&Object.keys(t.icons).map((e=>{const l=(0,c.get)(t,["icons",e,"width"],0),o=(0,c.get)(t,["icons",e,"height"],0);let a=0,r="0",i="0";l>o?(a=l-o,i=Math.floor(a/2)):l<o&&(a=o-l,r=Math.floor(a/2));const d=r+" "+i+" "+s+" "+(0!==l?l:s);return(0,n.createElement)("li",{className:"icon-item",style:{position:"relative",borderRadius:"3px",border:"1px solid #eee",overflow:"hidden",textAlign:"center",display:"flex",flexDirection:"column",padding:"10px 10px 0",alignItems:"center",color:"#333",justifyContent:"center"}},(0,n.createElement)("svg",{style:{display:"inline-block",verticalAlign:"middle"},viewBox:d,preserveAspectRatio:"xMinYMin meet",height:"24px",width:"24px",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},t.icons[e].icon.paths.map((e=>(0,n.createElement)("path",{d:e})))),(0,n.createElement)("p",{style:{fontSize:"10px",fontWeight:"normal",color:"#888"}},(0,c.get)(t,["icons",e,"properties","name"],"")))})))))}r()((()=>{(0,o.render)((0,n.createElement)(s,null),document.querySelector(".kadence_replace_json_file"))})),(this.kadence=this.kadence||{})["icon-upload"]=t})();