diff --git a/build/editor.asset.php b/build/editor.asset.php index de47c7b..d91105d 100644 --- a/build/editor.asset.php +++ b/build/editor.asset.php @@ -1 +1 @@ - array('lodash', 'react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-hooks', 'wp-i18n'), 'version' => '0e5a9ff452cc319a25fe'); + array('lodash', 'react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-hooks', 'wp-i18n'), 'version' => 'a127d9515a556a21769e'); diff --git a/build/editor.js b/build/editor.js index 22a26a9..26df571 100644 --- a/build/editor.js +++ b/build/editor.js @@ -1,7 +1,7 @@ -(()=>{"use strict";var e,t={558:(e,t,n)=>{var r={};n.r(r),n.d(r,{getSettingsPageURL:()=>p,isConnected:()=>u});var s={};n.r(s),n.d(s,{getHighlightBlocks:()=>g});var i={};n.r(i),n.d(i,{removeHighlightBlocks:()=>f,setHighlightBlocks:()=>m});var l={};n.r(l),n.d(l,{close:()=>K,open:()=>V,requestAI:()=>ie,reset:()=>le,setContext:()=>Y,setError:()=>se,setInput:()=>J,setInsertionPlace:()=>ee,setLoading:()=>ne,setResponse:()=>re,setScreen:()=>te,toggle:()=>X});var o={};n.r(o),n.d(o,{getContext:()=>ce,getError:()=>ge,getInput:()=>ae,getInsertionPlace:()=>ue,getLoading:()=>he,getResponse:()=>de,getScreen:()=>pe,isOpen:()=>oe});const{connected:a,settingsPageURL:c}=window.mindData;function u(){return"1"===a}function p(){return c}const h=window.wp.data,d=(0,h.createReduxStore)("mind",{selectors:r,reducer:e=>e});(0,h.register)(d);function g(e){return e?.highlightBlocks||[]}function m(e){return{type:"SET_HIGHLIGHT_BLOCKS",highlightBlocks:e}}function f(e){return{type:"REMOVE_HIGHLIGHT_BLOCKS",removeBlocks:e}}const k=(0,h.createReduxStore)("mind/blocks",{reducer:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{highlightBlocks:[]},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};switch(t.type){case"SET_HIGHLIGHT_BLOCKS":if(t.highlightBlocks&&t.highlightBlocks.length)return{...e,highlightBlocks:[...e.highlightBlocks,...t.highlightBlocks]};break;case"REMOVE_HIGHLIGHT_BLOCKS":if(e.highlightBlocks&&e.highlightBlocks.length&&t.removeBlocks&&t.removeBlocks.length)return{...e,highlightBlocks:e.highlightBlocks.filter((e=>!t.removeBlocks.includes(e)))}}return e},selectors:s,actions:i});(0,h.register)(k);let b={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};function w(e){b=e}const x=/[&<>"']/,_=new RegExp(x.source,"g"),E=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,y=new RegExp(E.source,"g"),v={"&":"&","<":"<",">":">",'"':""","'":"'"},S=e=>v[e];function O(e,t){if(t){if(x.test(e))return e.replace(_,S)}else if(E.test(e))return e.replace(y,S);return e}const $=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,C=/(^|[^\[])\^/g;function I(e,t){e="string"==typeof e?e:e.source,t=t||"";const n={replace:(t,r)=>(r=(r="object"==typeof r&&"source"in r?r.source:r).replace(C,"$1"),e=e.replace(t,r),n),getRegex:()=>new RegExp(e,t)};return n}function T(e){try{e=encodeURI(e).replace(/%25/g,"%")}catch(e){return null}return e}const R={exec:()=>null};function M(e,t){const n=e.replace(/\|/g,((e,t,n)=>{let r=!1,s=t;for(;--s>=0&&"\\"===n[s];)r=!r;return r?"|":" |"})).split(/ \|/);let r=0;if(n[0].trim()||n.shift(),n.length>0&&!n[n.length-1].trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length0)return{type:"space",raw:t[0]}}code(e){const t=this.rules.block.code.exec(e);if(t){const e=t[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:P(e,"\n")}}}fences(e){const t=this.rules.block.fences.exec(e);if(t){const e=t[0],n=function(e,t){const n=e.match(/^(\s+)(?:```)/);if(null===n)return t;const r=n[1];return t.split("\n").map((e=>{const t=e.match(/^\s+/);if(null===t)return e;const[n]=t;return n.length>=r.length?e.slice(r.length):e})).join("\n")}(e,t[3]||"");return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline._escapes,"$1"):t[2],text:n}}}heading(e){const t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(/#$/.test(e)){const t=P(e,"#");this.options.pedantic?e=t.trim():t&&!/ $/.test(t)||(e=t.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){const t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:t[0]}}blockquote(e){const t=this.rules.block.blockquote.exec(e);if(t){const e=P(t[0].replace(/^ *>[ \t]?/gm,""),"\n"),n=this.lexer.state.top;this.lexer.state.top=!0;const r=this.lexer.blockTokens(e);return this.lexer.state.top=n,{type:"blockquote",raw:t[0],tokens:r,text:e}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim();const r=n.length>1,s={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");const i=new RegExp(`^( {0,3}${n})((?:[\t ][^\\n]*)?(?:\\n|$))`);let l="",o="",a=!1;for(;e;){let n=!1;if(!(t=i.exec(e)))break;if(this.rules.block.hr.test(e))break;l=t[0],e=e.substring(l.length);let r=t[2].split("\n",1)[0].replace(/^\t+/,(e=>" ".repeat(3*e.length))),c=e.split("\n",1)[0],u=0;this.options.pedantic?(u=2,o=r.trimStart()):(u=t[2].search(/[^ ]/),u=u>4?1:u,o=r.slice(u),u+=t[1].length);let p=!1;if(!r&&/^ *$/.test(c)&&(l+=c+"\n",e=e.substring(c.length+1),n=!0),!n){const t=new RegExp(`^ {0,${Math.min(3,u-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),n=new RegExp(`^ {0,${Math.min(3,u-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),s=new RegExp(`^ {0,${Math.min(3,u-1)}}(?:\`\`\`|~~~)`),i=new RegExp(`^ {0,${Math.min(3,u-1)}}#`);for(;e;){const a=e.split("\n",1)[0];if(c=a,this.options.pedantic&&(c=c.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),s.test(c))break;if(i.test(c))break;if(t.test(c))break;if(n.test(e))break;if(c.search(/[^ ]/)>=u||!c.trim())o+="\n"+c.slice(u);else{if(p)break;if(r.search(/[^ ]/)>=4)break;if(s.test(r))break;if(i.test(r))break;if(n.test(r))break;o+="\n"+c}p||c.trim()||(p=!0),l+=a+"\n",e=e.substring(a.length+1),r=c.slice(u)}}s.loose||(a?s.loose=!0:/\n *\n *$/.test(l)&&(a=!0));let h,d=null;this.options.gfm&&(d=/^\[[ xX]\] /.exec(o),d&&(h="[ ] "!==d[0],o=o.replace(/^\[[ xX]\] +/,""))),s.items.push({type:"list_item",raw:l,task:!!d,checked:h,loose:!1,text:o,tokens:[]}),s.raw+=l}s.items[s.items.length-1].raw=l.trimEnd(),s.items[s.items.length-1].text=o.trimEnd(),s.raw=s.raw.trimEnd();for(let e=0;e"space"===e.type)),n=t.length>0&&t.some((e=>/\n.*\n/.test(e.raw)));s.loose=n}if(s.loose)for(let e=0;e$/,"$1").replace(this.rules.inline._escapes,"$1"):"",r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline._escapes,"$1"):t[3];return{type:"def",tag:e,raw:t[0],href:n,title:r}}}table(e){const t=this.rules.block.table.exec(e);if(t){if(!/[:|]/.test(t[2]))return;const e={type:"table",raw:t[0],header:M(t[1]).map((e=>({text:e,tokens:[]}))),align:t[2].replace(/^\||\| *$/g,"").split("|"),rows:t[3]&&t[3].trim()?t[3].replace(/\n[ \t]*$/,"").split("\n"):[]};if(e.header.length===e.align.length){let t,n,r,s,i=e.align.length;for(t=0;t({text:e,tokens:[]})));for(i=e.header.length,n=0;n/i.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){const t=this.rules.inline.link.exec(e);if(t){const e=t[2].trim();if(!this.options.pedantic&&/^$/.test(e))return;const t=P(e.slice(0,-1),"\\");if((e.length-t.length)%2==0)return}else{const e=function(e,t){if(-1===e.indexOf(t[1]))return-1;let n=0;for(let r=0;r-1){const n=(0===t[0].indexOf("!")?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=""}}let n=t[2],r="";if(this.options.pedantic){const e=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):"";return n=n.trim(),/^$/.test(e)?n.slice(1):n.slice(1,-1)),z(t,{href:n?n.replace(this.rules.inline._escapes,"$1"):n,title:r?r.replace(this.rules.inline._escapes,"$1"):r},t[0],this.lexer)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=(n[2]||n[1]).replace(/\s+/g," ");if(e=t[e.toLowerCase()],!e){const e=n[0].charAt(0);return{type:"text",raw:e,text:e}}return z(n,e,n[0],this.lexer)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrong.lDelim.exec(e);if(r&&(!r[3]||!n.match(/[\p{L}\p{N}]/u))&&(!r[1]&&!r[2]||!n||this.rules.inline.punctuation.exec(n))){const n=[...r[0]].length-1;let s,i,l=n,o=0;const a="*"===r[0][0]?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(a.lastIndex=0,t=t.slice(-1*e.length+n);null!=(r=a.exec(t));){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s)continue;if(i=[...s].length,r[3]||r[4]){l+=i;continue}if((r[5]||r[6])&&n%3&&!((n+i)%3)){o+=i;continue}if(l-=i,l>0)continue;i=Math.min(i,i+l+o);const t=[...r[0]][0].length,a=e.slice(0,n+r.index+t+i);if(Math.min(n,i)%2){const e=a.slice(1,-1);return{type:"em",raw:a,text:e,tokens:this.lexer.inlineTokens(e)}}const c=a.slice(2,-2);return{type:"strong",raw:a,text:c,tokens:this.lexer.inlineTokens(c)}}}}codespan(e){const t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(/\n/g," ");const n=/[^ ]/.test(e),r=/^ /.test(e)&&/ $/.test(e);return n&&r&&(e=e.substring(1,e.length-1)),e=O(e,!0),{type:"codespan",raw:t[0],text:e}}}br(e){const t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){const t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){const t=this.rules.inline.autolink.exec(e);if(t){let e,n;return"@"===t[2]?(e=O(t[1]),n="mailto:"+e):(e=O(t[1]),n=e),{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if("@"===t[2])e=O(t[0]),n="mailto:"+e;else{let r;do{r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])[0]}while(r!==t[0]);e=O(t[0]),n="www."===t[1]?"http://"+t[0]:t[0]}return{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(e){const t=this.rules.inline.text.exec(e);if(t){let e;return e=this.lexer.state.inRawBlock?t[0]:O(t[0]),{type:"text",raw:t[0],text:e}}}}const j={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr:/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,html:"^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|\\n*|$)|\\n*|$)|)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",def:/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,table:R,lheading:/^(?!bull )((?:.|\n(?!\s*?\n|bull ))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/,_label:/(?!\s*\])(?:\\.|[^\[\]\\])+/,_title:/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/};j.def=I(j.def).replace("label",j._label).replace("title",j._title).getRegex(),j.bullet=/(?:[*+-]|\d{1,9}[.)])/,j.listItemStart=I(/^( *)(bull) */).replace("bull",j.bullet).getRegex(),j.list=I(j.list).replace(/bull/g,j.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+j.def.source+")").getRegex(),j._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",j._comment=/|$)/,j.html=I(j.html,"i").replace("comment",j._comment).replace("tag",j._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),j.lheading=I(j.lheading).replace(/bull/g,j.bullet).getRegex(),j.paragraph=I(j._paragraph).replace("hr",j.hr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",j._tag).getRegex(),j.blockquote=I(j.blockquote).replace("paragraph",j.paragraph).getRegex(),j.normal={...j},j.gfm={...j.normal,table:"^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},j.gfm.table=I(j.gfm.table).replace("hr",j.hr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",j._tag).getRegex(),j.gfm.paragraph=I(j._paragraph).replace("hr",j.hr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",j.gfm.table).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",j._tag).getRegex(),j.pedantic={...j.normal,html:I("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+? *(?:\\n{2,}|\\s*$)|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",j._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:R,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:I(j.normal._paragraph).replace("hr",j.hr).replace("heading"," *#{1,6} *[^\n]").replace("lheading",j.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const L={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:R,tag:"^comment|^|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^|^",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(ref)\]/,nolink:/^!?\[(ref)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",emStrong:{lDelim:/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,rDelimAst:/^[^_*]*?__[^_*]*?\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\*)[punct](\*+)(?=[\s]|$)|[^punct\s](\*+)(?!\*)(?=[punct\s]|$)|(?!\*)[punct\s](\*+)(?=[^punct\s])|[\s](\*+)(?!\*)(?=[punct])|(?!\*)[punct](\*+)(?!\*)(?=[punct])|[^punct\s](\*+)(?=[^punct\s])/,rDelimUnd:/^[^_*]*?\*\*[^_*]*?_[^_*]*?(?=\*\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\s]|$)|[^punct\s](_+)(?!_)(?=[punct\s]|$)|(?!_)[punct\s](_+)(?=[^punct\s])|[\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:R,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\`^|~"};L.punctuation=I(L.punctuation,"u").replace(/punctuation/g,L._punctuation).getRegex(),L.blockSkip=/\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g,L.anyPunctuation=/\\[punct]/g,L._escapes=/\\([punct])/g,L._comment=I(j._comment).replace("(?:--\x3e|$)","--\x3e").getRegex(),L.emStrong.lDelim=I(L.emStrong.lDelim,"u").replace(/punct/g,L._punctuation).getRegex(),L.emStrong.rDelimAst=I(L.emStrong.rDelimAst,"gu").replace(/punct/g,L._punctuation).getRegex(),L.emStrong.rDelimUnd=I(L.emStrong.rDelimUnd,"gu").replace(/punct/g,L._punctuation).getRegex(),L.anyPunctuation=I(L.anyPunctuation,"gu").replace(/punct/g,L._punctuation).getRegex(),L._escapes=I(L._escapes,"gu").replace(/punct/g,L._punctuation).getRegex(),L._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,L._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/,L.autolink=I(L.autolink).replace("scheme",L._scheme).replace("email",L._email).getRegex(),L._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,L.tag=I(L.tag).replace("comment",L._comment).replace("attribute",L._attribute).getRegex(),L._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,L._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,L._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,L.link=I(L.link).replace("label",L._label).replace("href",L._href).replace("title",L._title).getRegex(),L.reflink=I(L.reflink).replace("label",L._label).replace("ref",j._label).getRegex(),L.nolink=I(L.nolink).replace("ref",j._label).getRegex(),L.reflinkSearch=I(L.reflinkSearch,"g").replace("reflink",L.reflink).replace("nolink",L.nolink).getRegex(),L.normal={...L},L.pedantic={...L.normal,strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:I(/^!?\[(label)\]\((.*?)\)/).replace("label",L._label).getRegex(),reflink:I(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",L._label).getRegex()},L.gfm={...L.normal,escape:I(L.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\t+" ".repeat(n.length)));e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some((r=>!!(n=r.call({lexer:this},e,t))&&(e=e.substring(n.raw.length),t.push(n),!0)))))if(n=this.tokenizer.space(e))e=e.substring(n.raw.length),1===n.raw.length&&t.length>0?t[t.length-1].raw+="\n":t.push(n);else if(n=this.tokenizer.code(e))e=e.substring(n.raw.length),r=t[t.length-1],!r||"paragraph"!==r.type&&"text"!==r.type?t.push(n):(r.raw+="\n"+n.raw,r.text+="\n"+n.text,this.inlineQueue[this.inlineQueue.length-1].src=r.text);else if(n=this.tokenizer.fences(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.heading(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.hr(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.blockquote(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.list(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.html(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.def(e))e=e.substring(n.raw.length),r=t[t.length-1],!r||"paragraph"!==r.type&&"text"!==r.type?this.tokens.links[n.tag]||(this.tokens.links[n.tag]={href:n.href,title:n.title}):(r.raw+="\n"+n.raw,r.text+="\n"+n.raw,this.inlineQueue[this.inlineQueue.length-1].src=r.text);else if(n=this.tokenizer.table(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.lheading(e))e=e.substring(n.raw.length),t.push(n);else{if(s=e,this.options.extensions&&this.options.extensions.startBlock){let t=1/0;const n=e.slice(1);let r;this.options.extensions.startBlock.forEach((e=>{r=e.call({lexer:this},n),"number"==typeof r&&r>=0&&(t=Math.min(t,r))})),t<1/0&&t>=0&&(s=e.substring(0,t+1))}if(this.state.top&&(n=this.tokenizer.paragraph(s)))r=t[t.length-1],i&&"paragraph"===r.type?(r.raw+="\n"+n.raw,r.text+="\n"+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=r.text):t.push(n),i=s.length!==e.length,e=e.substring(n.raw.length);else if(n=this.tokenizer.text(e))e=e.substring(n.raw.length),r=t[t.length-1],r&&"text"===r.type?(r.raw+="\n"+n.raw,r.text+="\n"+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=r.text):t.push(n);else if(e){const t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n,r,s,i,l,o,a=e;if(this.tokens.links){const e=Object.keys(this.tokens.links);if(e.length>0)for(;null!=(i=this.tokenizer.rules.inline.reflinkSearch.exec(a));)e.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(a=a.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+a.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(i=this.tokenizer.rules.inline.blockSkip.exec(a));)a=a.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+a.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;null!=(i=this.tokenizer.rules.inline.anyPunctuation.exec(a));)a=a.slice(0,i.index)+"++"+a.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;e;)if(l||(o=""),l=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some((r=>!!(n=r.call({lexer:this},e,t))&&(e=e.substring(n.raw.length),t.push(n),!0)))))if(n=this.tokenizer.escape(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.tag(e))e=e.substring(n.raw.length),r=t[t.length-1],r&&"text"===n.type&&"text"===r.type?(r.raw+=n.raw,r.text+=n.text):t.push(n);else if(n=this.tokenizer.link(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.reflink(e,this.tokens.links))e=e.substring(n.raw.length),r=t[t.length-1],r&&"text"===n.type&&"text"===r.type?(r.raw+=n.raw,r.text+=n.text):t.push(n);else if(n=this.tokenizer.emStrong(e,a,o))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.codespan(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.br(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.del(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.autolink(e))e=e.substring(n.raw.length),t.push(n);else if(this.state.inLink||!(n=this.tokenizer.url(e))){if(s=e,this.options.extensions&&this.options.extensions.startInline){let t=1/0;const n=e.slice(1);let r;this.options.extensions.startInline.forEach((e=>{r=e.call({lexer:this},n),"number"==typeof r&&r>=0&&(t=Math.min(t,r))})),t<1/0&&t>=0&&(s=e.substring(0,t+1))}if(n=this.tokenizer.inlineText(s))e=e.substring(n.raw.length),"_"!==n.raw.slice(-1)&&(o=n.raw.slice(-1)),l=!0,r=t[t.length-1],r&&"text"===r.type?(r.raw+=n.raw,r.text+=n.text):t.push(n);else if(e){const t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}else e=e.substring(n.raw.length),t.push(n);return t}}class q{options;constructor(e){this.options=e||b}code(e,t,n){const r=(t||"").match(/^\S*/)?.[0];return e=e.replace(/\n$/,"")+"\n",r?'
'+(n?e:O(e,!0))+"
\n":"
"+(n?e:O(e,!0))+"
\n"}blockquote(e){return`
\n${e}
\n`}html(e,t){return e}heading(e,t,n){return`${e}\n`}hr(){return"
\n"}list(e,t,n){const r=t?"ol":"ul";return"<"+r+(t&&1!==n?' start="'+n+'"':"")+">\n"+e+"\n"}listitem(e,t,n){return`
  • ${e}
  • \n`}checkbox(e){return"'}paragraph(e){return`

    ${e}

    \n`}table(e,t){return t&&(t=`${t}`),"\n\n"+e+"\n"+t+"
    \n"}tablerow(e){return`\n${e}\n`}tablecell(e,t){const n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`\n`}strong(e){return`${e}`}em(e){return`${e}`}codespan(e){return`${e}`}br(){return"
    "}del(e){return`${e}`}link(e,t,n){const r=T(e);if(null===r)return n;let s='",s}image(e,t,n){const r=T(e);if(null===r)return n;let s=`${n}"colon"===(t=t.toLowerCase())?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):"")));continue}case"code":{const e=s;n+=this.renderer.code(e.text,e.lang,!!e.escaped);continue}case"table":{const e=s;let t="",r="";for(let t=0;t0&&"paragraph"===n.tokens[0].type?(n.tokens[0].text=e+" "+n.tokens[0].text,n.tokens[0].tokens&&n.tokens[0].tokens.length>0&&"text"===n.tokens[0].tokens[0].type&&(n.tokens[0].tokens[0].text=e+" "+n.tokens[0].tokens[0].text)):n.tokens.unshift({type:"text",text:e+" "}):o+=e+" "}o+=this.parse(n.tokens,i),l+=this.renderer.listitem(o,s,!!r)}n+=this.renderer.list(l,t,r);continue}case"html":{const e=s;n+=this.renderer.html(e.text,e.block);continue}case"paragraph":{const e=s;n+=this.renderer.paragraph(this.parseInline(e.tokens));continue}case"text":{let i=s,l=i.tokens?this.parseInline(i.tokens):i.text;for(;r+1{n=n.concat(this.walkTokens(e[r],t))})):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){const t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach((e=>{const n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach((e=>{if(!e.name)throw new Error("extension name required");if("renderer"in e){const n=t.renderers[e.name];t.renderers[e.name]=n?function(...t){let r=e.renderer.apply(this,t);return!1===r&&(r=n.apply(this,t)),r}:e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw new Error("extension level must be 'block' or 'inline'");const n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&("block"===e.level?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:"inline"===e.level&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)})),n.extensions=t),e.renderer){const t=this.defaults.renderer||new q(this.defaults);for(const n in e.renderer){const r=e.renderer[n],s=n,i=t[s];t[s]=(...e)=>{let n=r.apply(t,e);return!1===n&&(n=i.apply(t,e)),n||""}}n.renderer=t}if(e.tokenizer){const t=this.defaults.tokenizer||new A(this.defaults);for(const n in e.tokenizer){const r=e.tokenizer[n],s=n,i=t[s];t[s]=(...e)=>{let n=r.apply(t,e);return!1===n&&(n=i.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){const t=this.defaults.hooks||new Z;for(const n in e.hooks){const r=e.hooks[n],s=n,i=t[s];Z.passThroughHooks.has(n)?t[s]=e=>{if(this.defaults.async)return Promise.resolve(r.call(t,e)).then((e=>i.call(t,e)));const n=r.call(t,e);return i.call(t,n)}:t[s]=(...e)=>{let n=r.apply(t,e);return!1===n&&(n=i.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){const t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}})),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return B.lex(e,t??this.defaults)}parser(e,t){return H.parse(e,t??this.defaults)}#e(e,t){return(n,r)=>{const s={...r},i={...this.defaults,...s};!0===this.defaults.async&&!1===s.async&&(i.silent||console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored."),i.async=!0);const l=this.#t(!!i.silent,!!i.async);if(null==n)return l(new Error("marked(): input parameter is undefined or null"));if("string"!=typeof n)return l(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(i.hooks&&(i.hooks.options=i),i.async)return Promise.resolve(i.hooks?i.hooks.preprocess(n):n).then((t=>e(t,i))).then((e=>i.walkTokens?Promise.all(this.walkTokens(e,i.walkTokens)).then((()=>e)):e)).then((e=>t(e,i))).then((e=>i.hooks?i.hooks.postprocess(e):e)).catch(l);try{i.hooks&&(n=i.hooks.preprocess(n));const r=e(n,i);i.walkTokens&&this.walkTokens(r,i.walkTokens);let s=t(r,i);return i.hooks&&(s=i.hooks.postprocess(s)),s}catch(e){return l(e)}}}#t(e,t){return n=>{if(n.message+="\nPlease report this to https://github.com/markedjs/marked.",e){const e="

    An error occurred:

    "+O(n.message+"",!0)+"
    ";return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function F(e,t){return D.parse(e,t)}function G(e){let t=F.parse(e);return t=t.replace(/
    <\/pre>/g,"
    "),t}F.options=F.setOptions=function(e){return D.setOptions(e),F.defaults=D.defaults,w(F.defaults),F},F.getDefaults=function(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}},F.defaults=b,F.use=function(...e){return D.use(...e),F.defaults=D.defaults,w(F.defaults),F},F.walkTokens=function(e,t){return D.walkTokens(e,t)},F.parseInline=D.parseInline,F.Parser=H,F.parser=H.parse,F.Renderer=q,F.TextRenderer=N,F.Lexer=B,F.lexer=B.lex,F.Tokenizer=A,F.Hooks=Z,F.parse=F,F.options,F.setOptions,F.use,F.walkTokens,F.parseInline,H.parse,B.lex,F.use({headerIds:!1});const U=window.wp.i18n,Q=window.wp.apiFetch;var W=n.n(Q);function V(){return{type:"OPEN"}}function K(){return{type:"CLOSE"}}function X(){return{type:"TOGGLE"}}function J(e){return{type:"SET_INPUT",input:e}}function Y(e){return{type:"SET_CONTEXT",context:e}}function ee(e){return{type:"SET_INSERTION_PLACE",insertionPlace:e}}function te(e){return{type:"SET_SCREEN",screen:e}}function ne(e){return{type:"SET_LOADING",loading:e}}function re(e){return{type:"SET_RESPONSE",response:e}}function se(e){return{type:"SET_ERROR",error:e}}function ie(){return e=>{let{dispatch:t,select:n}=e;if(!u)return;if(n.getLoading())return;t({type:"REQUEST_AI_PENDING"});const r=n.getContext(),s={request:n.getInput()};"selected-blocks"===r&&(s.context=function(){const{getBlock:e,getSelectedBlockClientIds:t}=wp.data.select("core/block-editor"),n=t();let r="";return n.forEach((t=>{const n=e(t);n?.attributes?.content&&(r=`${r}

    ${n.attributes.content}

    `)})),r}()),W()({path:"/mind/v1/request_ai",method:"POST",data:s}).then((e=>(t({type:"REQUEST_AI_SUCCESS",payload:e.response}),e.response))).catch((e=>{t({type:"REQUEST_AI_ERROR",payload:e?.response||e?.error_code||(0,U.__)("Something went wrong, please, try again…","mind")})}))}}function le(){return{type:"RESET"}}function oe(e){return e?.isOpen||!1}function ae(e){return e?.input||""}function ce(e){return e?.context||""}function ue(e){return e?.insertionPlace||""}function pe(e){return e?.screen||""}function he(e){return e?.loading||!1}function de(e){return e?.response||!1}function ge(e){return e?.error||!1}const me=(0,h.createReduxStore)("mind/popup",{reducer:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{isOpen:!1,input:"",context:"",insertionPlace:"",screen:"",loading:!1,response:!1,error:!1},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};switch(t.type){case"CLOSE":if(e.isOpen)return{...e,isOpen:!1};break;case"OPEN":if(!e.isOpen)return{...e,isOpen:!0};break;case"TOGGLE":return{...e,isOpen:!e.isOpen};case"SET_INPUT":if(e.input!==t.input)return{...e,input:t.input};break;case"SET_CONTEXT":if(e.context!==t.context)return{...e,context:t.context};break;case"SET_INSERTION_PLACE":if(e.insertionPlace!==t.insertionPlace)return{...e,insertionPlace:t.insertionPlace};break;case"SET_SCREEN":if(e.screen!==t.screen)return{...e,screen:t.screen};break;case"SET_LOADING":if(e.loading!==t.loading)return{...e,loading:t.loading};break;case"SET_RESPONSE":if(e.response!==t.response)return{...e,response:t.response};break;case"SET_ERROR":if(e.error!==t.error)return{...e,error:t.error};break;case"REQUEST_AI_PENDING":return{...e,loading:!0,isOpen:!0,screen:"request"};case"REQUEST_AI_SUCCESS":return{...e,loading:!1,response:!!t.payload&&G(t.payload)};case"REQUEST_AI_ERROR":return{...e,loading:!1,error:t.payload||"",response:!1};case"RESET":return{...e,input:"",context:"",insertionPlace:"",screen:"",response:!1,error:!1,loading:!1}}return e},actions:l,selectors:o});(0,h.register)(me);const fe=window.wp.element,ke=window.wp.components,be=window.wp.blocks,we=window.wp.domReady;var xe=n.n(we);function _e(e){var t,n,r="";if("string"==typeof e||"number"==typeof e)r+=e;else if("object"==typeof e)if(Array.isArray(e))for(t=0;t{const{isOpen:t,getInput:n,getContext:r,getScreen:s,getLoading:i,getResponse:l}=e("mind/popup");return{isOpen:t(),input:n(),context:r(),screen:s(),loading:i(),response:l()}}));let g=c;switch(c){case"selected-blocks":g=(0,U.__)("Selected Blocks");break;case"post-title":g=(0,U.__)("Post Title")}return(0,fe.useEffect)((()=>{o&&!p&&n?.current&&n.current.focus()}),[o,p,n]),(0,fe.useEffect)((()=>{""===u&&a&&i("request")}),[u,a,i]),(0,fe.useEffect)((()=>{if(n?.current){n.current.style.height="0px";const e=n.current.scrollHeight;n.current.style.height=e+"px"}}),[n,a]),(0,fe.createElement)("div",{className:"mind-popup-input"},(0,fe.createElement)(Le,null),(0,fe.createElement)("textarea",{ref:n,placeholder:(0,U.__)("Ask AI to write anything…","mind"),value:a,onChange:e=>{s(e.target.value)},onKeyDown:function(e){""===u||"Backspace"!==e.key||e.target.value?!d||"Enter"!==e.key||e.shiftKey?"request"!==u||"Enter"!==e.key||e.shiftKey||l():t():r()},disabled:p,rows:1}),g?(0,fe.createElement)("span",{className:"mind-popup-input-context"},g):null)}function qe(){return(0,fe.createElement)("div",{className:"mind-popup-loading-line"},(0,fe.createElement)("span",null))}function Ne(e){return(0,fe.createElement)("span",{className:"mind-popup-loading-text"},e.children)}function He(e){const{type:t,children:n}=e;return(0,fe.createElement)("div",{className:"mind-popup-notice "+(t?`mind-popup-notice-${t}`:"")},n)}function Ze(){return Ze=Object.assign?Object.assign.bind():function(e){for(var t=1;t{const{isOpen:t,getInput:n,getContext:r,getScreen:s,getLoading:i,getResponse:l,getError:o}=e("mind/popup");return{isOpen:t(),input:n(),context:r(),screen:s(),loading:i(),response:l(),error:o()}}));return(0,fe.useEffect)((()=>{r&&!l&&e?.current&&function(){if(e?.current){const t=e.current.querySelector("input");t&&t.focus()}}()}),[r,l,e]),(0,fe.useEffect)((()=>{""===i&&s&&n("request")}),[i,s,n]),(0,fe.createElement)("div",{className:"mind-popup-content"},""===i?(0,fe.createElement)("div",{className:"mind-popup-commands"},We.map((e=>"category"===e.type?(0,fe.createElement)("span",{key:e.type+e.label,className:"mind-popup-commands-category"},e.label):(0,fe.createElement)(ke.Button,{key:e.type+e.label,className:"mind-popup-commands-button",onClick:()=>{t(e.request),n("request")}},e.icon||"",e.label)))):null,"request"===i&&(0,fe.createElement)("div",{className:"mind-popup-request"},l&&(0,fe.createElement)(Ne,null,(0,U.__)("Waiting for AI response","mind")),!l&&o&&(0,fe.createElement)(fe.RawHTML,null,o),!l&&a&&(0,fe.createElement)(He,{type:"error"},a)))}function Ke(e){const{onInsert:t}=e,{close:n,reset:r,setError:s,requestAI:i}=(0,h.useDispatch)("mind/popup"),{input:l,loading:o,response:a}=(0,h.useSelect)((e=>{const{getInput:t,getContext:n,getScreen:r,getLoading:s,getResponse:i}=e("mind/popup");return{input:t(),context:n(),screen:r(),loading:s(),response:i()}}));return a||l&&!o&&!a?(0,fe.createElement)("div",{className:"mind-popup-footer"},(0,fe.createElement)("div",{className:"mind-popup-footer-actions"},l&&!o&&!a&&(0,fe.createElement)(ke.Button,{onClick:()=>{i()}},(0,U.__)("Get Answer","mind")," ",(0,fe.createElement)("kbd",null,"⏎")),a&&(0,fe.createElement)(fe.Fragment,null,(0,fe.createElement)(ke.Button,{onClick:()=>{s(""),i()}},(0,U.__)("Regenerate","mind")," ",(0,fe.createElement)("kbd",null,"↻")),(0,fe.createElement)(ke.Button,{onClick:()=>{window.navigator.clipboard.writeText(a),r(),n()}},(0,U.__)("Copy","mind")),(0,fe.createElement)(ke.Button,{onClick:t},(0,U.__)("Insert","mind")," ",(0,fe.createElement)("kbd",null,"⏎"))))):null}var Xe;function Je(){return Je=Object.assign?Object.assign.bind():function(e){for(var t=1;t{const{getSettingsPageURL:t}=e("mind");return{settingsPageURL:t()}}));return(0,fe.createElement)("div",{className:"mind-popup-connected-screen"},(0,fe.createElement)("h2",null,(0,fe.createElement)(Ye,null),(0,U.__)("OpenAI Key","mind")),(0,fe.createElement)("div",null,(0,fe.createElement)("p",null,(0,U.__)("In order to use Mind, you will need to provide your OpenAI API key. Please insert your API key in the plugin settings to get started.","mind"))),(0,fe.createElement)("div",null,(0,fe.createElement)("a",{className:"mind-popup-connected-screen-button",href:e},(0,U.__)("Go to Settings","mind"))))}const tt="mind-popup-container";function nt(){const{setHighlightBlocks:e}=(0,h.useDispatch)("mind/blocks"),{close:t,reset:n}=(0,h.useDispatch)("mind/popup"),{connected:r,isOpen:s,insertionPlace:i,loading:l,response:o}=(0,h.useSelect)((e=>{const{isConnected:t}=e("mind"),{isOpen:n,getInsertionPlace:r,getLoading:s,getResponse:i}=e("mind/popup");return{connected:t(),isOpen:n(),insertionPlace:r(),loading:s(),response:i()}})),{selectedClientIds:a}=(0,h.useSelect)((e=>{const{getSelectedBlockClientIds:t}=e("core/block-editor");return{selectedClientIds:t()}}),[]),{insertBlocks:c,replaceBlocks:u}=(0,h.useDispatch)("core/block-editor");function p(){!function(){const t=(0,be.rawHandler)({HTML:o});t.length&&("selected-blocks"===i?u(a,t):c(t),e(t.map((e=>e.clientId))))}(),n(),t()}return s?(0,fe.createElement)(ke.Modal,{title:!1,className:Ee("mind-popup",!r&&"mind-popup-not-connected"),overlayClassName:"mind-popup-overlay",onRequestClose:()=>{n(),t()},__experimentalHideHeader:!0},r?(0,fe.createElement)(fe.Fragment,null,(0,fe.createElement)(Be,{onInsert:p}),l&&(0,fe.createElement)(qe,null),(0,fe.createElement)(Ve,null),(0,fe.createElement)(Ke,{onInsert:p})):(0,fe.createElement)(et,null)):null}xe()((()=>{if(document.querySelector(`.${tt}`))return;const e=document.querySelector(".block-editor");if(!e)return;const t=document.createElement("div");t.classList.add(tt),e.appendChild(t),(0,fe.createRoot)(t).render((0,fe.createElement)(nt,null))}));const rt=window.wp.hooks,st=window.wp.blockEditor,it=window.wp.compose;var lt;function ot(){return ot=Object.assign?Object.assign.bind():function(e){for(var t=1;t
    ",s}image(e,t,n){const r=R(e);if(null===r)return n;let s=`${n}"colon"===(t=t.toLowerCase())?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):"")));continue}case"code":{const e=s;n+=this.renderer.code(e.text,e.lang,!!e.escaped);continue}case"table":{const e=s;let t="",r="";for(let t=0;t0&&"paragraph"===n.tokens[0].type?(n.tokens[0].text=e+" "+n.tokens[0].text,n.tokens[0].tokens&&n.tokens[0].tokens.length>0&&"text"===n.tokens[0].tokens[0].type&&(n.tokens[0].tokens[0].text=e+" "+n.tokens[0].tokens[0].text)):n.tokens.unshift({type:"text",text:e+" "}):l+=e+" "}l+=this.parse(n.tokens,i),o+=this.renderer.listitem(l,s,!!r)}n+=this.renderer.list(o,t,r);continue}case"html":{const e=s;n+=this.renderer.html(e.text,e.block);continue}case"paragraph":{const e=s;n+=this.renderer.paragraph(this.parseInline(e.tokens));continue}case"text":{let i=s,o=i.tokens?this.parseInline(i.tokens):i.text;for(;r+1{n=n.concat(this.walkTokens(e[r],t))})):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){const t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach((e=>{const n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach((e=>{if(!e.name)throw new Error("extension name required");if("renderer"in e){const n=t.renderers[e.name];t.renderers[e.name]=n?function(...t){let r=e.renderer.apply(this,t);return!1===r&&(r=n.apply(this,t)),r}:e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw new Error("extension level must be 'block' or 'inline'");const n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&("block"===e.level?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:"inline"===e.level&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)})),n.extensions=t),e.renderer){const t=this.defaults.renderer||new N(this.defaults);for(const n in e.renderer){const r=e.renderer[n],s=n,i=t[s];t[s]=(...e)=>{let n=r.apply(t,e);return!1===n&&(n=i.apply(t,e)),n||""}}n.renderer=t}if(e.tokenizer){const t=this.defaults.tokenizer||new B(this.defaults);for(const n in e.tokenizer){const r=e.tokenizer[n],s=n,i=t[s];t[s]=(...e)=>{let n=r.apply(t,e);return!1===n&&(n=i.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){const t=this.defaults.hooks||new H;for(const n in e.hooks){const r=e.hooks[n],s=n,i=t[s];H.passThroughHooks.has(n)?t[s]=e=>{if(this.defaults.async)return Promise.resolve(r.call(t,e)).then((e=>i.call(t,e)));const n=r.call(t,e);return i.call(t,n)}:t[s]=(...e)=>{let n=r.apply(t,e);return!1===n&&(n=i.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){const t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}})),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return L.lex(e,t??this.defaults)}parser(e,t){return U.parse(e,t??this.defaults)}#e(e,t){return(n,r)=>{const s={...r},i={...this.defaults,...s};!0===this.defaults.async&&!1===s.async&&(i.silent||console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored."),i.async=!0);const o=this.#t(!!i.silent,!!i.async);if(null==n)return o(new Error("marked(): input parameter is undefined or null"));if("string"!=typeof n)return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(i.hooks&&(i.hooks.options=i),i.async)return Promise.resolve(i.hooks?i.hooks.preprocess(n):n).then((t=>e(t,i))).then((e=>i.walkTokens?Promise.all(this.walkTokens(e,i.walkTokens)).then((()=>e)):e)).then((e=>t(e,i))).then((e=>i.hooks?i.hooks.postprocess(e):e)).catch(o);try{i.hooks&&(n=i.hooks.preprocess(n));const r=e(n,i);i.walkTokens&&this.walkTokens(r,i.walkTokens);let s=t(r,i);return i.hooks&&(s=i.hooks.postprocess(s)),s}catch(e){return o(e)}}}#t(e,t){return n=>{if(n.message+="\nPlease report this to https://github.com/markedjs/marked.",e){const e="

    An error occurred:

    "+O(n.message+"",!0)+"
    ";return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function Z(e,t){return D.parse(e,t)}function Q(e){let t=Z.parse(e);return t=t.replace(/
    <\/pre>/g,"
    "),t}Z.options=Z.setOptions=function(e){return D.setOptions(e),Z.defaults=D.defaults,w(Z.defaults),Z},Z.getDefaults=function(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}},Z.defaults=b,Z.use=function(...e){return D.use(...e),Z.defaults=D.defaults,w(Z.defaults),Z},Z.walkTokens=function(e,t){return D.walkTokens(e,t)},Z.parseInline=D.parseInline,Z.Parser=U,Z.parser=U.parse,Z.Renderer=N,Z.TextRenderer=q,Z.Lexer=L,Z.lexer=L.lex,Z.Tokenizer=B,Z.Hooks=H,Z.parse=Z,Z.options,Z.setOptions,Z.use,Z.walkTokens,Z.parseInline,U.parse,L.lex,Z.use({headerIds:!1});const F={isOpen:!1,input:"",context:"",insertionPlace:"",screen:"",loading:!1,response:"",error:null,progress:{charsProcessed:0,queueSize:0,isComplete:!1},renderBuffer:{content:"",lastUpdate:0}},G=window.wp.i18n,W=window.wp.apiFetch;var K=n.n(W);class V{constructor(e){this.dispatch=e,this.buffer="",this.responseText="",this.decoder=new TextDecoder,this.lastUpdate=Date.now(),this.updateQueue=[],this.isProcessing=!1,this.CONFIG={CHUNK_DELAY:30,UPDATE_INTERVAL:50,BATCH_SIZE:3,MAX_QUEUE_SIZE:100,TYPING_SPEED:{FAST:20,MEDIUM:35,SLOW:50}}}async processStream(e){try{for(this.startQueueProcessor();;){const{value:t,done:n}=await e.read();if(n)break;await this.processChunk(t)}await this.flushQueue(),this.sendCompletion()}catch(e){this.handleError(e)}}async processChunk(e){const t=this.decoder.decode(e,{stream:!0}),n=this.parseChunks(t);for(const e of n)await this.queueUpdate(e)}parseChunks(e){const t=[],n=e.split("\n");for(const e of n)if(e.startsWith("data: "))try{const n=JSON.parse(e.slice(6));n.content&&t.push(n.content)}catch(e){console.debug("Chunk parse error:",e)}return t}async queueUpdate(e){this.updateQueue.push(e),this.updateQueue.length>this.CONFIG.MAX_QUEUE_SIZE&&await this.flushQueue()}async startQueueProcessor(){if(!this.isProcessing){for(this.isProcessing=!0;this.updateQueue.length>0;){const e=this.updateQueue.splice(0,this.CONFIG.BATCH_SIZE);await this.processBatch(e)}this.isProcessing=!1}}async processBatch(e){const t=e.join("");this.responseText+=t;const n=Date.now();n-this.lastUpdate>=this.CONFIG.UPDATE_INTERVAL&&(this.dispatch({type:"REQUEST_AI_CHUNK",payload:{content:this.responseText,progress:this.calculateProgress()}}),this.lastUpdate=n),await new Promise((e=>setTimeout(e,this.CONFIG.CHUNK_DELAY)))}calculateProgress(){return{charsProcessed:this.responseText.length,queueSize:this.updateQueue.length,isComplete:!1}}async flushQueue(){for(;this.updateQueue.length>0;)await this.startQueueProcessor()}sendCompletion(){this.dispatch({type:"REQUEST_AI_SUCCESS",payload:{content:this.responseText,progress:{isComplete:!0}}})}handleError(e){this.dispatch({type:"REQUEST_AI_ERROR",payload:e.message})}}function X(){return{type:"OPEN"}}function J(){return{type:"CLOSE"}}function Y(){return{type:"TOGGLE"}}function ee(e){return{type:"SET_INPUT",input:e}}function te(e){return{type:"SET_CONTEXT",context:e}}function ne(e){return{type:"SET_INSERTION_PLACE",insertionPlace:e}}function re(e){return{type:"SET_SCREEN",screen:e}}function se(e){return{type:"SET_LOADING",loading:e}}function ie(e){return{type:"SET_RESPONSE",response:e}}function oe(e){return{type:"SET_ERROR",error:e}}function le(){return{type:"RESET"}}function ae(e){return async({dispatch:t})=>{const n=new TextDecoder;let r="",s="";const i=e=>new Promise((t=>setTimeout(t,e)));try{for(;;){const{value:o,done:l}=await e.read();if(l)break;r+=n.decode(o,{stream:!0});const a=r.split("\n");r=a.pop()||"";for(const e of a)if(e.startsWith("data: "))try{const n=JSON.parse(e.slice(6));if(n.error)return void t({type:"REQUEST_AI_ERROR",payload:n.message});if(n.done)return void t({type:"REQUEST_AI_SUCCESS",payload:s});n.content&&(s+=n.content,t({type:"REQUEST_AI_CHUNK",payload:s}),await i(50))}catch(e){t({type:"REQUEST_AI_ERROR",payload:(0,G.__)("Failed to parse stream data","mind")})}}}catch(e){t({type:"REQUEST_AI_ERROR",payload:e.message})}}}function ce(){return async({dispatch:e,select:t})=>{if(!u)return;if(t.getLoading())return;e({type:"REQUEST_AI_PENDING"});const n=t.getContext(),r={request:t.getInput()};"selected-blocks"===n&&(r.context=function(){const{getBlock:e,getSelectedBlockClientIds:t}=wp.data.select("core/block-editor"),n=t();let r="";return n.forEach((t=>{const n=e(t);n?.attributes?.content&&(r=`${r}

    ${n.attributes.content}

    `)})),r}());try{const t=new V(e),n=await K()({path:"/mind/v1/request_ai",method:"POST",data:r,parse:!1});if(!n.ok){const e=await n.json();throw new Error(e.message||(0,G.__)("Failed to fetch AI response","mind"))}await t.processStream(n.body.getReader())}catch(t){e({type:"REQUEST_AI_ERROR",payload:t.message||(0,G.__)("Failed to fetch AI response","mind")})}}}function ue(e){return e?.isOpen||!1}function pe(e){return e?.input||""}function he(e){return e?.context||""}function de(e){return e?.insertionPlace||""}function ge(e){return e?.screen||""}function me(e){return e?.loading||!1}function fe(e){return e?.response||!1}function ke(e){return e?.progress||!1}function be(e){return e?.renderBuffer||!1}function we(e){return e?.error||!1}const _e=(0,h.createReduxStore)("mind/popup",{reducer:function(e=F,t={}){switch(t.type){case"CLOSE":if(e.isOpen)return{...e,isOpen:!1};break;case"OPEN":if(!e.isOpen)return{...e,isOpen:!0};break;case"TOGGLE":return{...e,isOpen:!e.isOpen};case"SET_INPUT":if(e.input!==t.input)return{...e,input:t.input};break;case"SET_CONTEXT":if(e.context!==t.context)return{...e,context:t.context};break;case"SET_INSERTION_PLACE":if(e.insertionPlace!==t.insertionPlace)return{...e,insertionPlace:t.insertionPlace};break;case"SET_SCREEN":if(e.screen!==t.screen)return{...e,screen:t.screen};break;case"SET_LOADING":if(e.loading!==t.loading)return{...e,loading:t.loading};break;case"SET_RESPONSE":if(e.response!==t.response)return{...e,response:t.response};break;case"SET_ERROR":if(e.error!==t.error)return{...e,error:t.error};break;case"REQUEST_AI_PENDING":return{...e,isOpen:!0,loading:!0,response:"",error:null,screen:"request",progress:F.progress,renderBuffer:F.renderBuffer};case"REQUEST_AI_CHUNK":const n=Date.now();return n-e.renderBuffer.lastUpdate>=50?{...e,loading:!0,response:!!t.payload.content&&Q(t.payload.content),progress:t.payload.progress,renderBuffer:{content:t.payload.content,lastUpdate:n}}:{...e,renderBuffer:{content:t.payload.content,lastUpdate:e.renderBuffer.lastUpdate}};case"REQUEST_AI_SUCCESS":return{...e,loading:!1,response:!!t.payload.content&&Q(t.payload.content),progress:{...t.payload.progress,isComplete:!0},renderBuffer:{content:t.payload.content,lastUpdate:Date.now()}};case"REQUEST_AI_ERROR":return{...e,loading:!1,response:!1,error:t.payload||"",progress:F.progress,renderBuffer:F.renderBuffer};case"RESET":return{...e,input:"",context:"",insertionPlace:"",screen:"",response:!1,error:!1,loading:!1}}return e},actions:o,selectors:l});(0,h.register)(_e);const xe=window.wp.element,Ee=window.wp.components,ye=window.wp.blocks,ve=window.wp.domReady;var Se=n.n(ve);function Oe(e){var t,n,r="";if("string"==typeof e||"number"==typeof e)r+=e;else if("object"==typeof e)if(Array.isArray(e))for(t=0;t{const{isOpen:t,getInput:n,getContext:r,getScreen:s,getLoading:i,getResponse:o}=e("mind/popup");return{isOpen:t(),input:n(),context:r(),screen:s(),loading:i(),response:o()}}));let g=c;switch(c){case"selected-blocks":g=(0,G.__)("Selected Blocks");break;case"post-title":g=(0,G.__)("Post Title")}return(0,xe.useEffect)((()=>{l&&!p&&n?.current&&n.current.focus()}),[l,p,n]),(0,xe.useEffect)((()=>{""===u&&a&&i("request")}),[u,a,i]),(0,xe.useEffect)((()=>{if(n?.current){n.current.style.height="0px";const e=n.current.scrollHeight;n.current.style.height=e+"px"}}),[n,a]),(0,xe.createElement)("div",{className:"mind-popup-input"},(0,xe.createElement)($e,null),(0,xe.createElement)("textarea",{ref:n,placeholder:(0,G.__)("Ask AI to write anything…","mind"),value:a,onChange:e=>{s(e.target.value)},onKeyDown:function(e){""===u||"Backspace"!==e.key||e.target.value?!d||"Enter"!==e.key||e.shiftKey?"request"!==u||"Enter"!==e.key||e.shiftKey||o():t():r()},disabled:p,rows:1}),g?(0,xe.createElement)("span",{className:"mind-popup-input-context"},g):null)}function Me(){return(0,xe.createElement)("div",{className:"mind-popup-loading-line"},(0,xe.createElement)("span",null))}function Ae(e){const{type:t,children:n}=e;return(0,xe.createElement)("div",{className:"mind-popup-notice "+(t?`mind-popup-notice-${t}`:"")},n)}const Be=(0,xe.memo)((function({response:e,loading:t}){const n=(0,xe.useRef)();return(0,xe.useEffect)((()=>{if(!n.current)return;const e=n.current.closest(".mind-popup-content");if(!e)return;const{scrollHeight:t,clientHeight:r}=e;t-r<1e3&&e.scrollTo({top:t,behavior:"smooth"})}),[e]),e||t?(0,Te.createElement)("div",{ref:n,className:"mind-popup-response",style:{opacity:t?.85:1}},(0,Te.createElement)(xe.RawHTML,null,e),t&&(0,Te.createElement)("div",{className:"mind-popup-cursor"})):null}),((e,t)=>e.renderBuffer.lastUpdate===t.renderBuffer.lastUpdate&&e.loading===t.loading&&e.progress.isComplete===t.progress.isComplete));var ze,je,Le,Ne,qe,Ue,He,De,Ze,Qe,Fe;function Ge(){return Ge=Object.assign?Object.assign.bind():function(e){for(var t=1;t{const{isOpen:t,getInput:n,getContext:r,getScreen:s,getLoading:i,getResponse:o,getProgress:l,getRenderBuffer:a,getError:c}=e("mind/popup");return{isOpen:t(),input:n(),context:r(),screen:s(),loading:i(),response:o(),progress:l(),renderBuffer:a(),error:c()}}));return(0,xe.useEffect)((()=>{r&&!o&&e?.current&&function(){if(e?.current){const t=e.current.querySelector("input");t&&t.focus()}}()}),[r,o,e]),(0,xe.useEffect)((()=>{""===i&&s&&n("request")}),[i,s,n]),(0,Te.createElement)("div",{className:"mind-popup-content"},""===i?(0,Te.createElement)("div",{className:"mind-popup-commands"},Ye.map((e=>"category"===e.type?(0,Te.createElement)("span",{key:e.type+e.label,className:"mind-popup-commands-category"},e.label):(0,Te.createElement)(Ee.Button,{key:e.type+e.label,className:"mind-popup-commands-button",onClick:()=>{t(e.request),n("request")}},e.icon||"",e.label)))):null,"request"===i&&(0,Te.createElement)("div",{className:"mind-popup-request"},l&&(0,Te.createElement)(Be,{progress:a,loading:o,response:l,renderBuffer:c}),!o&&u&&(0,Te.createElement)(Ae,{type:"error"},u)))}function tt(e){return(0,xe.createElement)("span",{className:"mind-popup-loading-text"},e.children)}function nt(e){const{onInsert:t}=e,{close:n,reset:r,setError:s,requestAI:i}=(0,h.useDispatch)("mind/popup"),{input:o,loading:l,response:a}=(0,h.useSelect)((e=>{const{getInput:t,getContext:n,getScreen:r,getLoading:s,getResponse:i}=e("mind/popup");return{input:t(),context:n(),screen:r(),loading:s(),response:i()}}));return a||l||o&&!l&&!a?(0,Te.createElement)("div",{className:"mind-popup-footer"},l&&(0,Te.createElement)(tt,null,(0,G.__)("Writing","mind")),(0,Te.createElement)("div",{className:"mind-popup-footer-actions"},o&&!l&&!a&&(0,Te.createElement)(Ee.Button,{onClick:()=>{i()}},(0,G.__)("Get Answer","mind")," ",(0,Te.createElement)("kbd",null,"⏎")),a&&!l&&(0,Te.createElement)(Te.Fragment,null,(0,Te.createElement)(Ee.Button,{onClick:()=>{s(""),i()}},(0,G.__)("Regenerate","mind")," ",(0,Te.createElement)("kbd",null,"↻")),(0,Te.createElement)(Ee.Button,{onClick:()=>{window.navigator.clipboard.writeText(a),r(),n()}},(0,G.__)("Copy","mind")),(0,Te.createElement)(Ee.Button,{onClick:t},(0,G.__)("Insert","mind")," ",(0,Te.createElement)("kbd",null,"⏎"))))):null}var rt;function st(){return st=Object.assign?Object.assign.bind():function(e){for(var t=1;t{const{getSettingsPageURL:t}=e("mind");return{settingsPageURL:t()}}));return(0,xe.createElement)("div",{className:"mind-popup-connected-screen"},(0,xe.createElement)("h2",null,(0,xe.createElement)(it,null),(0,G.__)("OpenAI Key","mind")),(0,xe.createElement)("div",null,(0,xe.createElement)("p",null,(0,G.__)("In order to use Mind, you will need to provide your OpenAI API key. Please insert your API key in the plugin settings to get started.","mind"))),(0,xe.createElement)("div",null,(0,xe.createElement)("a",{className:"mind-popup-connected-screen-button",href:e},(0,G.__)("Go to Settings","mind"))))}const lt="mind-popup-container";function at(){const{setHighlightBlocks:e}=(0,h.useDispatch)("mind/blocks"),{close:t,reset:n}=(0,h.useDispatch)("mind/popup"),{connected:r,isOpen:s,insertionPlace:i,loading:o,response:l}=(0,h.useSelect)((e=>{const{isConnected:t}=e("mind"),{isOpen:n,getInsertionPlace:r,getLoading:s,getResponse:i}=e("mind/popup");return{connected:t(),isOpen:n(),insertionPlace:r(),loading:s(),response:i()}})),{selectedClientIds:a}=(0,h.useSelect)((e=>{const{getSelectedBlockClientIds:t}=e("core/block-editor");return{selectedClientIds:t()}}),[]),{insertBlocks:c,replaceBlocks:u}=(0,h.useDispatch)("core/block-editor");function p(){!function(){const t=(0,ye.rawHandler)({HTML:l});t.length&&("selected-blocks"===i?u(a,t):c(t),e(t.map((e=>e.clientId))))}(),n(),t()}return s?(0,xe.createElement)(Ee.Modal,{title:!1,className:Ce("mind-popup",!r&&"mind-popup-not-connected"),overlayClassName:"mind-popup-overlay",onRequestClose:()=>{n(),t()},__experimentalHideHeader:!0},r?(0,xe.createElement)(xe.Fragment,null,(0,xe.createElement)(Pe,{onInsert:p}),o&&(0,xe.createElement)(Me,null),(0,xe.createElement)(et,null),(0,xe.createElement)(nt,{onInsert:p})):(0,xe.createElement)(ot,null)):null}Se()((()=>{if(document.querySelector(`.${lt}`))return;const e=document.querySelector(".block-editor");if(!e)return;const t=document.createElement("div");t.classList.add(lt),e.appendChild(t),(0,xe.createRoot)(t).render((0,xe.createElement)(at,null))}));const ct=window.wp.hooks,ut=window.wp.blockEditor,pt=window.wp.compose;var ht;function dt(){return dt=Object.assign?Object.assign.bind():function(e){for(var t=1;t