JezK
Edit File: dokan-intelligence.js
(()=>{"use strict";var e={n:t=>{var o=t&&t.__esModule?()=>t.default:()=>t;return e.d(o,{a:o}),o},d:(t,o)=>{for(var r in o)e.o(o,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:o[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.wp.domReady;var o=e.n(t);const r=window.wp.element,n=window.dokan.dokanUI,s=window.ReactJSXRuntime,l=({children:e,...t})=>(0,s.jsx)(n.Tooltip,{...t,contentClass:"dokan-layout",content:(0,s.jsx)("div",{className:"z-50 select-none rounded-[5px] max-w-[285px] bg-black px-3.5 py-1.5 text-xs text-white break-words",children:t?.content||e}),children:e}),a=window.dokan.components,i=window.wp.i18n,d=window.wp.apiFetch;var c=e.n(d);const p=async(e,t={})=>(await c()({path:"/dokan/v1/ai/generate",method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},data:{prompt:e,payload:t}})).response,u=(e,t)=>{try{let o=!1;const r=t=>(t.value=e,t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0})),!0),n=t=>{if(window.tinymce){const o=window.tinymce.get(t);if(o){o.setContent(e),o.fire("change"),o.fire("input");const n=document.getElementById(t);return n&&r(n),!0}}return!1},s=(e=>{const t=[`input[name="${e}"]`,`#${e}`,`textarea[name="${e}"]`,`[data-id="${e}"]`];for(const e of t){const t=document.querySelector(e);if(t)return t}return null})(t);return s&&(null!==s.closest(".wp-editor-wrap")?(o=n(t),!o&&s instanceof HTMLTextAreaElement&&(o=r(s))):(s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement)&&(o=r(s))),o}catch(e){return!1}},m=({prev:e,next:t,history:o,loading:r})=>!o||r?null:(0,s.jsxs)("div",{className:"flex gap-1 items-center",children:[(0,s.jsx)("svg",{onClick:e,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"h-4 w-4 cursor-pointer",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 19.5 8.25 12l7.5-7.5"})}),(0,s.jsx)("span",{className:"text-sm",children:o}),(0,s.jsx)("svg",{onClick:t,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"h-4 w-4 cursor-pointer",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m8.25 4.5 7.5 7.5-7.5 7.5"})})]}),b=({type:e="textarea",loading:t,element:o})=>t?"text"===e?(0,s.jsxs)("div",{className:"flex flex-col gap-2 animate-pulse",children:[(0,s.jsx)("div",{className:"h-4 w-1/2 bg-gray-200 rounded"}),(0,s.jsx)("div",{className:"h-4 w-full bg-gray-200 rounded"})]}):(0,s.jsxs)("div",{className:"flex flex-col gap-2 animate-pulse mb-3",children:[(0,s.jsx)("div",{className:"h-4 w-1/2 bg-gray-200 rounded"}),(0,s.jsx)("div",{className:"h-4 w-full bg-gray-200 rounded"}),(0,s.jsx)("div",{className:"h-4 w-3/4 bg-gray-200 rounded"}),(0,s.jsx)("div",{className:"h-4 w-full bg-gray-200 rounded"})]}):o,g=e=>{const t=v(e),{conflictingClassGroups:o,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{const o=e.split("-");return""===o[0]&&1!==o.length&&o.shift(),h(o,t)||x(e)},getConflictingClassGroupIds:(e,t)=>{const n=o[e]||[];return t&&r[e]?[...n,...r[e]]:n}}},h=(e,t)=>{if(0===e.length)return t.classGroupId;const o=e[0],r=t.nextPart.get(o),n=r?h(e.slice(1),r):void 0;if(n)return n;if(0===t.validators.length)return;const s=e.join("-");return t.validators.find(({validator:e})=>e(s))?.classGroupId},f=/^\[(.+)\]$/,x=e=>{if(f.test(e)){const t=f.exec(e)[1],o=t?.substring(0,t.indexOf(":"));if(o)return"arbitrary.."+o}},v=e=>{const{theme:t,prefix:o}=e,r={nextPart:new Map,validators:[]};return k(Object.entries(e.classGroups),o).forEach(([e,o])=>{w(o,r,e,t)}),r},w=(e,t,o,r)=>{e.forEach(e=>{if("string"!=typeof e)return"function"==typeof e?_(e)?void w(e(r),t,o,r):void t.validators.push({validator:e,classGroupId:o}):void Object.entries(e).forEach(([e,n])=>{w(n,y(t,e),o,r)});(""===e?t:y(t,e)).classGroupId=o})},y=(e,t)=>{let o=e;return t.split("-").forEach(e=>{o.nextPart.has(e)||o.nextPart.set(e,{nextPart:new Map,validators:[]}),o=o.nextPart.get(e)}),o},_=e=>e.isThemeGetter,k=(e,t)=>t?e.map(([e,o])=>[e,o.map(e=>"string"==typeof e?t+e:"object"==typeof e?Object.fromEntries(Object.entries(e).map(([e,o])=>[t+e,o])):e)]):e,j=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,o=new Map,r=new Map;const n=(n,s)=>{o.set(n,s),t++,t>e&&(t=0,r=o,o=new Map)};return{get(e){let t=o.get(e);return void 0!==t?t:void 0!==(t=r.get(e))?(n(e,t),t):void 0},set(e,t){o.has(e)?o.set(e,t):n(e,t)}}},C=e=>{const{separator:t,experimentalParseClassName:o}=e,r=1===t.length,n=t[0],s=t.length,l=e=>{const o=[];let l,a=0,i=0;for(let d=0;d<e.length;d++){let c=e[d];if(0===a){if(c===n&&(r||e.slice(d,d+s)===t)){o.push(e.slice(i,d)),i=d+s;continue}if("/"===c){l=d;continue}}"["===c?a++:"]"===c&&a--}const d=0===o.length?e:e.substring(i),c=d.startsWith("!");return{modifiers:o,hasImportantModifier:c,baseClassName:c?d.substring(1):d,maybePostfixModifierPosition:l&&l>i?l-i:void 0}};return o?e=>o({className:e,parseClassName:l}):l},N=e=>{if(e.length<=1)return e;const t=[];let o=[];return e.forEach(e=>{"["===e[0]?(t.push(...o.sort(),e),o=[]):o.push(e)}),t.push(...o.sort()),t},z=/\s+/;function S(){let e,t,o=0,r="";for(;o<arguments.length;)(e=arguments[o++])&&(t=M(e))&&(r&&(r+=" "),r+=t);return r}const M=e=>{if("string"==typeof e)return e;let t,o="";for(let r=0;r<e.length;r++)e[r]&&(t=M(e[r]))&&(o&&(o+=" "),o+=t);return o};function I(e,...t){let o,r,n,s=function(a){const i=t.reduce((e,t)=>t(e),e());return o=(e=>({cache:j(e.cacheSize),parseClassName:C(e),...g(e)}))(i),r=o.cache.get,n=o.cache.set,s=l,l(a)};function l(e){const t=r(e);if(t)return t;const s=((e,t)=>{const{parseClassName:o,getClassGroupId:r,getConflictingClassGroupIds:n}=t,s=[],l=e.trim().split(z);let a="";for(let e=l.length-1;e>=0;e-=1){const t=l[e],{modifiers:i,hasImportantModifier:d,baseClassName:c,maybePostfixModifierPosition:p}=o(t);let u=Boolean(p),m=r(u?c.substring(0,p):c);if(!m){if(!u){a=t+(a.length>0?" "+a:a);continue}if(m=r(c),!m){a=t+(a.length>0?" "+a:a);continue}u=!1}const b=N(i).join(":"),g=d?b+"!":b,h=g+m;if(s.includes(h))continue;s.push(h);const f=n(m,u);for(let e=0;e<f.length;++e){const t=f[e];s.push(g+t)}a=t+(a.length>0?" "+a:a)}return a})(e,o);return n(e,s),s}return function(){return s(S.apply(null,arguments))}}const B=e=>{const t=t=>t[e]||[];return t.isThemeGetter=!0,t},E=/^\[(?:([a-z-]+):)?(.+)\]$/i,T=/^\d+\/\d+$/,G=new Set(["px","full","screen"]),P=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,D=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,L=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,$=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,V=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,H=e=>R(e)||G.has(e)||T.test(e),O=e=>te(e,"length",oe),R=e=>Boolean(e)&&!Number.isNaN(Number(e)),q=e=>te(e,"number",R),A=e=>Boolean(e)&&Number.isInteger(Number(e)),W=e=>e.endsWith("%")&&R(e.slice(0,-1)),F=e=>E.test(e),Y=e=>P.test(e),Z=new Set(["length","size","percentage"]),J=e=>te(e,Z,re),U=e=>te(e,"position",re),X=new Set(["image","url"]),K=e=>te(e,X,se),Q=e=>te(e,"",ne),ee=()=>!0,te=(e,t,o)=>{const r=E.exec(e);return!!r&&(r[1]?"string"==typeof t?r[1]===t:t.has(r[1]):o(r[2]))},oe=e=>D.test(e)&&!L.test(e),re=()=>!1,ne=e=>$.test(e),se=e=>V.test(e),le=I((Symbol.toStringTag,()=>{const e=B("colors"),t=B("spacing"),o=B("blur"),r=B("brightness"),n=B("borderColor"),s=B("borderRadius"),l=B("borderSpacing"),a=B("borderWidth"),i=B("contrast"),d=B("grayscale"),c=B("hueRotate"),p=B("invert"),u=B("gap"),m=B("gradientColorStops"),b=B("gradientColorStopPositions"),g=B("inset"),h=B("margin"),f=B("opacity"),x=B("padding"),v=B("saturate"),w=B("scale"),y=B("sepia"),_=B("skew"),k=B("space"),j=B("translate"),C=()=>["auto",F,t],N=()=>[F,t],z=()=>["",H,O],S=()=>["auto",R,F],M=()=>["","0",F],I=()=>[R,F];return{cacheSize:500,separator:":",theme:{colors:[ee],spacing:[H,O],blur:["none","",Y,F],brightness:I(),borderColor:[e],borderRadius:["none","","full",Y,F],borderSpacing:N(),borderWidth:z(),contrast:I(),grayscale:M(),hueRotate:I(),invert:M(),gap:N(),gradientColorStops:[e],gradientColorStopPositions:[W,O],inset:C(),margin:C(),opacity:I(),padding:N(),saturate:I(),scale:I(),sepia:M(),skew:I(),space:N(),translate:N()},classGroups:{aspect:[{aspect:["auto","square","video",F]}],container:["container"],columns:[{columns:[Y]}],"break-after":[{"break-after":["auto","avoid","all","avoid-page","page","left","right","column"]}],"break-before":[{"break-before":["auto","avoid","all","avoid-page","page","left","right","column"]}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top",F]}],overflow:[{overflow:["auto","hidden","clip","visible","scroll"]}],"overflow-x":[{"overflow-x":["auto","hidden","clip","visible","scroll"]}],"overflow-y":[{"overflow-y":["auto","hidden","clip","visible","scroll"]}],overscroll:[{overscroll:["auto","contain","none"]}],"overscroll-x":[{"overscroll-x":["auto","contain","none"]}],"overscroll-y":[{"overscroll-y":["auto","contain","none"]}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[g]}],"inset-x":[{"inset-x":[g]}],"inset-y":[{"inset-y":[g]}],start:[{start:[g]}],end:[{end:[g]}],top:[{top:[g]}],right:[{right:[g]}],bottom:[{bottom:[g]}],left:[{left:[g]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",A,F]}],basis:[{basis:C()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",F]}],grow:[{grow:M()}],shrink:[{shrink:M()}],order:[{order:["first","last","none",A,F]}],"grid-cols":[{"grid-cols":[ee]}],"col-start-end":[{col:["auto",{span:["full",A,F]},F]}],"col-start":[{"col-start":S()}],"col-end":[{"col-end":S()}],"grid-rows":[{"grid-rows":[ee]}],"row-start-end":[{row:["auto",{span:[A,F]},F]}],"row-start":[{"row-start":S()}],"row-end":[{"row-end":S()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",F]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",F]}],gap:[{gap:[u]}],"gap-x":[{"gap-x":[u]}],"gap-y":[{"gap-y":[u]}],"justify-content":[{justify:["normal","start","end","center","between","around","evenly","stretch"]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal","start","end","center","between","around","evenly","stretch","baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":["start","end","center","between","around","evenly","stretch","baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[x]}],px:[{px:[x]}],py:[{py:[x]}],ps:[{ps:[x]}],pe:[{pe:[x]}],pt:[{pt:[x]}],pr:[{pr:[x]}],pb:[{pb:[x]}],pl:[{pl:[x]}],m:[{m:[h]}],mx:[{mx:[h]}],my:[{my:[h]}],ms:[{ms:[h]}],me:[{me:[h]}],mt:[{mt:[h]}],mr:[{mr:[h]}],mb:[{mb:[h]}],ml:[{ml:[h]}],"space-x":[{"space-x":[k]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[k]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",F,t]}],"min-w":[{"min-w":[F,t,"min","max","fit"]}],"max-w":[{"max-w":[F,t,"none","full","min","max","fit","prose",{screen:[Y]},Y]}],h:[{h:[F,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[F,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[F,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[F,t,"auto","min","max","fit"]}],"font-size":[{text:["base",Y,O]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",q]}],"font-family":[{font:[ee]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",F]}],"line-clamp":[{"line-clamp":["none",R,q]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",H,F]}],"list-image":[{"list-image":["none",F]}],"list-style-type":[{list:["none","disc","decimal",F]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[f]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[f]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:["solid","dashed","dotted","double","none","wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",H,O]}],"underline-offset":[{"underline-offset":["auto",H,F]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:N()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",F]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",F]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[f]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top",U]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",J]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},K]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[b]}],"gradient-via-pos":[{via:[b]}],"gradient-to-pos":[{to:[b]}],"gradient-from":[{from:[m]}],"gradient-via":[{via:[m]}],"gradient-to":[{to:[m]}],rounded:[{rounded:[s]}],"rounded-s":[{"rounded-s":[s]}],"rounded-e":[{"rounded-e":[s]}],"rounded-t":[{"rounded-t":[s]}],"rounded-r":[{"rounded-r":[s]}],"rounded-b":[{"rounded-b":[s]}],"rounded-l":[{"rounded-l":[s]}],"rounded-ss":[{"rounded-ss":[s]}],"rounded-se":[{"rounded-se":[s]}],"rounded-ee":[{"rounded-ee":[s]}],"rounded-es":[{"rounded-es":[s]}],"rounded-tl":[{"rounded-tl":[s]}],"rounded-tr":[{"rounded-tr":[s]}],"rounded-br":[{"rounded-br":[s]}],"rounded-bl":[{"rounded-bl":[s]}],"border-w":[{border:[a]}],"border-w-x":[{"border-x":[a]}],"border-w-y":[{"border-y":[a]}],"border-w-s":[{"border-s":[a]}],"border-w-e":[{"border-e":[a]}],"border-w-t":[{"border-t":[a]}],"border-w-r":[{"border-r":[a]}],"border-w-b":[{"border-b":[a]}],"border-w-l":[{"border-l":[a]}],"border-opacity":[{"border-opacity":[f]}],"border-style":[{border:["solid","dashed","dotted","double","none","hidden"]}],"divide-x":[{"divide-x":[a]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[a]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[f]}],"divide-style":[{divide:["solid","dashed","dotted","double","none"]}],"border-color":[{border:[n]}],"border-color-x":[{"border-x":[n]}],"border-color-y":[{"border-y":[n]}],"border-color-s":[{"border-s":[n]}],"border-color-e":[{"border-e":[n]}],"border-color-t":[{"border-t":[n]}],"border-color-r":[{"border-r":[n]}],"border-color-b":[{"border-b":[n]}],"border-color-l":[{"border-l":[n]}],"divide-color":[{divide:[n]}],"outline-style":[{outline:["","solid","dashed","dotted","double","none"]}],"outline-offset":[{"outline-offset":[H,F]}],"outline-w":[{outline:[H,O]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:z()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[f]}],"ring-offset-w":[{"ring-offset":[H,O]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",Y,Q]}],"shadow-color":[{shadow:[ee]}],opacity:[{opacity:[f]}],"mix-blend":[{"mix-blend":["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity","plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"]}],filter:[{filter:["","none"]}],blur:[{blur:[o]}],brightness:[{brightness:[r]}],contrast:[{contrast:[i]}],"drop-shadow":[{"drop-shadow":["","none",Y,F]}],grayscale:[{grayscale:[d]}],"hue-rotate":[{"hue-rotate":[c]}],invert:[{invert:[p]}],saturate:[{saturate:[v]}],sepia:[{sepia:[y]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[o]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[i]}],"backdrop-grayscale":[{"backdrop-grayscale":[d]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[c]}],"backdrop-invert":[{"backdrop-invert":[p]}],"backdrop-opacity":[{"backdrop-opacity":[f]}],"backdrop-saturate":[{"backdrop-saturate":[v]}],"backdrop-sepia":[{"backdrop-sepia":[y]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[l]}],"border-spacing-x":[{"border-spacing-x":[l]}],"border-spacing-y":[{"border-spacing-y":[l]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",F]}],duration:[{duration:I()}],ease:[{ease:["linear","in","out","in-out",F]}],delay:[{delay:I()}],animate:[{animate:["none","spin","ping","pulse","bounce",F]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[w]}],"scale-x":[{"scale-x":[w]}],"scale-y":[{"scale-y":[w]}],rotate:[{rotate:[A,F]}],"translate-x":[{"translate-x":[j]}],"translate-y":[{"translate-y":[j]}],"skew-x":[{"skew-x":[_]}],"skew-y":[{"skew-y":[_]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",F]}],accent:[{accent:["auto",e]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",F]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":N()}],"scroll-mx":[{"scroll-mx":N()}],"scroll-my":[{"scroll-my":N()}],"scroll-ms":[{"scroll-ms":N()}],"scroll-me":[{"scroll-me":N()}],"scroll-mt":[{"scroll-mt":N()}],"scroll-mr":[{"scroll-mr":N()}],"scroll-mb":[{"scroll-mb":N()}],"scroll-ml":[{"scroll-ml":N()}],"scroll-p":[{"scroll-p":N()}],"scroll-px":[{"scroll-px":N()}],"scroll-py":[{"scroll-py":N()}],"scroll-ps":[{"scroll-ps":N()}],"scroll-pe":[{"scroll-pe":N()}],"scroll-pt":[{"scroll-pt":N()}],"scroll-pr":[{"scroll-pr":N()}],"scroll-pb":[{"scroll-pb":N()}],"scroll-pl":[{"scroll-pl":N()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",F]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[H,O,q]}],stroke:[{stroke:[e,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}})),ae={post_title:0,post_excerpt:0,post_content:0},ie={post_title:[],post_excerpt:[],post_content:[]},de=({className:e,value:t,onChange:o})=>{const[d,c]=(0,r.useState)(!1),[g,h]=(0,r.useState)({post_title:!1,post_excerpt:!1,post_content:!1}),[f,x]=(0,r.useState)(!1),[v,w]=(0,r.useState)(""),[y,_]=(0,r.useState)(""),[k,j]=(0,r.useState)(!1),[C,N]=(0,r.useState)(ie),[z,S]=(0,r.useState)(!1),[M,I]=(0,r.useState)(ae),[B,E]=(0,r.useState)(!1),T=()=>{I(ae)},G=(e,t)=>{const o=document.getElementById(e),r=o.contentDocument||o.contentWindow?.document;return r?.querySelector(`[data-id="${t}"]`)||document.querySelector(`#${t}`)},P=()=>{w(""),_(""),j(!1),N(ie),T()},D=()=>{c(!1),P()},L=async()=>{if(_(""),v.trim()){E(!0);try{const e=await p(v,{json_format:"true"});e?N({post_title:[e.title],post_excerpt:[e.short_description],post_content:[e.long_description]}):_((0,i.__)("No content generated, please try again.","dokan-lite")),T()}catch(e){_(e.message)}finally{E(!1)}}else _((0,i.__)("Please enter a prompt.","dokan"))},$=e=>g[e]||f,V=async e=>{_("");let t=C[e][M[e]];if(t?.trim()||(t={post_excerpt:"generate short description",post_content:"generate long description"}[e]||""),"post_title"!==e&&(t=`${t} \n\n product title is ${C.post_title[M.post_title]}`),t?.trim()){E(!0),h(t=>({...t,[e]:!0}));try{const o=await p(t,{field:e});N(t=>({...t,[e]:[o,...t[e]]})),I(t=>({...t,[e]:0}))}catch(e){_(e.message)}finally{E(!1),h(t=>({...t,[e]:!1}))}}else _((0,i.__)("Please enter a prompt.","dokan-lite"))},H=(e,t)=>{N(o=>({...o,[t]:C[t].map((o,r)=>r===M[t]?e:o)}))},O=e=>{0!==M[e]&&I(t=>({...t,[e]:t[e]-1}))},R=e=>{M[e]<C[e].length-1&&I(t=>({...t,[e]:t[e]+1}))},q=e=>{const t=C[e].length;return 0===t?"":`${M[e]+1}/${t}`},A=e=>C[e][M[e]],W=(e=!1)=>{const t=C.post_title[M.post_title],r=C.post_excerpt[M.post_excerpt],n=C.post_content[M.post_content];return o?(o({name:t,short_description:r,description:n}),void D()):document.getElementById("post_title").value&&!e?(c(!1),void j(!0)):void(z?(u(t,"post_title"),u(r,"post_excerpt"),u(n,"post_content"),D()):_((0,i.__)("Invalid input data","dokan")))};return(0,r.useEffect)(()=>{const e=C.post_title.length>0||C.post_content.length>0||C.post_excerpt.length>0;S(e)},[C.post_title,C.post_content,C.post_excerpt]),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("button",{type:"button",className:le("dokan-btn p-0 !min-h-[max-content]",e),onClick:e=>{if(e.preventDefault(),e.stopPropagation(),c(!0),t){N(t);const e=t.post_title.length>0||t.post_content.length>0||t.post_excerpt.length>0;return S(e),w(t.post_title?.[0]||""),void T()}const o=document.querySelector("#post_title"),r=G("post_excerpt_ifr","post_excerpt"),n=document.querySelector("#post_excerpt"),s=G("post_content_ifr","post_content"),l=document.querySelector("#post_content"),a={...ie};(n.value||l.value)&&(a.post_title=[o.value||""],w(o.value)),r?.innerHTML&&n.value&&(a.post_excerpt=[r.innerHTML]),s?.innerHTML&&l.value&&(a.post_content=[s.innerHTML]),N(a),T()},children:(0,s.jsx)(l,{content:(0,i.__)("AI Assistant","dokan-lite"),children:(0,s.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,s.jsx)("path",{d:"M18.0064 11.0266C18.2625 9.98897 19.7376 9.98897 19.9938 11.0266V11.0266C21.0872 15.4557 24.5455 18.9139 28.9747 20.0073V20.0073C30.0123 20.2634 30.0123 21.7386 28.9747 21.9947V21.9947C24.5455 23.0881 21.0872 26.5463 19.9938 30.9754V30.9754C19.7376 32.0131 18.2625 32.0131 18.0064 30.9754V30.9754C16.9129 26.5463 13.4546 23.0881 9.02549 21.9947V21.9947C7.98784 21.7386 7.98784 20.2634 9.02549 20.0073V20.0073C13.4546 18.9139 16.9129 15.4557 18.0064 11.0266V11.0266Z",fill:"white"}),(0,s.jsx)("path",{d:"M28.9309 6.62922C29.0345 6.20923 29.6316 6.20923 29.7353 6.62922V6.62922C30.1779 8.42196 31.5777 9.82171 33.3704 10.2643V10.2643C33.7904 10.3679 33.7904 10.965 33.3704 11.0687V11.0687C31.5777 11.5113 30.1779 12.911 29.7353 14.7037V14.7037C29.6316 15.1237 29.0345 15.1237 28.9309 14.7037V14.7037C28.4883 12.911 27.0885 11.5113 25.2957 11.0687V11.0687C24.8757 10.965 24.8757 10.3679 25.2957 10.2643V10.2643C27.0885 9.82171 28.4883 8.42196 28.9309 6.62922V6.62922Z",fill:"white"})]})})}),(0,s.jsx)(a.DokanModal,{namespace:"dokan-ai-new-prompt-modal",isOpen:d,onClose:D,onConfirm:()=>{},modalClassName:"max-w-2xl",isDismissible:!1,dialogHeader:(0,s.jsxs)("div",{className:"p-4 font-semibold border-b flex justify-between items-center",children:[(0,s.jsx)("div",{children:(0,i.__)("Craft your product information","dokan-lite")}),z&&(0,s.jsxs)(a.DokanButton,{variant:"secondary",onClick:P,disabled:B,className:"flex gap-2 items-center",children:[(0,s.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"h-4 w-4",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0 3.181 3.183a8.25 8.25 0 0 0 13.803-3.7M4.031 9.865a8.25 8.25 0 0 1 13.803-3.7l3.181 3.182m0-4.991v4.99"})}),(0,i.__)("Start Over","dokan-lite")]})]}),dialogContent:(0,s.jsxs)(s.Fragment,{children:[y&&(0,s.jsx)(a.DokanAlert,{label:(0,i.__)("Error","dokan-lite"),variant:"danger",className:"mb-4 [&_*_p]:m-0",children:y}),z?(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,s.jsx)("div",{className:"font-semibold text-gray-800",children:(0,i.__)("Title:","dokan-lite")}),(0,s.jsx)(m,{loading:$("post_title"),history:q("post_title"),prev:()=>O("post_title"),next:()=>R("post_title")})]}),(0,s.jsx)("div",{className:"mb-3",children:(0,s.jsx)(b,{type:"text",loading:$("post_title"),element:(0,s.jsx)(n.SimpleInput,{className:"focus:outline-none",onChange:e=>{H(e.target.value,"post_title")},value:A("post_title")})})}),(0,s.jsx)(a.DokanButton,{variant:"secondary",onClick:()=>V("post_title"),disabled:$("post_title"),children:(0,i.__)("Refine","dokan-lite")}),(0,s.jsxs)("div",{className:"my-4",children:[(0,s.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,s.jsx)("div",{className:"font-semibold text-gray-800",children:(0,i.__)("Short Description:","dokan-lite")}),(0,s.jsx)(m,{loading:$("post_excerpt"),history:q("post_excerpt"),prev:()=>O("post_excerpt"),next:()=>R("post_excerpt")})]}),(0,s.jsx)(b,{loading:$("post_excerpt"),element:(0,s.jsx)("div",{className:"mb-3 focus:outline-dokan-btn-border h-36 border rounded p-2.5 overflow-auto",contentEditable:!0,onBlur:e=>{H(e.target.innerHTML,"post_excerpt")},dangerouslySetInnerHTML:{__html:A("post_excerpt")}})}),(0,s.jsx)(a.DokanButton,{variant:"secondary",onClick:()=>V("post_excerpt"),disabled:$("post_excerpt"),children:(0,i.__)("Refine","dokan-lite")})]}),(0,s.jsxs)("div",{className:"mt-4",children:[(0,s.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,s.jsx)("div",{className:"font-semibold text-gray-800",children:(0,i.__)("Long Description:","dokan-lite")}),(0,s.jsx)(m,{loading:$("post_content"),history:q("post_content"),prev:()=>O("post_content"),next:()=>R("post_content")})]}),(0,s.jsx)(b,{loading:$("post_content"),element:(0,s.jsx)("div",{className:"mb-3 h-48 focus:outline-dokan-btn-border border rounded p-2.5 overflow-auto",contentEditable:!0,onBlur:e=>{H(e.target.innerHTML,"post_content")},dangerouslySetInnerHTML:{__html:A("post_content")}})}),(0,s.jsx)(a.DokanButton,{variant:"secondary",onClick:()=>V("post_content"),disabled:$("post_content"),children:(0,i.__)("Refine","dokan-lite")})]}),(0,s.jsxs)("p",{className:"text-sm mt-4 mb-3",children:[(0,i.__)("** If you think the outcome doesn’t match your choice then you can","dokan-lite"),(0,s.jsx)("span",{tabIndex:0,role:"button",onClick:async()=>{x(!0),await L(),x(!1)},className:"text-dokan-link mx-1 underline",children:(0,i.__)("regenerate all again.","dokan-lite")})]})]}):(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm mb-3",children:(0,i.__)("You can generate your product title, short description, long description all at once with this prompt. Type your prompt below","dokan-lite")}),(0,s.jsx)(n.TextArea,{disabled:B,className:"min-h-48",onChange:e=>w(e.target.value),input:{id:"dokan-ai-prompt",value:v,placeholder:(0,i.__)("Enter prompt","dokan-lite")}})]})]}),dialogFooter:(0,s.jsxs)("div",{className:"p-4 border-t flex gap-4 justify-end",children:[(0,s.jsx)(a.DokanButton,{variant:"secondary",disabled:B,onClick:D,children:(0,i.__)("Cancel","dokan-lite")}),z?(0,s.jsx)(a.DokanButton,{disabled:B,onClick:()=>W(),children:(0,i.__)("Insert","dokan-lite")}):(0,s.jsx)(a.DokanButton,{disabled:B||!v,onClick:L,children:B?(0,i.__)("Generating…","dokan-lite"):(0,i.__)("Generate","dokan-lite")})]})}),(0,s.jsx)(a.DokanModal,{namespace:"dokan-ai-new-prompt-modal",isOpen:k,onClose:()=>j(!1),onConfirm:()=>{},modalClassName:"max-w-md",isDismissible:!1,dialogHeader:!1,dialogContent:(0,s.jsxs)("div",{className:"text-center p-5",children:[(0,s.jsx)("div",{className:"text-xl font-semibold mb-4",children:(0,i.__)("Insert Generated Information?","dokan-lite")}),(0,s.jsx)("p",{children:(0,i.__)("Are you sure you want to insert the generated information? If you insert then your current product information will be updated with the generated content.","dokan-lite")}),(0,s.jsxs)("div",{className:"mt-4 flex gap-4 justify-center",children:[(0,s.jsx)(a.DokanButton,{variant:"secondary",onClick:()=>j(!1),children:(0,i.__)("Cancel","dokan-lite")}),(0,s.jsx)(a.DokanButton,{onClick:()=>W(!0),children:(0,i.__)("Yes, Insert","dokan-lite")})]})]}),dialogFooter:!1})]})};o()(()=>{const e=document.getElementById("ai-prompt-app");e&&(0,r.createRoot)(e).render((0,s.jsx)(de,{}))})})();