/*! For license information please see editor-no-post-editor.js.LICENSE.txt */ (()=>{var e={7675(e,t,r){"use strict";r.d(t,{y:()=>a});var n=r(76416),s=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(n=Object.getOwnPropertySymbols(e);s{const f=Object.assign({},a);let b;function v(){b.abort(),document.hidden||j()}f.accept||(f.accept=o),h||document.addEventListener("visibilitychange",v);let y=1e3,k=0;function _(){document.removeEventListener("visibilitychange",v),window.clearTimeout(k),b.abort()}null==r||r.addEventListener("abort",()=>{_(),t()});const x=null!=m?m:window.fetch,w=null!=l?l:c;async function j(){var r;b=new AbortController;try{const r=await x(e,Object.assign(Object.assign({},g),{headers:f,signal:b.signal}));await w(r),await(0,n.q5)(r.body,(0,n.iv)((0,n.VL)(e=>{e?f[i]=e:delete f[i]},e=>{y=e},u))),null==d||d(),_(),t()}catch(e){if(!b.signal.aborted)try{const t=null!==(r=null==p?void 0:p(e))&&void 0!==r?r:y;window.clearTimeout(k),k=window.setTimeout(j,t)}catch(e){_(),s(e)}}}j()})}function c(e){const t=e.headers.get("content-type");if(!(null==t?void 0:t.startsWith(o)))throw new Error(`Expected content-type to be ${o}, Actual: ${t}`)}},76416(e,t,r){"use strict";async function n(e,t){const r=e.getReader();let n;for(;!(n=await r.read()).done;)t(n.value)}function s(e){let t,r,n,s=!1;return function(o){void 0===t?(t=o,r=0,n=-1):t=function(e,t){const r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}(t,o);const i=t.length;let a=0;for(;r0){const r=s.decode(o.subarray(0,a)),i=a+(32===o[a+1]?2:1),c=s.decode(o.subarray(i));switch(r){case"data":n.data=n.data?n.data+"\n"+c:c;break;case"event":n.event=c;break;case"id":e(n.id=c);break;case"retry":const r=parseInt(c,10);isNaN(r)||t(n.retry=r)}}}}function i(){return{data:"",event:"",id:"",retry:void 0}}r.d(t,{VL:()=>o,iv:()=>s,q5:()=>n})},87399(e){!function(){"use strict";var t=[],r=3988292384;function n(e){var t,n,s,o,i=-1;for(t=0,s=e.length;t>>=1:o=o>>>1^r;i=i>>>8^o}return-1^i}function s(e,r){var n,o,i;if(void 0!==s.crc&&r&&e||(s.crc=~0,e)){for(n=s.crc,o=0,i=e.length;o>>8^t[255&(n^e[o])];return s.crc=n,-1^n}}!function(){var e,n,s;for(n=0;n<256;n+=1){for(e=n,s=0;s<8;s+=1)1&e?e=r^e>>>1:e>>>=1;t[n]=e>>>0}}(),e.exports=function(e,t){var r;e="string"==typeof e?(r=e,Array.prototype.map.call(r,function(e){return e.charCodeAt(0)})):e;return((t?n(e):s(e))>>>0).toString(16)},e.exports.direct=n,e.exports.table=s}()},39904(e,t){"use strict";var r=/^[-!#$%&'*+\/0-9=?A-Z^_a-z{|}~](\.?[-!#$%&'*+\/0-9=?A-Z^_a-z`{|}~])*@[a-zA-Z0-9](-*\.?[a-zA-Z0-9])*\.[a-zA-Z](-?[a-zA-Z0-9])+$/;t.t=function(e){if(!e)return!1;if(e.length>254)return!1;if(!r.test(e))return!1;var t=e.split("@");return!(t[0].length>64)&&!t[1].split(".").some(function(e){return e.length>63})}},2467(e){"use strict";var t,r="object"==typeof Reflect?Reflect:null,n=r&&"function"==typeof r.apply?r.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};t=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var s=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}e.exports=o,e.exports.once=function(e,t){return new Promise(function(r,n){function s(r){e.removeListener(t,o),n(r)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",s),r([].slice.call(arguments))}g(e,t,o,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&g(e,"error",t,r)}(e,s,{once:!0})})},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var i=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function c(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function l(e,t,r,n){var s,o,i,l;if(a(r),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),i=o[t]),void 0===i)i=o[t]=r,++e._eventsCount;else if("function"==typeof i?i=o[t]=n?[r,i]:[i,r]:n?i.unshift(r):i.push(r),(s=c(e))>0&&i.length>s&&!i.warned){i.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+i.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=i.length,l=u,console&&console.warn&&console.warn(l)}return e}function u(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},s=u.bind(n);return s.listener=r,n.wrapFn=s,s}function p(e,t,r){var n=e._events;if(void 0===n)return[];var s=n[t];return void 0===s?[]:"function"==typeof s?r?[s.listener||s]:[s]:r?function(e){for(var t=new Array(e.length),r=0;r0&&(i=t[0]),i instanceof Error)throw i;var a=new Error("Unhandled error."+(i?" ("+i.message+")":""));throw a.context=i,a}var c=o[e];if(void 0===c)return!1;if("function"==typeof c)n(c,this,t);else{var l=c.length,u=m(c,l);for(r=0;r=0;o--)if(r[o]===t||r[o].listener===t){i=r[o].listener,s=o;break}if(s<0)return this;0===s?r.shift():function(e,t){for(;t+1=0;n--)this.removeListener(e,t[n]);return this},o.prototype.listeners=function(e){return p(this,e,!0)},o.prototype.rawListeners=function(e){return p(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):h.call(e,t)},o.prototype.listenerCount=h,o.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},20305(e){"use strict";function t(e,t,r,n){var s=Number(e[t].meta.id+1).toString(),o="";return"string"==typeof n.docId&&(o="-"+n.docId+"-"),o+s}function r(e,t){var r=Number(e[t].meta.id+1).toString();return e[t].meta.subId>0&&(r+=":"+e[t].meta.subId),"["+r+"]"}function n(e,t,r,n,s){var o=s.rules.footnote_anchor_name(e,t,r,n,s),i=s.rules.footnote_caption(e,t,r,n,s),a=o;return e[t].meta.subId>0&&(a+=":"+e[t].meta.subId),''+i+""}function s(e,t,r){return(r.xhtmlOut?'
\n':'
\n')+'
\n
    \n'}function o(){return"
\n
\n"}function i(e,t,r,n,s){var o=s.rules.footnote_anchor_name(e,t,r,n,s);return e[t].meta.subId>0&&(o+=":"+e[t].meta.subId),'
  • '}function a(){return"
  • \n"}function c(e,t,r,n,s){var o=s.rules.footnote_anchor_name(e,t,r,n,s);return e[t].meta.subId>0&&(o+=":"+e[t].meta.subId),' ↩︎'}e.exports=function(e){var l=e.helpers.parseLinkLabel,u=e.utils.isSpace;e.renderer.rules.footnote_ref=n,e.renderer.rules.footnote_block_open=s,e.renderer.rules.footnote_block_close=o,e.renderer.rules.footnote_open=i,e.renderer.rules.footnote_close=a,e.renderer.rules.footnote_anchor=c,e.renderer.rules.footnote_caption=r,e.renderer.rules.footnote_anchor_name=t,e.block.ruler.before("reference","footnote_def",function(e,t,r,n){var s,o,i,a,c,l,d,p,h,m,g,f=e.bMarks[t]+e.tShift[t],b=e.eMarks[t];if(f+4>b)return!1;if(91!==e.src.charCodeAt(f))return!1;if(94!==e.src.charCodeAt(f+1))return!1;for(c=f+2;c=b||58!==e.src.charCodeAt(++c))return!1;if(n)return!0;for(c++,e.env.footnotes||(e.env.footnotes={}),e.env.footnotes.refs||(e.env.footnotes.refs={}),l=e.src.slice(f+2,c-2),e.env.footnotes.refs[":"+l]=-1,(d=new e.Token("footnote_reference_open","",1)).meta={label:l},d.level=e.level++,e.tokens.push(d),s=e.bMarks[t],o=e.tShift[t],i=e.sCount[t],a=e.parentType,g=c,p=h=e.sCount[t]+c-(e.bMarks[t]+e.tShift[t]);c=i)&&(94===e.src.charCodeAt(a)&&(91===e.src.charCodeAt(a+1)&&(r=a+2,!((n=l(e,a+1))<0)&&(t||(e.env.footnotes||(e.env.footnotes={}),e.env.footnotes.list||(e.env.footnotes.list=[]),s=e.env.footnotes.list.length,e.md.inline.parse(e.src.slice(r,n),e.md,e.env,o=[]),e.push("footnote_ref","",0).meta={id:s},e.env.footnotes.list[s]={content:e.src.slice(r,n),tokens:o}),e.pos=n+1,e.posMax=i,!0))))}),e.inline.ruler.after("footnote_inline","footnote_ref",function(e,t){var r,n,s,o,i=e.posMax,a=e.pos;if(a+3>i)return!1;if(!e.env.footnotes||!e.env.footnotes.refs)return!1;if(91!==e.src.charCodeAt(a))return!1;if(94!==e.src.charCodeAt(a+1))return!1;for(n=a+2;n=i)&&(n++,r=e.src.slice(a+2,n-1),void 0!==e.env.footnotes.refs[":"+r]&&(t||(e.env.footnotes.list||(e.env.footnotes.list=[]),e.env.footnotes.refs[":"+r]<0?(s=e.env.footnotes.list.length,e.env.footnotes.list[s]={label:r,count:0},e.env.footnotes.refs[":"+r]=s):s=e.env.footnotes.refs[":"+r],o=e.env.footnotes.list[s].count,e.env.footnotes.list[s].count++,e.push("footnote_ref","",0).meta={id:s,subId:o,label:r}),e.pos=n,e.posMax=i,!0)))}),e.core.ruler.after("inline","footnote_tail",function(e){var t,r,n,s,o,i,a,c,l,u,d=!1,p={};if(e.env.footnotes&&(e.tokens=e.tokens.filter(function(e){return"footnote_reference_open"===e.type?(d=!0,l=[],u=e.meta.label,!1):"footnote_reference_close"===e.type?(d=!1,p[":"+u]=l,!1):(d&&l.push(e),!d)}),e.env.footnotes.list)){for(i=e.env.footnotes.list,a=new e.Token("footnote_block_open","",1),e.tokens.push(a),t=0,r=i.length;t0?i[t].count:1,n=0;nn});const n={placeholder:"NisihrgiIKl_knpYJtfg",pulse:"R2i0K45dEF157drbVRPI"}},74116(e,t,r){"use strict";r.d(t,{A:()=>n});const n={global:"_fUXxnSp5pagKBp9gSN7"}},68071(){},15016(){},1103(){},28745(){},34927(){},26233(){},50920(){},45608(){},47894(){},16282(){},14808(){},87495(){},1947(){},55179(){},8221(){},98989(){},47698(){},83572(){},46236(){},3749(){},81699(){},55883(){},64799(){},85637(){},61824(){},79719(){},89592(){},23115(){},71035(){},23320(){},72847(){},27544(){},82933(){},96117(){},71293(){},62585(){},96854(){},98920(){},12315(){},97225(){},5271(){},48289(){},95341(){},21324(){},33362(){},47769(){},36556(){},76593(){},99650(e,t,r){"use strict";r.d(t,{A:()=>n});const n={wrapper:"h2NGkiVs1r1nf85LtJpF","conversion-notice":"k3Apzwo3v9n0IaHbB8tf"}},73823(){},83091(){},56251(){},19316(){},15538(){},36631(){},50888(){},42106(){},4825(){},72808(){},82588(){},28691(){},20499(){},44997(e){var t=1e3,r=60*t,n=60*r,s=24*n,o=7*s,i=365.25*s;function a(e,t,r,n){var s=t>=1.5*r;return Math.round(e/r)+" "+n+(s?"s":"")}e.exports=function(e,c){c=c||{};var l=typeof e;if("string"===l&&e.length>0)return function(e){if((e=String(e)).length>100)return;var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!a)return;var c=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*i;case"weeks":case"week":case"w":return c*o;case"days":case"day":case"d":return c*s;case"hours":case"hour":case"hrs":case"hr":case"h":return c*n;case"minutes":case"minute":case"mins":case"min":case"m":return c*r;case"seconds":case"second":case"secs":case"sec":case"s":return c*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(e);if("number"===l&&isFinite(e))return c.long?function(e){var o=Math.abs(e);if(o>=s)return a(e,o,s,"day");if(o>=n)return a(e,o,n,"hour");if(o>=r)return a(e,o,r,"minute");if(o>=t)return a(e,o,t,"second");return e+" ms"}(e):function(e){var o=Math.abs(e);if(o>=s)return Math.round(e/s)+"d";if(o>=n)return Math.round(e/n)+"h";if(o>=r)return Math.round(e/r)+"m";if(o>=t)return Math.round(e/t)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},14936(e,t,r){"use strict";r.d(t,{A:()=>h});var n=r(87399),s=r.n(n),o=r(10067),i=r.n(o),a=r(11264),c=r.n(a);const l=i()("photon"),u={width:"w",height:"h",letterboxing:"lb",removeLetterboxing:"ulb"},d="__domain__.invalid",p=`https://${d}`;function h(e,t){let r;try{r=new URL(e,p)}catch{return null}const n="https:"===r.protocol,o=new URL("https://i0.wp.com");if(i=r.host,/^i[0-2]\.wp\.com$/.test(i))o.pathname=r.pathname,o.hostname=n?"i0.wp.com":r.hostname;else{if(r.search)return null;let e=r.href.replace(`${r.protocol}/`,"");"blob:"===r.protocol&&(e=r.pathname.replace("://","//")),r.hostname===d&&(e=r.pathname),o.pathname=e,o.hostname=function(e,t){if(t)return"i0.wp.com";const r=s()(e),n=c()(r),o="i"+Math.floor(3*n());return l('determined server "%s" to use with "%s"',o,e),o+".wp.com"}(e,"https:"===o.protocol),n&&o.searchParams.set("ssl","1")}var i;if(t)for(const[e,r]of Object.entries(t))"host"!==e&&"hostname"!==e?"secure"!==e||r?o.searchParams.set(u[e]??e,r.toString()):o.protocol="http:":o.hostname=r;return l("generated Photon URL: %s",o.href),o.href}},87072(e,t,r){"use strict";r.d(t,{Ay:()=>y});const n=2147483647,s=36,o=/^xn--/,i=/[^\0-\x7F]/,a=/[\x2E\u3002\uFF0E\uFF61]/g,c={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},l=Math.floor,u=String.fromCharCode;function d(e){throw new RangeError(c[e])}function p(e,t){const r=e.split("@");let n="";r.length>1&&(n=r[0]+"@",e=r[1]);const s=function(e,t){const r=[];let n=e.length;for(;n--;)r[n]=t(e[n]);return r}((e=e.replace(a,".")).split("."),t).join(".");return n+s}function h(e){const t=[];let r=0;const n=e.length;for(;r=55296&&s<=56319&&r=48&&e<58?e-48+26:e>=65&&e<91?e-65:e>=97&&e<123?e-97:s},g=function(e,t){return e+22+75*(e<26)-((0!=t)<<5)},f=function(e,t,r){let n=0;for(e=r?l(e/700):e>>1,e+=l(e/t);e>455;n+=s)e=l(e/35);return l(n+36*e/(e+38))},b=function(e){const t=[],r=e.length;let o=0,i=128,a=72,c=e.lastIndexOf("-");c<0&&(c=0);for(let r=0;r=128&&d("not-basic"),t.push(e.charCodeAt(r));for(let u=c>0?c+1:0;u=r&&d("invalid-input");const c=m(e.charCodeAt(u++));c>=s&&d("invalid-input"),c>l((n-o)/t)&&d("overflow"),o+=c*t;const p=i<=a?1:i>=a+26?26:i-a;if(cl(n/h)&&d("overflow"),t*=h}const p=t.length+1;a=f(o-c,p,0==c),l(o/p)>n-i&&d("overflow"),i+=l(o/p),o%=p,t.splice(o++,0,i)}return String.fromCodePoint(...t)},v=function(e){const t=[],r=(e=h(e)).length;let o=128,i=0,a=72;for(const r of e)r<128&&t.push(u(r));const c=t.length;let p=c;for(c&&t.push("-");p=o&&tl((n-i)/h)&&d("overflow"),i+=(r-o)*h,o=r;for(const r of e)if(rn&&d("overflow"),r===o){let e=i;for(let r=s;;r+=s){const n=r<=a?1:r>=a+26?26:r-a;if(eString.fromCodePoint(...e)},decode:b,encode:v,toASCII:function(e){return p(e,function(e){return i.test(e)?"xn--"+v(e):e})},toUnicode:function(e){return p(e,function(e){return o.test(e)?b(e.slice(4).toLowerCase()):e})}}},24588(e,t){"use strict";var r=Object.prototype.hasOwnProperty;function n(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(e){return null}}function s(e){try{return encodeURIComponent(e)}catch(e){return null}}t.stringify=function(e,t){t=t||"";var n,o,i=[];for(o in"string"!=typeof t&&(t="?"),e)if(r.call(e,o)){if((n=e[o])||null!=n&&!isNaN(n)||(n=""),o=s(o),n=s(n),null===o||null===n)continue;i.push(o+"="+n)}return i.length?t+i.join("&"):""},t.parse=function(e){for(var t,r=/([^=?#&]+)=?([^&]*)/g,s={};t=r.exec(e);){var o=n(t[1]),i=n(t[2]);null===o||null===i||o in s||(s[o]=i)}return s}},96811(e){"use strict";e.exports=function(e,t){if(t=t.split(":")[0],!(e=+e))return!1;switch(t){case"http":case"ws":return 80!==e;case"https":case"wss":return 443!==e;case"ftp":return 21!==e;case"gopher":return 70!==e;case"file":return!1}return 0!==e}},94107(e,t,r){"use strict";r.d(t,{A:()=>j});var n=function(){if("undefined"!=typeof Map)return Map;function e(e,t){var r=-1;return e.some(function(e,n){return e[0]===t&&(r=n,!0)}),r}return function(){function t(){this.__entries__=[]}return Object.defineProperty(t.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),t.prototype.get=function(t){var r=e(this.__entries__,t),n=this.__entries__[r];return n&&n[1]},t.prototype.set=function(t,r){var n=e(this.__entries__,t);~n?this.__entries__[n][1]=r:this.__entries__.push([t,r])},t.prototype.delete=function(t){var r=this.__entries__,n=e(r,t);~n&&r.splice(n,1)},t.prototype.has=function(t){return!!~e(this.__entries__,t)},t.prototype.clear=function(){this.__entries__.splice(0)},t.prototype.forEach=function(e,t){void 0===t&&(t=null);for(var r=0,n=this.__entries__;r0},e.prototype.connect_=function(){s&&!this.connected_&&(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),c?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},e.prototype.disconnect_=function(){s&&this.connected_&&(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},e.prototype.onTransitionEnd_=function(e){var t=e.propertyName,r=void 0===t?"":t;a.some(function(e){return!!~r.indexOf(e)})&&this.refresh()},e.getInstance=function(){return this.instance_||(this.instance_=new e),this.instance_},e.instance_=null,e}(),u=function(e,t){for(var r=0,n=Object.keys(t);r0},e}(),x="undefined"!=typeof WeakMap?new WeakMap:new n,w=function e(t){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var r=l.getInstance(),n=new _(t,r,this);x.set(this,n)};["observe","unobserve","disconnect"].forEach(function(e){w.prototype[e]=function(){var t;return(t=x.get(this))[e].apply(t,arguments)}});const j=void 0!==o.ResizeObserver?o.ResizeObserver:w},11264(e){"use strict";var t=256,r=[],n=window,s=Math.pow(t,6),o=Math.pow(2,52),i=2*o,a=255,c=Math.random;function l(e){var r,n=e.length,s=this,o=0,i=s.i=s.j=0,c=s.S=[];for(n||(e=[n++]);o=i;)e/=2,r/=2,n>>>=1;return(e+n)/r}},e.exports.resetGlobal=function(){Math.random=c},d(Math.random(),r)},48931(e,t,r){"use strict";r.d(t,{A:()=>o});var n=r(1455),s=r.n(n);const o="default"in s()?s().default:s()},87286(e,t,r){"use strict";r.d(t,{A:()=>c});var n=r(47143),s=r(10067),o=r.n(s),i=r(53664);const a=o()("jetpack-ai-client:ask-question");async function c(e,{postId:t=null,fromCache:r=!1,feature:s,functions:o,model:c,languageCode:l}={}){const u=l||(0,n.select)("core").getEntityRecord("root","site")?.language||"en_US";return a("Asking question: %o. options: %o",e,{postId:t,fromCache:r,feature:s,functions:o,model:c,languageCode:u}),new i.A({question:e,options:{postId:t,feature:s,fromCache:r,functions:o,model:c,languageCode:u}})}},31439(e,t,r){"use strict";r.d(t,{A:()=>c});var n=r(47143),s=r(10067),o=r.n(s),i=r(51391);const a=o()("jetpack-ai-client:ask-question-sync");async function c(e,t={}){t.languageCode=t.languageCode||(0,n.select)("core").getEntityRecord("root","site")?.language||"en_US",a("Asking question with no streaming: %o. options: %o",e,t);let r=null;try{r=(await(0,i.A)()).token}catch(e){return a("Error getting token: %o",e),Promise.reject(e)}const s=Array.isArray(e)?{messages:e}:{question:e},{languageCode:o,...c}=t,l={...s,...c,language_code:o,stream:!1},u={Authorization:`Bearer ${r}`,"Content-Type":"application/json"};try{const e=await fetch("https://public-api.wordpress.com/wpcom/v2/jetpack-ai-query",{method:"POST",headers:u,body:JSON.stringify(l)}).then(e=>e.json());return e?.data?.status&&e?.data?.status>200?(a("Error generating prompt: %o",e),Promise.reject(e)):e.choices?.[0]?.message?.content}catch(e){return a("Error asking question: %o",e),Promise.reject(e)}}},57745(e,t,r){"use strict";r.d(t,{A:()=>a});var n=r(10067),s=r.n(n),o=r(51391);const i=s()("jetpack-ai-client:audio-transcription");async function a(e,t,r){i("Transcribing audio: %o. Feature: %o",e,t);let n="";try{n=(await(0,o.A)()).token}catch(e){return i("Error getting token: %o",e),Promise.reject(e)}const s=new FormData;s.append("audio_file",e);try{const e={Authorization:`Bearer ${n}`},o="https://public-api.wordpress.com/wpcom/v2/jetpack-ai-transcription"+(t?`?feature=${t}`:"");return fetch(o,{method:"POST",body:s,headers:e,signal:r??void 0}).then(e=>(i("Transcription response: %o",e),e.ok?e.json().then(e=>e?.text):e.json().then(e=>Promise.reject(e))))}catch(e){return i("Transcription error response: %o",e),Promise.reject(e)}}},70629(e,t,r){"use strict";r.d(t,{A:()=>a});var n=r(94715),s=r(13022),o=r(6754),i=(r(81443),r(10790));function a({className:e,disabled:t=!1,value:r="",placeholder:a="",isTransparent:c=!1,state:l="init",onChange:u,banner:d=null,error:p=null,actions:h=null,message:m=null,promptUserInputRef:g=null,wrapperRef:f=null}){return(0,i.jsxs)("div",{className:(0,s.A)("jetpack-components-ai-control__container-wrapper",e),ref:f,children:[p,(0,i.jsxs)("div",{className:"jetpack-components-ai-control__container",children:[d,(0,i.jsxs)("div",{className:(0,s.A)("jetpack-components-ai-control__wrapper",{"is-transparent":c}),children:[(0,i.jsx)(o.A,{state:l}),(0,i.jsx)("div",{className:"jetpack-components-ai-control__input-wrapper",children:(0,i.jsx)(n.PlainText,{value:r,onChange:u,placeholder:a,className:"jetpack-components-ai-control__input",disabled:t,ref:g})}),h]}),m]})]})}},71417(e,t,r){"use strict";r.d(t,{A:()=>_});var n=r(56427),s=r(29491),o=r(86087),i=r(27723),a=r(13109),c=r(87756),l=r(88901),u=r(65995),d=r(48568),p=r(57839),h=r(10067),m=r.n(h),g=r(51609),f=r(63098),b=r(70629),v=(r(81443),r(10790));const __=i.__,y=m()("jetpack-ai-client:block-ai-control");function k({disabled:e=!1,value:t="",placeholder:r="",showAccept:i=!1,acceptLabel:h=__("Accept","jetpack"),showButtonLabels:m=!0,isTransparent:g=!1,state:k="init",showGuideLine:_=!1,customFooter:x=null,onChange:w,onSend:j,onStop:A,onAccept:C,onDiscard:S,showRemove:E=!1,banner:T=null,error:N=null,lastAction:P},R){const L="requesting"===k||"suggesting"===k,[D,I]=(0,o.useState)(!1),[B,F]=(0,o.useState)(t||null),M=(0,o.useRef)(null);(0,o.useImperativeHandle)(R,()=>M.current),(0,o.useEffect)(()=>{D&&M?.current?.focus()},[D]);const U=(0,o.useCallback)(()=>{F(t),I(!1),j?.(t)},[t]),O=(0,o.useCallback)(e=>{w?.(e),"init"!==k&&I(B?e!==B:e.length>0)},[B,k]),z=(0,o.useCallback)(()=>{S?.()},[]),q=(0,o.useCallback)(()=>{y("cancelEdit, revert to last value",B),w?.(B||""),I(!1)},[B]);(0,s.useKeyboardShortcut)("mod+enter",()=>{i&&C?.()},{target:M}),(0,s.useKeyboardShortcut)("enter",e=>{e.preventDefault(),U()},{target:M});const $=(0,v.jsxs)(v.Fragment,{children:[(!i||D)&&(0,v.jsx)("div",{className:"jetpack-components-ai-control__controls-prompt_button_wrapper",children:L?(0,v.jsx)(n.Button,{className:"jetpack-components-ai-control__controls-prompt_button",onClick:A,variant:"secondary",label:__("Stop request","jetpack"),children:m?__("Stop","jetpack"):(0,v.jsx)(a.A,{icon:u.A})}):(0,v.jsxs)(v.Fragment,{children:[D&&(0,v.jsx)(n.Button,{className:"jetpack-components-ai-control__controls-prompt_button",onClick:q,variant:"secondary",label:__("Cancel","jetpack"),children:m?__("Cancel","jetpack"):(0,v.jsx)(a.A,{icon:u.A})}),E&&!D&&!t?.length&&S&&(0,v.jsx)(n.Button,{className:"jetpack-components-ai-control__controls-prompt_button",onClick:z,variant:"secondary",label:__("Cancel","jetpack"),children:m?__("Cancel","jetpack"):(0,v.jsx)(a.A,{icon:u.A})}),t?.length>0&&(0,v.jsx)(n.Button,{className:"jetpack-components-ai-control__controls-prompt_button",onClick:U,variant:"primary",disabled:!t?.length||e,label:__("Send request","jetpack"),children:m?__("Generate","jetpack"):(0,v.jsx)(a.A,{icon:c.A})})]})}),i&&!D&&(0,v.jsxs)("div",{className:"jetpack-components-ai-control__controls-prompt_button_wrapper",children:[(t?.length>0||null===B)&&(0,v.jsxs)(n.Flex,{gap:1,role:"group",className:"jetpack-components-ai-control__button-group",children:[(0,v.jsx)(n.Button,{className:"jetpack-components-ai-control__controls-prompt_button",label:__("Discard","jetpack"),onClick:z,tooltipPosition:"top",children:(0,v.jsx)(a.A,{icon:p.A})}),(0,v.jsx)(n.Button,{className:"jetpack-components-ai-control__controls-prompt_button",label:__("Regenerate","jetpack"),onClick:()=>j?.(t),tooltipPosition:"top",disabled:!t?.length||null===t||e,children:(0,v.jsx)(a.A,{icon:d.A})})]}),(0,v.jsx)(n.Button,{className:"jetpack-components-ai-control__controls-prompt_button",onClick:C,variant:"primary",label:h,children:m?h:(0,v.jsx)(a.A,{icon:l.A})})]})]}),H=_&&!L&&!D&&(x||(0,v.jsx)(f.Yj,{aiFeedbackThumbsOptions:{showAIFeedbackThumbs:!0,ratedItem:"ai-assistant",prompt:P,block:"ai-assistant"}}));return(0,v.jsx)(b.A,{disabled:e||L,value:t,placeholder:r,isTransparent:g,state:k,onChange:O,banner:T,error:N,actions:$,message:H,promptUserInputRef:M})}const _=(0,g.forwardRef)(k)},61(e,t,r){"use strict";r.d(t,{A:()=>f});var n=r(56427),s=r(29491),o=r(86087),i=r(27723),a=r(13109),c=r(87756),l=r(65995),u=r(84701),d=r(51609),p=r(63098),h=r(70629),m=(r(81443),r(10790));const __=i.__;function g({className:e,disabled:t=!1,value:r="",placeholder:i="",showButtonLabels:d=!0,isTransparent:g=!1,state:f="init",showGuideLine:b=!1,error:v,requestsRemaining:y,showUpgradeMessage:k=!1,showFairUsageMessage:_=!1,upgradeUrl:x,wrapperRef:w,onChange:j,onSend:A,onStop:C,onClose:S,onUndo:E,onUpgrade:T,onTryAgain:N,lastAction:P,blockType:R},L){const D="requesting"===f||"suggesting"===f,[I,B]=(0,o.useState)(!1),[F,M]=(0,o.useState)(r||null),U=(0,o.useRef)(null),O=r?.length<=0&&"done"===f;(0,o.useImperativeHandle)(L,()=>U.current),(0,o.useEffect)(()=>{I&&U?.current?.focus()},[I]);const z=(0,o.useCallback)(()=>{M(r),B(!1),A?.(r)},[A,r]),q=(0,o.useCallback)(e=>{j?.(e),"init"!==f&&B(F?e!==F:e.length>0)},[j,F,f]),$=(0,o.useCallback)(()=>{C?.()},[C]),H=(0,o.useCallback)(()=>{S?.()},[S]),V=(0,o.useCallback)(()=>{E?.()},[E]),G=(0,o.useCallback)(e=>{T?.(e)},[T]),W=(0,o.useCallback)(()=>{N?.()},[N]);(0,s.useKeyboardShortcut)("enter",e=>{e.preventDefault(),z()},{target:U});const Z=(0,m.jsx)(m.Fragment,{children:D?(0,m.jsx)(n.Button,{className:"jetpack-components-ai-control__controls-prompt_button",onClick:$,variant:"secondary",label:__("Stop request","jetpack"),children:d?__("Stop","jetpack"):(0,m.jsx)(a.A,{icon:l.A})}):(0,m.jsxs)(m.Fragment,{children:[r?.length>0&&(0,m.jsx)("div",{className:"jetpack-components-ai-control__controls-prompt_button_wrapper",children:(0,m.jsx)(n.Button,{className:"jetpack-components-ai-control__controls-prompt_button",onClick:z,variant:"primary",disabled:!r?.length||t,label:__("Send request","jetpack"),children:d?__("Generate","jetpack"):(0,m.jsx)(a.A,{icon:c.A})})}),O&&(0,m.jsx)("div",{className:"jetpack-components-ai-control__controls-prompt_button_wrapper",children:(0,m.jsxs)(n.Flex,{gap:1,role:"group",className:"jetpack-components-ai-control__button-group",children:[(0,m.jsx)(n.Button,{className:"jetpack-components-ai-control__controls-prompt_button",label:__("Undo","jetpack"),onClick:V,tooltipPosition:"top",children:(0,m.jsx)(a.A,{icon:u.A})}),(0,m.jsx)(n.Button,{className:"jetpack-components-ai-control__controls-prompt_button",label:__("Close","jetpack"),onClick:H,variant:"tertiary",children:__("Close","jetpack")})]})})]})});let J=null;return v?.message?J=(0,m.jsx)(p.Kw,{error:v.message,code:v.code,onTryAgainClick:W,onUpgradeClick:G,upgradeUrl:x}):_?J=(0,m.jsx)(p.k9,{}):k?J=(0,m.jsx)(p.AK,{requestsRemaining:y,onUpgradeClick:G,upgradeUrl:x}):b&&(J=O?(0,m.jsx)(p.Yj,{aiFeedbackThumbsOptions:{showAIFeedbackThumbs:!0,ratedItem:"ai-assistant",prompt:P,block:R}}):(0,m.jsx)(p.Yj,{})),(0,m.jsx)(h.A,{className:e,disabled:t||D,value:r,placeholder:i,isTransparent:g,state:f,onChange:q,actions:Z,message:J,promptUserInputRef:U,wrapperRef:w})}const f=(0,d.forwardRef)(g)},42299(e,t,r){"use strict";r.d(t,{FC:()=>s.A,N0:()=>n.A});r(70629);var n=r(71417),s=r(61)},11497(e,t,r){"use strict";r.d(t,{A:()=>d});var n=r(85985),s=r(56427),o=r(86087),i=r(27723),a=r(57577),c=r(44582),l=r(13022),u=(r(81913),r(10790));const __=i.__;function d({disabled:e=!1,iconSize:t=24,ratedItem:r="",feature:i="",savedRatings:d={},options:p={},onRate:h}){if(!function(e){return!0===(0,n.FB)(e).available}("ai-response-feedback"))return null;const[m,g]=(0,o.useState)({}),{tracks:f}=(0,n.st)();(0,o.useEffect)(()=>{const e={...d,...m};JSON.stringify(e)!==JSON.stringify(m)&&g(e)},[d]);const b=e=>!!m[r]&&m[r]===e,v=e=>{const t=e?"thumbs-up":"thumbs-down";b(t)||(g({...m,[r]:t}),h?.(t),f.recordEvent("jetpack_ai_feedback",{type:i,rating:t,media_library_id:p.mediaLibraryId||null,prompt:p.prompt||null,revised_prompt:p.revisedPrompt||null,block:p.block||null}))};return(0,u.jsxs)("div",{className:"ai-assistant-feedback__selection",children:[(0,u.jsx)(s.Tooltip,{text:__("I like this","jetpack"),children:(0,u.jsx)(s.Button,{disabled:e,icon:c.A,onClick:()=>v(!0),iconSize:t,showTooltip:!1,className:(0,l.A)({"ai-assistant-feedback__thumb-selected":b("thumbs-up")})})}),(0,u.jsx)(s.Tooltip,{text:__("I don't find this useful","jetpack"),children:(0,u.jsx)(s.Button,{disabled:e,icon:a.A,onClick:()=>v(!1),iconSize:t,showTooltip:!1,className:(0,l.A)({"ai-assistant-feedback__thumb-selected":b("thumbs-down")})})})]})}},23059(e,t,r){"use strict";var n=r(56427),s=r(5573),o=r(10790);n.SVG,n.G,n.Path,n.Path,n.Path,s.Defs,n.Rect},96390(e,t,r){"use strict";r(85985),r(56427),r(86087),r(27723);var n=r(10067),s=r.n(n);r(23101),r(46381),r(14016),r(57853),r(77990),r(47560),r(10169),r(10790);s()("jetpack-ai-client:ai-image-modal")},77990(e,t,r){"use strict";r(56427),r(86087),r(27723),r(11497),r(23059),r(79209),r(10790)},47560(e,t,r){"use strict";r(86087),r(27723),r(97011),r(10790)},89289(e,t,r){"use strict";r(85985),r(56427),r(47143),r(43656),r(86087),r(27723);var n=r(10067),s=r.n(n);r(54339),r(43984),r(72448),r(71508),r(62038),r(96390),r(3620),r(35918),r(10790);s()("jetpack-ai-client:featured-image")},83158(e,t,r){"use strict";r(85985),r(56427),r(86087),r(27723);var n=r(10067),s=r.n(n);r(54339),r(72448),r(71508),r(62038),r(96390),r(3620),r(35918),r(10790);s()("jetpack-ai:general-purpose-image")},3620(e,t,r){"use strict";r(47143),r(86087),r(27723),r(93832),r(31439),r(72448),r(62614),r(62038)},35918(e,t,r){"use strict";r(97999),r(86087)},77089(e,t,r){"use strict";r(89289),r(83158)},46381(e,t,r){"use strict";r.d(t,{A:()=>l});var n=r(56427),s=r(86087),o=r(27723),i=r(13109),a=r(28847),c=(r(557),r(10790));const __=o.__;function l({onGuidelinesClick:e,onFeedbackClick:t}){const r=(0,s.useCallback)(()=>{e?.()},[e]),o=(0,s.useCallback)(()=>{t?.()},[t]);return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsxs)("div",{className:"ai-image-modal__footer-disclaimer",children:[(0,c.jsx)(i.A,{icon:a.A}),(0,c.jsx)("span",{children:__("Generated images could be inaccurate, biased or include text.","jetpack")}),(0,c.jsx)(n.Button,{variant:"link",className:"ai-image-modal__guidelines-button",href:"https://jetpack.com/redirect/?source=ai-guidelines",target:"_blank",onClick:r,children:(0,c.jsxs)("span",{children:[__("Guidelines","jetpack")," ↗"]})})]}),(0,c.jsx)(n.Button,{variant:"link",className:"ai-image-modal__feedback-button",href:"https://jetpack.com/redirect/?source=jetpack-ai-feedback",target:"_blank",onClick:o,children:(0,c.jsxs)("span",{children:[__("Give feedback","jetpack")," ↗"]})})]})}},6754(e,t,r){"use strict";r.d(t,{A:()=>i});var n=r(56427),s=r(13022),o=(r(93208),r(10790));function i({state:e}){return(0,o.jsx)("div",{className:(0,s.A)("jetpack-ai-status-indicator__icon-wrapper",{[`is-${e}`]:!0}),children:(0,o.jsx)(n.Spinner,{})})}},68203(e,t,r){"use strict";r.d(t,{A:()=>o});var n=r(32569),s=r(10790);function o({duration:e,className:t}){return(0,s.jsx)("span",{className:t,children:(0,n.f)(e,{addDecimalPart:!1})})}},32569(e,t,r){"use strict";function n(e,{addDecimalPart:t=!1,showMinutes:r=!0,showHours:n=!1}={}){const s=Math.floor(e/36e5),o=Math.floor(e/6e4)%60,i=Math.floor(e/1e3)%60,a=Math.floor(e/10)%100,c=[s>0||n?s.toString().padStart(2,"0")+":":"",s>0||o>0||r?o.toString().padStart(2,"0")+":":"",i.toString().padStart(2,"0")];return t&&c.push("."+a.toString().padStart(2,"0")),c.join("")}r.d(t,{f:()=>n})},27802(e,t,r){"use strict";r.d(t,{AK:()=>o.AK,FC:()=>n.FC,Hb:()=>i.A,N0:()=>n.N0,QA:()=>i.Q,z3:()=>s.A});var n=r(42299),s=(r(11497),r(23059),r(77089),r(6754),r(68203)),o=(r(46381),r(63098)),i=(r(14016),r(57853))},63098(e,t,r){"use strict";r.d(t,{AK:()=>x,Kw:()=>w,Yj:()=>k,k9:()=>_});var n=r(56427),s=r(86087),o=r(27723),i=r(13109),a=r(88901),c=r(13022),l=(r(11008),r(42154)),u=r(78836),d=r(11497),p=r(10790);const __=o.__,h="warning",m="error",g="success",f="info",b={[f]:null,[h]:null,[m]:l.A,[g]:a.A};function v({severity:e=f,icon:t=null,aiFeedbackThumbsOptions:r={showAIFeedbackThumbs:!1,ratedItem:"",prompt:"",block:null,onRate:()=>{}},children:n}){return(0,p.jsxs)("div",{className:(0,c.A)("jetpack-ai-assistant__message",`jetpack-ai-assistant__message-severity-${e}`),children:[(b[e]||t)&&(0,p.jsx)(i.A,{icon:b[e]||t}),(0,p.jsx)("div",{className:"jetpack-ai-assistant__message-content",children:n}),r.showAIFeedbackThumbs&&r.prompt&&(0,p.jsx)(d.A,{disabled:!1,ratedItem:r.ratedItem,feature:"ai-assistant",options:{prompt:r.prompt,block:r.block},onRate:r.onRate})]})}function y(){return(0,p.jsx)(n.ExternalLink,{href:"https://jetpack.com/redirect/?source=ai-guidelines",children:__("Learn more","jetpack")})}function k({aiFeedbackThumbsOptions:e={showAIFeedbackThumbs:!1,ratedItem:"",prompt:"",block:null,onRate:()=>{}}}){return(0,p.jsxs)(v,{aiFeedbackThumbsOptions:e,children:[(0,p.jsx)("span",{children:__("AI-generated content could be inaccurate or biased.","jetpack")}),(0,p.jsx)(y,{})]})}function _(){const e=__("You've reached this month's request limit, per our fair usage policy","jetpack"),t=(0,s.createInterpolateElement)(e,{link:(0,p.jsx)(n.ExternalLink,{href:"https://jetpack.com/redirect/?source=ai-assistant-fair-usage-policy",children:null})});return(0,p.jsx)(v,{severity:h,children:t})}function x({requestsRemaining:e,severity:t,onUpgradeClick:r,upgradeUrl:s}){let i=t;return null==i&&(i=e>0?f:h),(0,p.jsxs)(v,{severity:i,children:[(0,p.jsx)("span",{children:(0,o.sprintf)( // translators: %1$d: number of requests remaining __("You have %1$d requests remaining.","jetpack"),e)}),(0,p.jsx)(n.Button,{variant:"link",onClick:r,href:s,target:s?"_blank":null,children:(0,p.jsx)("span",{children:__("Upgrade now","jetpack")})})]})}function w({error:e,code:t,onTryAgainClick:r,onUpgradeClick:s,upgradeUrl:i}){const a=e||__("Something went wrong","jetpack");return(0,p.jsxs)(v,{severity:m,children:[(0,p.jsx)("span",{children:(0,o.sprintf)( // translators: %1$d: A dynamic error message __("Error: %1$s","jetpack"),a)}),t===u.Or?(0,p.jsx)(n.Button,{variant:"link",onClick:s,href:i,target:i?"_blank":null,children:(0,p.jsx)("span",{children:__("Upgrade now","jetpack")})}):(0,p.jsx)(n.Button,{variant:"link",onClick:r,children:(0,p.jsx)("span",{children:__("Try again","jetpack")})})]})}},14016(e,t,r){"use strict";r(56427),r(27723),r(6754),r(28494),r(10790)},57853(e,t,r){"use strict";r.d(t,{A:()=>b,Q:()=>f});var n=r(3924),s=r(85985),o=r(82201),i=r(56427),a=r(86087),c=r(27723),l=r(10067),u=r.n(l),d=r(42694),p=r(72448),h=r(71567),m=(r(17277),r(10790));const __=c.__,g=u()("jetpack-ai-client:upgrade-prompt"),f=({variant:e="error"})=>{const t=(()=>{const{usagePeriod:e}=(0,p.A)(),t=(e=>{const t=__("You've reached this month's request limit, per our fair usage policy.","jetpack");if(!e)return t; // Translators: %s is the date when the requests will reset. const r=__("Requests will reset on %s.","jetpack");return`${t} ${(0,c.sprintf)(r,e)}`})((e=>{if(!e?.nextStart)return null;const t=new Date(e.nextStart);return t.toLocaleString("default",{month:"long"})+" "+t.getDate()})(e));return(0,a.createInterpolateElement)(t,{link:(0,m.jsx)("a",{href:"https://jetpack.com/redirect/?source=ai-assistant-fair-usage-policy",target:"_blank",rel:"noreferrer"}),span:(0,m.jsx)("span",{})})})();return"muted"===e?(0,m.jsx)("span",{className:"jetpack-ai-fair-usage-notice-muted-variant",children:t}):"error"===e?(0,m.jsx)(i.Notice,{status:"error",isDismissible:!1,className:"jetpack-ai-fair-usage-notice",children:t}):null},b=e=>{const{upgradeType:t,currentTier:r}=(0,p.A)();return 1===r?.value?(0,m.jsx)(f,{}):"vip"===t?(({description:e=null,useLightNudge:t=!1})=>{const r=t?h.U:o.cb,n=(0,a.createInterpolateElement)(__("You've reached the Jetpack AI rate limit. Please reach out to your VIP account team.","jetpack"),{strong:(0,m.jsx)("strong",{})});return(0,m.jsx)(r,{buttonText:null,checkoutUrl:null,className:"jetpack-ai-upgrade-banner",description:e||n,goToCheckoutPage:null,isRedirecting:null,visible:!0,align:null,title:null,context:null})})({description:e.description,useLightNudge:e?.useLightNudge}):(({placement:e=null,description:t=null,useLightNudge:r=!1})=>{const i=r?h.U:o.cb,{checkoutUrl:l}=(0,d.A)(),u=(0,s.CP)(),{nextTier:f,tierPlansEnabled:b,currentTier:v,requestsCount:y}=(0,p.A)(),{tracks:k}=(0,s.st)(),_=(0,a.useCallback)(()=>{g("upgrade",e),k.recordEvent("jetpack_ai_upgrade_button",{current_tier_slug:v?.slug,requests_count:y,placement:e})},[v,y,k,e]),x=(0,a.useCallback)(()=>{g("contact us",e),k.recordEvent("jetpack_ai_upgrade_contact_us",{placement:e})},[k,e]);if(!u){const e=(0,a.createInterpolateElement)(__("Congratulations on exploring Jetpack AI and reaching the free requests limit! Reach out to the site administrator to upgrade and keep using Jetpack AI.","jetpack"),{strong:(0,m.jsx)("strong",{})});return(0,m.jsx)(i,{showButton:!1,className:"jetpack-ai-upgrade-banner",description:t||e,visible:!0,align:null,title:null,context:null})}if(b){if(!f){const e=(0,n.A)("jetpack-ai-tiers-more-requests-contact"),r=__("You have reached the request limit for your current plan.","jetpack");return(0,m.jsx)(i,{buttonText:__("Contact Us","jetpack"),description:t||r,className:"jetpack-ai-upgrade-banner",checkoutUrl:e,visible:!0,align:null,title:null,context:null,goToCheckoutPage:x,target:"_blank"})}const e=(0,a.createInterpolateElement)((0,c.sprintf)(/* Translators: %d: the number of requests allowed */ __("You have reached the requests limit for your current plan. Upgrade now to increase your requests limit to %d.","jetpack"),f.limit),{strong:(0,m.jsx)("strong",{})});return(0,m.jsx)(i,{buttonText:(0,c.sprintf)(/* Translators: %d: the number of requests */ __("Upgrade to %d requests","jetpack"),f.limit),checkoutUrl:l,className:"jetpack-ai-upgrade-banner",description:t||e,goToCheckoutPage:_,visible:!0,align:"center",title:null,context:null,target:"_blank"})}return(0,m.jsx)(i,{buttonText:__("Upgrade","jetpack"),checkoutUrl:l,className:"jetpack-ai-upgrade-banner",description:(0,a.createInterpolateElement)(__("Congratulations on exploring Jetpack AI and reaching the free requests limit! Upgrade now to keep using it.","jetpack"),{strong:(0,m.jsx)("strong",{})}),goToCheckoutPage:_,visible:!0,align:null,title:null,context:null,target:"_blank"})})(e)}},71567(e,t,r){"use strict";r.d(t,{U:()=>i});var n=r(56427),s=r(27723),o=(r(17277),r(10790));const __=s.__,i=({title:e,description:t,buttonText:r=null,checkoutUrl:s=null,goToCheckoutPage:i=null,isRedirecting:a=!1,showButton:c=!0,target:l="_top"})=>{const u=__("Redirecting…","jetpack");return(0,o.jsx)("div",{className:"jetpack-upgrade-plan-banner-light",children:(0,o.jsx)(n.Notice,{status:"error",isDismissible:!1,children:(0,o.jsxs)("p",{children:[e&&(0,o.jsx)("strong",{children:e}),t," ",c&&(0,o.jsx)(n.Button,{href:a?null:s,onClick:i,variant:"link",target:l,children:(0,o.jsx)("span",{children:a?u:r})})]})})})}},43984(e,t,r){"use strict";r.d(t,{A4:()=>c,DD:()=>x,DT:()=>P,Gm:()=>g,HM:()=>w,JR:()=>j,K2:()=>C,Rq:()=>N,UA:()=>m,UD:()=>A,br:()=>d,d5:()=>v,eJ:()=>h,fD:()=>p,fv:()=>y,im:()=>i,mI:()=>S,mT:()=>T,oZ:()=>o,pE:()=>f,sn:()=>a,so:()=>s,u0:()=>k,uQ:()=>_,vE:()=>u,yQ:()=>E,yy:()=>l,z5:()=>b});var n=r(27723);const __=n.__,s={en:{label:__("English","jetpack")},es:{label:__("Spanish","jetpack")},fr:{label:__("French","jetpack")},de:{label:__("German","jetpack")},it:{label:__("Italian","jetpack")},pt:{label:__("Portuguese","jetpack")},ru:{label:__("Russian","jetpack")},zh:{label:__("Chinese","jetpack")},ja:{label:__("Japanese","jetpack")},ar:{label:__("Arabic","jetpack")},hi:{label:__("Hindi","jetpack")},ko:{label:__("Korean","jetpack")}},o={formal:{label:__("Formal","jetpack"),emoji:"🎩"},informal:{label:__("Informal","jetpack"),emoji:"😊"},optimistic:{label:__("Optimistic","jetpack"),emoji:"😃"},humorous:{label:__("Humorous","jetpack"),emoji:"😂"},serious:{label:__("Serious","jetpack"),emoji:"😐"},skeptical:{label:__("Skeptical","jetpack"),emoji:"🤨"},empathetic:{label:__("Empathetic","jetpack"),emoji:"💗"},confident:{label:__("Confident","jetpack"),emoji:"😎"},passionate:{label:__("Passionate","jetpack"),emoji:"❤️"},provocative:{label:__("Provocative","jetpack"),emoji:"🔥"}},i="titleSummary",a="continue",c="simplify",l="correctSpelling",u="generateTitle",d="makeLonger",p="makeShorter",h="changeTone",m="summarize",g="changeLanguage",f="userPrompt",b="jetpackFormCustomPrompt",v="transformListToTable",y="writePostFromList",k=__("Translate","jetpack"),_=__("Change tone","jetpack"),x=__("Correct spelling and grammar","jetpack"),w=__("Simplify","jetpack"),j=__("Summarize","jetpack"),A=__("Make shorter","jetpack"),C=__("Expand","jetpack"),S=__("Turn list into a table","jetpack"),E=__("Write a post from this list","jetpack"),T=__("Generate a post title","jetpack"),N=__("Summary based on title","jetpack"),P=__("Continue writing","jetpack")},2166(e,t,r){"use strict";r.d(t,{R:()=>i});var n=r(51609),s=r(10790);const o=(0,n.createContext)({}),i=({value:e,children:t})=>(0,s.jsx)(o.Provider,{value:e,children:t})},13965(e,t,r){"use strict";r.d(t,{Rb:()=>n.R});var n=r(2166);r(59886),r(53471)},53471(e,t,r){"use strict";r(51609),r(78836),r(13965)},59886(e,t,r){"use strict";var n=r(29491),s=r(86087),o=r(46219),i=r(13965),a=r(10790);(0,n.createHigherOrderComponent)(e=>t=>{const{suggestion:r,error:n,requestingState:c,request:l,stopSuggestion:u,eventSource:d}=(0,o.Ay)(),p=(0,s.useMemo)(()=>({suggestion:r,requestingError:n,requestingState:c,eventSource:d,requestSuggestion:l,stopSuggestion:u}),[r,n,c,d,l,u]);return(0,a.jsx)(i.Rb,{value:p,children:(0,a.jsx)(e,{...t})})},"withAiDataProvider")},42694(e,t,r){"use strict";r.d(t,{A:()=>a});var n=r(3924),s=r(97999),o=r(85985),i=r(72448);function a(){const{nextTier:e,tierPlansEnabled:t}=(0,i.A)(),r=(()=>{const e=new URLSearchParams(window.location.search),t=(0,o.GE)();return(0,s.isSimpleSite)()&&e.has("post")?`https://wordpress.com/post/${t}/${e.get("post")}`:`https://wordpress.com/home/${t}`})(),a=(0,n.A)("jetpack-ai-yearly-tier-upgrade-nudge",{site:(0,o.GE)(),path:t?`jetpack_ai_yearly:-q-${e?.limit}`:"jetpack_ai_yearly",query:`redirect_to=${encodeURIComponent(r)}`}),c=(0,n.A)("jetpack-ai-upgrade-url-for-jetpack-sites",{site:(0,o.GE)(),path:"jetpack_ai_yearly"}),l=(0,s.isWpcomPlatformSite)()?a:c,{autosaveAndRedirect:u,isRedirecting:d}=(0,o.ZR)(l);return{checkoutUrl:l,autosaveAndRedirect:u,isRedirecting:d}}},72448(e,t,r){"use strict";r.d(t,{A:()=>i});var n=r(85985),s=r(47143),o=r(86087);function i(){const e=(0,s.useSelect)(e=>e("wordpress-com/plans").getAiAssistantFeature(),[]),t=(0,s.useSelect)(e=>e("wordpress-com/plans").getIsRequestingAiAssistantFeature(),[]),{fetchAiAssistantFeature:r,increaseAiAssistantRequestsCount:i,dequeueAiAssistantFeatureAsyncRequest:a}=(0,s.useDispatch)("wordpress-com/plans");return(0,o.useMemo)(()=>{const s=(0,n.Bd)(e?.currentTier),o=e?.currentTier?.limit||e?.requestsLimit,c=s===n._X?e?.requestsCount:e?.usagePeriod?.requestsCount,l=s===n._X?e?.requestsLimit:o;return{...e,requestsCount:c,requestsLimit:l,loading:t,error:null,refresh:r,increaseRequestsCount:i,dequeueAsyncRequest:a}},[e,t,r,i,a])}},46219(e,t,r){"use strict";r.d(t,{Ay:()=>p,fC:()=>u});var n=r(86087),s=r(27723),o=r(10067),i=r.n(o),a=r(87286),c=r(78836);const __=s.__,l=i()("ai-client:use-ai-suggestions");function u(e){switch(e){case c.Or:return{code:c.Or,message:__("You have reached the limit of requests for this site.","jetpack"),severity:"info"};case c.L9:return{code:c.L9,message:__("Your request was unclear. Mind trying again?","jetpack"),severity:"info"};case c.AZ:return{code:c.AZ,message:__("Jetpack AI services are currently unavailable. Sorry for the inconvenience.","jetpack"),severity:"info"};case c.ud:return{code:c.ud,message:__("Our service provider OpenAI could not process your prompt due to a moderation system. Please try to rephrase it changing potentially problematic words and try again.","jetpack"),severity:"info"};case c.cT:return{code:c.cT,message:__("The content is too large to be processed all at once. Please try to shorten it or divide it into smaller parts.","jetpack"),severity:"info"};case c.mA:default:return{code:c.mA,message:__("It was not possible to process your request. Mind trying again?","jetpack"),severity:"info"}}}function d(e){return e.replace(/^<\|start_header_id\|>assistant<\|end_header_id\|>[\n]+/,"")}function p({prompt:e,autoRequest:t=!1,askQuestionOptions:r={},initialRequestingState:s="init",onSuggestion:o,onDone:i,onStop:p,onError:h,onAllErrors:m}={}){const[g,f]=(0,n.useState)(s),[b,v]=(0,n.useState)(""),[y,k]=(0,n.useState)(c.Np),_=(0,n.useRef)(c.Np),[x,w]=(0,n.useState)(),j=(0,n.useRef)(void 0),A=(0,n.useCallback)(e=>{l("handleSuggestion",e);const t=d(e?.detail);t?(v(t),o?.(t)):l("no partial suggestion")},[o]),C=(0,n.useCallback)(e=>{B();const t=d(e?.detail?.message??e?.detail);i?.(t,_.current),f("done")},[i]),S=(0,n.useCallback)(e=>{m?.(e?.detail)},[m]),E=(0,n.useCallback)(e=>{j?.current?.close(),f("error"),w(u(e)),h?.(u(e))},[h]),T=(0,n.useCallback)(()=>E(c.Or),[]),N=(0,n.useCallback)(()=>E(c.L9),[]),P=(0,n.useCallback)(()=>E(c.AZ),[]),R=(0,n.useCallback)(()=>E(c.ud),[]),L=(0,n.useCallback)(()=>E(c.mA),[]),D=(0,n.useCallback)(async(e,t={...r})=>{var n;if(w(void 0),f("requesting"),n=c.Np,k(n),_.current=n,j.current=await(0,a.A)(e,t),!j?.current)return void l("no event source");const s=j.current;f("suggesting"),s.addEventListener("suggestion",A),s.addEventListener(c.Or,T),s.addEventListener(c.L9,N),s.addEventListener(c.AZ,P),s.addEventListener(c.ud,R),s.addEventListener(c.mA,L),s.addEventListener(c.zn,S),s.addEventListener("done",C)},[C,T,N,P,R,L,A]),I=(0,n.useCallback)(()=>{f("init"),v(""),w(void 0)},[]),B=(0,n.useCallback)(()=>{if(!j?.current)return;const e=j?.current;e.close(),e.removeEventListener("suggestion",A),e.removeEventListener(c.Or,T),e.removeEventListener(c.L9,N),e.removeEventListener(c.AZ,P),e.removeEventListener(c.ud,R),e.removeEventListener(c.mA,L),e.removeEventListener("done",C)},[j,A,T,N,P,R,L,C]),F=(0,n.useCallback)(()=>{B(),p?.(),f("done")},[p]);return(0,n.useEffect)(()=>{if(e?.length)return t&&D(e,r),()=>{F()}},[t,e,D,F]),{suggestion:b,model:y,error:x,requestingState:g,request:D,stopSuggestion:F,reset:I,handleErrorQuotaExceededError:T,eventSource:j.current}}},7804(e,t,r){"use strict";r.d(t,{A:()=>l});var n=r(86087),s=r(27723),o=r(10067),i=r.n(o),a=r(57745);const __=s.__,c=i()("jetpack-ai-client:use-audio-transcription");function l({feature:e,onReady:t,onError:r}){const[s,o]=(0,n.useState)(""),[i,l]=(0,n.useState)(""),[u,d]=(0,n.useState)(!1),p=(0,n.useRef)(null);return{transcriptionResult:s,isTranscribingAudio:u,transcriptionError:i,transcribeAudio:(0,n.useCallback)(n=>{c("Transcribing audio"),o(""),l(""),d(!0);const s=new AbortController;p.current=s,(0,a.A)(n,e,s.signal).then(e=>{o(e),t?.(e)}).catch(e=>{s.signal.aborted||(l(e.message),r?.((e=>{if("string"==typeof e)return e;if("code"in e)switch(e.code){case"error_quota_exceeded":return __("You exceeded your current quota, please check your plan details.","jetpack");case"jetpack_ai_missing_audio_param":return __("The audio_file is required to perform a transcription.","jetpack");case"jetpack_ai_service_unavailable":return __("The Jetpack AI service is temporarily unavailable.","jetpack");case"file_size_not_supported":return __("The provided audio file is too big.","jetpack");case"file_type_not_supported":return __("The provided audio file type is not supported.","jetpack");case"jetpack_ai_error":return __("There was an error processing the transcription request.","jetpack");default:return e.message}return"message"in e?e.message:__("There was an error processing the transcription request.","jetpack")})(e)))}).finally(()=>d(!1))},[a.A,o,l,d]),cancelTranscription:(0,n.useCallback)(()=>{p.current?.abort(),o(""),l(""),d(!1)},[p,o,l,d])}}},66859(e,t,r){"use strict";r.d(t,{A:()=>i});var n=r(86087),s=r(27723);const __=s.__,o=["audio/mpeg","audio/mp3","audio/ogg","audio/flac","audio/x-flac","audio/m4a","audio/x-m4a","audio/mp4","audio/wav","audio/wave","audio/x-wav","audio/webm"];function i(){const[e,t]=(0,n.useState)(!1);return{isValidatingAudio:e,validateAudio:(0,n.useCallback)((e,r,n)=>{if(t(!0),e?.size>25e6)return t(!1),n(__("The audio file is too large. The maximum file size is 25MB.","jetpack"));const s=e instanceof File;if(s&&!o.includes(e.type))return t(!1),n(__("The audio file type is not supported. Please use a supported audio file type.","jetpack"));const i=new AudioContext;e.arrayBuffer().then(o=>{i.decodeAudioData(o,function(o){const i=Math.ceil(o.duration);return i>1500?(t(!1),n(__("The audio file is too long. The maximum recording time is 25 minutes.","jetpack"))):(t(!1),r({duration:i,isFile:s,size:e?.size}))})})},[t])}}},66223(e,t,r){"use strict";r.d(t,{Hu:()=>s,Wp:()=>n});const n="auto",s="none"},62614(e,t,r){"use strict";r.d(t,{Ay:()=>u});var n=r(10067),s=r.n(n),o=r(31439),i=r(51391);const a=s()("ai-client:use-image-generator"),c=(e,t)=>{const r=4e3-t;return e.length>r?e.substring(0,r-6)+" [...]":e},l=async(e,t,r)=>{const n=((e,t)=>{if(t){const r=`I need a Stable Diffusion prompt to generate a featured image for a blog post based on this user-provided image description:\n\n${t.length>1e3?t.substring(0,1e3):t}\n\nThe image should be a photo. Make sure you highlight the main suject of the image description, and include brief details about the light and style of the image.\nInclude a request to use high resolution and produce a highly detailed image, with sharp focus.\nReturn just the prompt, without comments.\n\nFor additional context, this is the post content:\n\n`;return r+c(e,r.length)}return"I need a Stable Diffusion prompt to generate a featured image for a blog post with the following content.\nThe image should be a photo. Make sure you highlight the main suject of the content, and include brief details about the light and style of the image.\nInclude a request to use high resolution and produce a highly detailed image, with sharp focus.\nReturn just the prompt, without comments. The content is:\n\n"+c(e,412)})(e,t);return await(0,o.A)(n,{feature:r})},u=()=>{const e=async function(e){let t="";try{t=(await(0,i.A)()).token}catch(e){return a("Error getting token: %o",e),Promise.reject(e)}try{const r="https://public-api.wordpress.com/wpcom/v2/jetpack-ai-image",n={Authorization:`Bearer ${t}`,"Content-Type":"application/json"},s=await fetch(r,{method:"POST",headers:n,body:JSON.stringify(e)}).then(e=>e.json());return s?.data?.status&&s?.data?.status>200?(a("Error generating image: %o",s),Promise.reject(s)):s}catch(e){return a("Error generating image: %o",e),Promise.reject(e)}};return{generateImage:async function({feature:t,postContent:r,responseFormat:n="url",userPrompt:s}){try{a("Generating image");const o=((e,t)=>{if(t){const r=`I need a cover image for a blog post based on this user prompt:\n\n${t.length>1e3?t.substring(0,1e3):t}\n\nBefore creating the image, identify the main topic of the user prompt and relate it to the post content.\nDo not represent the whole content in one image, keep it simple and just represent one single idea.\nDo not add details, detailed explanations or highlights from the content, just represent the main idea as if it was a photograph.\nDo not use collages or compositions with multiple elements or scenes. Stick to one single scene. Do not compose unrealistic scenes.\nIf the content describes facts, objects or concepts from the real world, represent them on a realistic style and do not make unreal compositions.\nIf the content is more abstract, use a more abstract style to represent the main idea.\nMake sure the light and the style are visually appealing.\nDo not add text to the image.\n\nFor additional context, this is the post content:\n\n`;return r+c(e,r.length)}const r="I need a cover image for a blog post.\nBefore creating the image, identify the main topic of the content and only represent it.\nDo not represent the whole content in one image, keep it simple and just represent one single idea.\nDo not add details, detailed explanations or highlights from the content, just represent the main idea as if it was a photograph.\nDo not use collages or compositions with multiple elements or scenes. Stick to one single scene. Do not compose unrealistic scenes.\nIf the content describes facts, objects or concepts from the real world, represent them on a realistic style and do not make unreal compositions.\nIf the content is more abstract, use a more abstract style to represent the main idea.\nMake sure the light and the style are visually appealing.\nDo not add text to the image.\n\nThis is the post content:\n\n";return r+c(e,838)})(r,s),i={prompt:o,response_format:n,feature:t,size:"1792x1024"};return await e(i)}catch(e){return a("Error generating image: %o",e),Promise.reject(e)}},generateImageWithStableDiffusion:async function({feature:t,postContent:r,userPrompt:n}){try{a("Generating image with Stable Diffusion");const s={prompt:await l(r,n,t),feature:t,model:"stable-diffusion"};return await e(s)}catch(e){return a("Error generating image: %o",e),Promise.reject(e)}},generateImageWithParameters:e}}},96657(e,t,r){"use strict";r.d(t,{A:()=>i});var n=r(86087);const s="audio/mp4;codecs=mp4a",o="audio/webm";function i({onDone:e}={}){const t=(0,n.useRef)(null),[r,i]=(0,n.useState)("inactive"),a=(0,n.useRef)(!1),c=(0,n.useRef)(0),[l,u]=(0,n.useState)(0),d=(0,n.useRef)(null),[p,h]=(0,n.useState)(null),m=(0,n.useRef)([]).current,[g,f]=(0,n.useState)(null),b=(0,n.useRef)(null);function v(){return MediaRecorder.isTypeSupported(s)?new Blob(m,{type:"audio/mp4"}):new Blob(m,{type:o})}const y=(0,n.useCallback)(e=>{if(w(),!e)return t?.current?.start();e<100&&(e=100),c.current=Date.now(),t?.current?.start(e)},[]),k=(0,n.useCallback)(()=>{a.current=!0,t?.current?.pause(),u(e=>e+Date.now()-c.current)},[]),_=(0,n.useCallback)(()=>{a.current=!1,t?.current?.resume(),c.current=Date.now()},[]),x=(0,n.useCallback)(()=>{t?.current?.stop(),"recording"===r&&u(e=>e+Date.now()-c.current)},[]),w=(0,n.useCallback)(()=>{m.length=0,h(null),f(null),u(0),a.current=!1,c.current=0},[]),j=(0,n.useCallback)(()=>{t?.current&&(t.current.removeEventListener("start",S),t.current.removeEventListener("stop",E),t.current.removeEventListener("pause",T),t.current.removeEventListener("resume",N),t.current.removeEventListener("dataavailable",P),t.current=null)},[]),A=(0,n.useCallback)(()=>{if(i("inactive"),w(),j(),!navigator.mediaDevices?.getUserMedia)return;const e=new AudioContext;b.current=e.createAnalyser();navigator.mediaDevices.getUserMedia({audio:!0}).then(r=>{d.current=r;e.createMediaStreamSource(r).connect(b.current),MediaRecorder.isTypeSupported(s)?t.current=new MediaRecorder(r,{mimeType:s}):t.current=new MediaRecorder(r,{mimeType:o}),t.current.addEventListener("start",S),t.current.addEventListener("stop",E),t.current.addEventListener("pause",T),t.current.addEventListener("resume",N),t.current.addEventListener("dataavailable",P)}).catch(e=>{throw e})},[]),C=(0,n.useCallback)(e=>{x(),f("string"==typeof e?e:e.message),i("error")},[]);function S(){i("recording")}function E(){const t=v();e?.(t),m.length=0}function T(){i("paused")}function N(){i("recording")}function P(e){const{data:t}=e;t?.size&&(m.push(t),h(v()),a.current||u(e=>{const t=Date.now(),r=t-c.current;return c.current=t,e+r}))}return(0,n.useEffect)(()=>(A(),()=>{d.current&&d.current.getTracks().forEach(e=>e.stop()),j()}),[]),{state:r,blob:p,error:g,duration:l,analyser:b.current,onError:C,controls:{start:y,pause:k,resume:_,stop:x,reset:A}}}},71508(e,t,r){"use strict";r.d(t,{A:()=>c});var n=r(74997),s=r(47143),o=r(43656),i=r(86087),a=r(55166);const c=()=>{const{getBlocks:e,isEditedPostEmpty:t}=(0,s.useSelect)(e=>{const t=e("core/block-editor"),r=e(o.store);return{getBlocks:t.getBlocks,isEditedPostEmpty:r.isEditedPostEmpty}},[]),r=(0,i.useCallback)(()=>{const t=e();return 0===t.length?"":(0,n.serialize)(t)},[e]);return{getPostContent:(0,i.useCallback)(e=>{let t=r();return t?(e&&"function"==typeof e&&(t=e(t)),t?(0,a.rh)({content:t}):""):""},[e]),isEditedPostEmpty:t,getSerializedPostContent:r}}},62038(e,t,r){"use strict";r(63162),r(47143),r(86087);var n=r(10067);r.n(n)()("jetpack-ai-client:save-to-media-library")},93869(e,t,r){"use strict";r.d(t,{A:()=>c});var n=r(63162),s=r(47143),o=r(86087),i=r(10067);const a=r.n(i)()("ai-client:save-to-media-library");function c(){const[e,t]=(0,o.useState)(!1),{getSettings:r}=(0,s.useSelect)(e=>e("core/block-editor"),[]);return{isLoading:e,saveToMediaLibrary:(e,s)=>{const o=r();return new Promise((r,i)=>{t(!0),a("Fetching image from URL"),fetch(e).then(e=>{a("Transforming response to blob"),e.blob().then(e=>{a("Uploading blob to media library");const c=Array();s?c.push(new File([e],s)):c.push(e),o.mediaUpload({allowedTypes:["image"],filesList:c,onFileChange([e]){(0,n.isBlobURL)(e?.url)||(e&&(a("Image uploaded to media library",e),r(e)),t(!1))},onError(e){a("Error uploading image to media library:",e),i(e),t(!1)}})}).catch(e=>{a("Error transforming response to blob:",e?.message),i(e?.message),t(!1)})}).catch(e=>{a("Error fetching image from URL:",e?.message),i(e?.message),t(!1)})})}}}},97784(e,t,r){"use strict";r.d(t,{A:()=>l,u:()=>c});var n=r(86087),s=r(10067),o=r.n(s),i=r(46219);const a=o()("jetpack-ai-client:use-transcription-post-processing"),c="voice-to-content-simple-draft";function l({feature:e,onReady:t,onError:r,onUpdate:s}){const[o,c]=(0,n.useState)(""),[l,u]=(0,n.useState)(""),[d,p]=(0,n.useState)(!1),h=(0,n.useCallback)(e=>{c(e),s?.(e)},[c,s]),m=(0,n.useCallback)(e=>{c(e),s?.(e),t?.(e)},[c,s,t]),g=(0,n.useCallback)(e=>{u(e.message),r?.(e.message)},[u,r]),{request:f,stopSuggestion:b}=(0,i.Ay)({onSuggestion:h,onDone:m,onError:g});return{postProcessingResult:o,isProcessingTranscription:d,postProcessingError:l,processTranscription:(0,n.useCallback)((t,r)=>{a("Post-processing transcription"),c(""),u(""),p(!0);f([{role:"jetpack-ai",context:{type:t,content:r}}],{feature:e})},[c,u,p,f,e]),cancelTranscriptionProcessing:(0,n.useCallback)(()=>{b(),p(!1)},[b,p])}}},30151(e,t,r){"use strict";r.d(t,{A:()=>o});var n=r(56427),s=r(10790);const o=(0,s.jsxs)(n.SVG,{viewBox:"0 0 32 32",width:"32",height:"32",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",className:"ai-assistant-icon",children:[(0,s.jsx)(n.Path,{className:"spark-first",d:"M9.33301 5.33325L10.4644 8.20188L13.333 9.33325L10.4644 10.4646L9.33301 13.3333L8.20164 10.4646L5.33301 9.33325L8.20164 8.20188L9.33301 5.33325Z"}),(0,s.jsx)(n.Path,{className:"spark-second",d:"M21.3333 5.33333L22.8418 9.15817L26.6667 10.6667L22.8418 12.1752L21.3333 16L19.8248 12.1752L16 10.6667L19.8248 9.15817L21.3333 5.33333Z"}),(0,s.jsx)(n.Path,{className:"spark-third",d:"M14.6667 13.3333L16.5523 18.1144L21.3333 20L16.5523 21.8856L14.6667 26.6667L12.781 21.8856L8 20L12.781 18.1144L14.6667 13.3333Z"})]})},42154(e,t,r){"use strict";r.d(t,{A:()=>o});var n=r(56427),s=r(10790);const o=(0,s.jsxs)(n.SVG,{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,s.jsx)(n.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M10 3.95833C6.66328 3.95833 3.95833 6.66327 3.95833 9.99999C3.95833 13.3367 6.66328 16.0417 10 16.0417C13.3367 16.0417 16.0417 13.3367 16.0417 9.99999C16.0417 6.66327 13.3367 3.95833 10 3.95833ZM2.70833 9.99999C2.70833 5.97292 5.97292 2.70833 10 2.70833C14.0271 2.70833 17.2917 5.97292 17.2917 9.99999C17.2917 14.0271 14.0271 17.2917 10 17.2917C5.97292 17.2917 2.70833 14.0271 2.70833 9.99999Z"}),(0,s.jsx)(n.Path,{d:"M10.8333 5.83333H9.16667V10.8333H10.8333V5.83333Z"}),(0,s.jsx)(n.Path,{d:"M10.8333 12.5H9.16667V14.1667H10.8333V12.5Z"})]})},91396(e,t,r){"use strict";r.d(t,{Qr:()=>i.A,Vo:()=>s.A,cj:()=>n.A,ni:()=>o.A});var n=r(30151),s=r(81353),o=(r(95007),r(96626),r(4416),r(25680)),i=r(67205)},81353(e,t,r){"use strict";r.d(t,{A:()=>o});var n=r(56427),s=r(10790);const o=(0,s.jsxs)(n.SVG,{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/SVG",children:[(0,s.jsx)(n.Path,{d:"M12 4.75C11.0479 4.75 10.1052 4.93753 9.22554 5.30187C8.34593 5.66622 7.5467 6.20025 6.87348 6.87348C6.20025 7.5467 5.66622 8.34593 5.30187 9.22554C4.93753 10.1052 4.75 11.0479 4.75 12C4.75 12.9521 4.93753 13.8948 5.30187 14.7745C5.66622 15.6541 6.20025 16.4533 6.87348 17.1265C7.5467 17.7997 8.34593 18.3338 9.22554 18.6981C10.1052 19.0625 11.0479 19.25 12 19.25C13.9228 19.25 15.7669 18.4862 17.1265 17.1265C18.4862 15.7669 19.25 13.9228 19.25 12C19.25 10.0772 18.4862 8.23312 17.1265 6.87348C15.7669 5.51384 13.9228 4.75 12 4.75ZM3.25 12C3.25 9.67936 4.17187 7.45376 5.81282 5.81282C7.45376 4.17187 9.67936 3.25 12 3.25C14.3206 3.25 16.5462 4.17187 18.1872 5.81282C19.8281 7.45376 20.75 9.67936 20.75 12C20.75 14.3206 19.8281 16.5462 18.1872 18.1872C16.5462 19.8281 14.3206 20.75 12 20.75C9.67936 20.75 7.45376 19.8281 5.81282 18.1872C4.17187 16.5462 3.25 14.3206 3.25 12Z",fill:"#008710"}),(0,s.jsx)(n.Rect,{x:"10.5",y:"8.25",width:"3",height:"4.875",rx:"1.5",fill:"#008710"}),(0,s.jsx)(n.Path,{d:"M15 11.25C15 11.644 14.9224 12.0341 14.7716 12.3981C14.6209 12.762 14.3999 13.0927 14.1213 13.3713C13.8427 13.6499 13.512 13.8709 13.1481 14.0216C12.7841 14.1724 12.394 14.25 12 14.25C11.606 14.25 11.2159 14.1724 10.8519 14.0216C10.488 13.8709 10.1573 13.6499 9.87868 13.3713C9.6001 13.0927 9.37913 12.762 9.22836 12.3981C9.0776 12.0341 9 11.644 9 11.25",stroke:"#008710",strokeWidth:"1.125",strokeLinecap:"round"}),(0,s.jsx)(n.Path,{d:"M11.4375 15.75C11.4375 16.0607 11.6893 16.3125 12 16.3125C12.3107 16.3125 12.5625 16.0607 12.5625 15.75L11.4375 15.75ZM11.4375 14.25L11.4375 15.75L12.5625 15.75L12.5625 14.25L11.4375 14.25Z",fill:"#008710"})]})},95007(e,t,r){"use strict";var n=r(56427),s=r(10790);n.SVG,n.Path,n.Path},25680(e,t,r){"use strict";r.d(t,{A:()=>o});var n=r(56427),s=r(10790);const o=(0,s.jsxs)(n.SVG,{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/SVG",children:[(0,s.jsx)(n.Path,{d:"M12 4.75C11.0479 4.75 10.1052 4.93753 9.22554 5.30187C8.34593 5.66622 7.5467 6.20025 6.87348 6.87348C6.20025 7.5467 5.66622 8.34593 5.30187 9.22554C4.93753 10.1052 4.75 11.0479 4.75 12C4.75 12.9521 4.93753 13.8948 5.30187 14.7745C5.66622 15.6541 6.20025 16.4533 6.87348 17.1265C7.5467 17.7997 8.34593 18.3338 9.22554 18.6981C10.1052 19.0625 11.0479 19.25 12 19.25C13.9228 19.25 15.7669 18.4862 17.1265 17.1265C18.4862 15.7669 19.25 13.9228 19.25 12C19.25 10.0772 18.4862 8.23312 17.1265 6.87348C15.7669 5.51384 13.9228 4.75 12 4.75ZM3.25 12C3.25 9.67936 4.17187 7.45376 5.81282 5.81282C7.45376 4.17187 9.67936 3.25 12 3.25C14.3206 3.25 16.5462 4.17187 18.1872 5.81282C19.8281 7.45376 20.75 9.67936 20.75 12C20.75 14.3206 19.8281 16.5462 18.1872 18.1872C16.5462 19.8281 14.3206 20.75 12 20.75C9.67936 20.75 7.45376 19.8281 5.81282 18.1872C4.17187 16.5462 3.25 14.3206 3.25 12Z",fill:"#008710"}),(0,s.jsx)(n.Rect,{x:"12.75",y:"9",width:"2.25",height:"6",fill:"#008710"}),(0,s.jsx)(n.Rect,{x:"9",y:"9",width:"2.25",height:"6",fill:"#008710"})]})},96626(e,t,r){"use strict";var n=r(56427),s=r(10790);n.SVG,n.Path,n.Path},4416(e,t,r){"use strict";var n=r(56427),s=r(10790);n.SVG,n.Path,n.Rect},67205(e,t,r){"use strict";r.d(t,{A:()=>o});var n=r(56427),s=r(10790);const o=(0,s.jsxs)(n.SVG,{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,s.jsx)(n.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M12.5 10C12.5 11.3807 11.3807 12.5 10 12.5C8.61929 12.5 7.5 11.3807 7.5 10C7.5 8.61929 8.61929 7.5 10 7.5C11.3807 7.5 12.5 8.61929 12.5 10ZM14 10C14 12.2091 12.2091 14 10 14C7.79086 14 6 12.2091 6 10C6 7.79086 7.79086 6 10 6C12.2091 6 14 7.79086 14 10ZM16.75 21V19C16.75 17.4812 15.5188 16.25 14 16.25L6 16.25C4.48122 16.25 3.25 17.4812 3.25 19V21H4.75L4.75 19C4.75 18.3096 5.30964 17.75 6 17.75L14 17.75C14.6904 17.75 15.25 18.3096 15.25 19V21H16.75Z",fill:"currentColor"}),(0,s.jsx)(n.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M19.976 16.3599C21.2507 14.5642 22.0001 12.3695 22.0001 9.99969C22.0001 7.63128 21.2515 5.43769 19.9782 3.64258L18.754 4.50967C19.8537 6.05996 20.5001 7.95434 20.5001 9.99969C20.5001 12.0464 19.8528 13.9419 18.7519 15.4928L19.976 16.3599ZM17.3357 14.4897C18.2357 13.222 18.7648 11.6727 18.7648 9.99969C18.7648 8.32808 18.2365 6.77984 17.3379 5.51279L16.1137 6.37988C16.8387 7.4021 17.2648 8.65114 17.2648 9.99969C17.2648 11.3496 16.8378 12.5998 16.1116 13.6226L17.3357 14.4897Z",fill:"currentColor"})]})},96865(e,t,r){"use strict";r.d(t,{A4:()=>f.A4,AK:()=>h.AK,AZ:()=>m.AZ,DD:()=>f.DD,DT:()=>f.DT,E0:()=>c.A,FC:()=>h.FC,Fs:()=>g.Fs,Gm:()=>f.Gm,HM:()=>f.HM,Hb:()=>h.Hb,JR:()=>f.JR,K2:()=>f.K2,L9:()=>m.L9,MB:()=>g.MB,N0:()=>h.N0,ON:()=>s.A,OO:()=>g.OO,Or:()=>m.Or,QA:()=>h.QA,Qr:()=>p.Qr,R0:()=>n.A,Rq:()=>f.Rq,Tg:()=>b.T,UA:()=>f.UA,UD:()=>f.UD,Vo:()=>p.Vo,Zo:()=>g.Zo,_E:()=>g.Hh,_G:()=>g._G,be:()=>a.A,br:()=>f.br,cT:()=>m.cT,cj:()=>p.cj,d5:()=>f.d5,dh:()=>d.A,eJ:()=>f.eJ,fD:()=>f.fD,im:()=>f.im,in:()=>g.in,mA:()=>m.mA,mI:()=>f.mI,mT:()=>f.mT,ni:()=>p.ni,o2:()=>i.Ay,oZ:()=>f.oZ,pE:()=>f.pE,rh:()=>g.rh,rr:()=>u.A,sn:()=>f.sn,so:()=>f.so,u0:()=>f.u0,uH:()=>m.uH,uQ:()=>f.uQ,ud:()=>m.ud,vE:()=>f.vE,xA:()=>l.A,yM:()=>o.A,yQ:()=>f.yQ,yy:()=>f.yy,z3:()=>h.z3,z5:()=>f.z5});r(51391),r(53664),r(87286);var n=r(31439),s=(r(57745),r(42694)),o=r(72448),i=r(46219),a=r(96657),c=r(7804),l=r(97784),u=r(66859),d=(r(62614),r(71508)),p=r(91396),h=r(27802),m=(r(13965),r(78836)),g=r(72586),f=r(43984),b=r(23101)},51391(e,t,r){"use strict";r.d(t,{A:()=>l});var n=r(97999),s=r(10067),o=r.n(s),i=r(48931);const a=o()("jetpack-ai-client:jwt"),c="jetpack-ai-jwt";async function l({apiNonce:e,siteId:t,expirationTime:r}={}){e=e||window.JP_CONNECTION_INITIAL_STATE.apiNonce,t=t||window.JP_CONNECTION_INITIAL_STATE.siteSuffix,r=r||12e4;const s=localStorage.getItem(c);let o,l=null;if(s)try{l=JSON.parse(s)}catch(e){a("Error parsing token",e)}if(l&&l?.expire>Date.now())return a("Using cached token"),l;const u=(0,n.isSimpleSite)();o=u?await(0,i.A)({path:"/wpcom/v2/sites/"+t+"/jetpack-openai-query/jwt",method:"POST"}):await(0,i.A)({path:"/jetpack/v4/jetpack-ai-jwt?_cacheBuster="+Date.now(),credentials:"same-origin",headers:{"X-WP-Nonce":e},method:"POST"});const d={token:o.token,blogId:u?t:o.blog_id,expire:Date.now()+r};return a("Storing new token"),localStorage.setItem(c,JSON.stringify(d)),d}},20231(e,t,r){"use strict";r.d(t,{_:()=>s});var n=r(47143);const s=()=>{const e=(0,n.select)("core/block-editor").getBlocks(),t=[],r=e=>{t.push(e),e.innerBlocks?.length&&e.innerBlocks.forEach(r)};return e.forEach(r),t}},40464(e,t,r){"use strict";r.d(t,{Z:()=>n});const n=async e=>{try{const t=await fetch(e),r=await t.arrayBuffer();return`data:image/png;base64,${btoa(new Uint8Array(r).reduce((e,t)=>e+String.fromCharCode(t),""))}`}catch{return e}}},72586(e,t,r){"use strict";r.d(t,{Fs:()=>i.F,Hh:()=>n.Hh,MB:()=>s.M,OO:()=>n.OO,Zo:()=>c.Z,_G:()=>a._,in:()=>o.i,rh:()=>n.rh});var n=r(55166),s=r(84861),o=r(61269),i=r(1811),a=r(20231),c=r(40464)},84861(e,t,r){"use strict";r.d(t,{M:()=>s});var n=r(43984);function s(e,t={}){const{language:r,tone:s}=t,o=r?.split(" (")[0];switch(e){case n.Gm:return`${n.u0}: ${n.so[o].label}`;case n.eJ:return`${n.uQ}: ${n.oZ[s].label}`;case n.yy:return n.DD;case n.A4:return n.HM;case n.UA:return n.JR;case n.br:return n.K2;case n.fD:return n.UD;case n.d5:return n.mI;case n.fv:return n.yQ;case n.vE:return n.mT;case n.im:return n.Rq;case n.sn:return n.DT;default:return null}}},68641(e,t,r){"use strict";r.d(t,{A:()=>a});var n=r(21147);const s={paragraph:e=>e.replaceAll("\n","
    ")},o={emDelimiter:"_",headingStyle:"atx"},i={strikethrough:{filter:["del","s"],replacement:function(e){return"~~"+e+"~~"}}};class a{constructor({options:e={},rules:t={},keep:r=[],remove:s=[],fixes:a=[]}={}){this.fixes=a,this.turndownService=new n.A({...o,...e}),this.turndownService.keep(r),this.turndownService.remove(s);const c={...i,...t};for(const e in c)this.turndownService.addRule(e,c[e])}render({content:e}){const t=this.turndownService.turndown(e);return this.fixes.reduce((e,t)=>s[t](e),t)}}},55166(e,t,r){"use strict";r.d(t,{Hh:()=>i,OO:()=>n.A,rh:()=>a});var n=r(68641);const s=new(r(31737).A),o=new n.A,i=({content:e,rules:t,extension:r})=>s.render({content:e,rules:t,extension:r}),a=({content:e})=>o.render({content:e})},31737(e,t,r){"use strict";r.d(t,{A:()=>c});var n=r(97158);const s=e=>e.replaceAll("\x3c!-- wp:list-item --\x3e","").replaceAll("\x3c!-- /wp:list-item --\x3e","").replaceAll("\x3c!-- wp:list --\x3e","").replaceAll("\x3c!-- /wp:list --\x3e","").replaceAll("
  • ","\x3c!-- wp:list-item --\x3e
  • ").replaceAll("
  • ","\x3c!-- /wp:list-item --\x3e").replaceAll("
      ",'\x3c!-- wp:list {"ordered":true} --\x3e
        ').replaceAll("
      ","
    \x3c!-- /wp:list --\x3e").replaceAll("
      ","\x3c!-- wp:list --\x3e
        ").replaceAll("
      ","
    \x3c!-- /wp:list --\x3e"),o={list:(e,t=!1)=>{const r=e.replace(/
  • \s+

    /g,"

  • ").replace(/<\/p>\s+<\/li>/g,"
  • ");return t?s(r):r},listItem:(e,t=!1)=>t?s(e.replace(/^<[ou]l>\s*/g,"").replace(/\s*<\/[ou]l>\s*$/g,"")):e,paragraph:(e,t=!1)=>t?e.split("<br />").map((e,t,r)=>(t0&&(e=e.trimStart()),e)).join("
    "):e,table:(e,t=!1,{hasFixedLayout:r=!1})=>t?e.startsWith("\x3c!-- wp:table")?e:`\x3c!-- wp:table { "hasFixedLayout":${r?"true":"false"} } --\x3e${e}\x3c!-- /wp:table --\x3e`:e},i={breaks:!0},a=["list"];class c{constructor(e=i){this.markdownConverter=new n.A(e)}render({content:e,rules:t=a,extension:r=!1}){const n=this.markdownConverter.render(e);return t.reduce((e,t)=>o[t](e,r),n)}}},61269(e,t,r){"use strict";r.d(t,{i:()=>o});var n=r(94715),s=r(47143);function o(e){if(!e)return;const{selectBlock:t}=(0,s.dispatch)(n.store),{enableComplementaryArea:r}=(0,s.dispatch)("core/interface");t(e),r("core/edit-post","edit-post/block")}},1811(e,t,r){"use strict";r.d(t,{F:()=>s});var n=r(47143);const s=async()=>{const{clearSelectedBlock:e}=(0,n.dispatch)("core/block-editor"),{enableComplementaryArea:t}=(0,n.dispatch)("core/interface");e(),await t("core/edit-post","jetpack-sidebar/jetpack");const r=document.querySelector(".jetpack-ai-assistant-panel"),s=r?.classList.contains("is-opened"),o=r?.querySelector("h2 button");s&&o?.click(),setTimeout(()=>{o?.click()},50)}},21902(e,t,r){"use strict";r.d(t,{A:()=>s});r(8655);var n=r(10790);const s=()=>(0,n.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"jetpack-ai-logo-generator-icon",children:[(0,n.jsx)("path",{d:"M6.99976 3.99994L7.84828 6.15141L9.99976 6.99994L7.84828 7.84847L6.99976 9.99994L6.15123 7.84847L3.99976 6.99994L6.15123 6.15141L6.99976 3.99994Z"}),(0,n.jsx)("path",{d:"M16 4L17.1314 6.86863L20 8L17.1314 9.13137L16 12L14.8686 9.13137L12 8L14.8686 6.86863L16 4Z"}),(0,n.jsx)("path",{d:"M11 10L12.4142 13.5858L16 15L12.4142 16.4142L11 20L9.58579 16.4142L6 15L9.58579 13.5858L11 10Z"})]})},11574(e,t,r){"use strict";r.d(t,{A:()=>s});r(8655);var n=r(10790);const s=()=>(0,n.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"jetpack-ai-logo-generator-icon",children:(0,n.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17.9291 7.96836L10.7308 17.6492L6.2145 14.2911L7.10952 13.0873L10.4221 15.5504L16.7253 7.07333L17.9291 7.96836Z"})})},47621(e,t,r){"use strict";r.d(t,{A:()=>s});r(8655);var n=r(10790);const s=()=>(0,n.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"jetpack-ai-logo-generator-icon",children:(0,n.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19.2927 13.7485C18.5014 17.0423 15.5366 19.4901 12 19.4901C8.92508 19.4901 6.28236 17.6396 5.12469 14.9915L8.79556 12.8139L12.2508 14.0309C12.482 14.1123 12.7383 14.0756 12.9374 13.9327L15.8243 11.8601L15.9039 11.8992C16.1998 12.0451 16.6072 12.249 17.0533 12.4807C17.8331 12.8857 18.6946 13.3572 19.2927 13.7485ZM19.499 12.1129C18.9341 11.7788 18.3001 11.4379 17.7447 11.1495C17.287 10.9118 16.8698 10.7031 16.5672 10.5539C16.4158 10.4792 16.2928 10.4193 16.2074 10.378L16.1085 10.3303L16.0824 10.3177L16.0729 10.3132C15.8261 10.1954 15.5347 10.2214 15.3126 10.3809L12.3802 12.4861L8.9634 11.2827C8.75395 11.2089 8.52258 11.2318 8.3316 11.3451L4.65716 13.5248C4.55414 13.0294 4.5 12.5161 4.5 11.9901C4.5 7.84798 7.85786 4.49011 12 4.49011C16.1421 4.49011 19.5 7.84798 19.5 11.9901C19.5 12.0311 19.4997 12.072 19.499 12.1129ZM21 11.9901C21 16.9607 16.9706 20.9901 12 20.9901C7.02944 20.9901 3 16.9607 3 11.9901C3 7.01955 7.02944 2.99011 12 2.99011C16.9706 2.99011 21 7.01955 21 11.9901Z"})})},97034(e,t,r){"use strict";r.d(t,{A:()=>s});r(8655);var n=r(10790);const s=()=>(0,n.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"jetpack-ai-logo-generator-icon",children:[(0,n.jsx)("path",{d:"M7 6.49011L11 8.99011L7 11.4901V6.49011Z"}),(0,n.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5 2.99011C3.89543 2.99011 3 3.88554 3 4.99011V18.9901C3 20.0947 3.89543 20.9901 5 20.9901H19C20.1046 20.9901 21 20.0947 21 18.9901V4.99011C21 3.88554 20.1046 2.99011 19 2.99011H5ZM19 4.49011H5C4.72386 4.49011 4.5 4.71397 4.5 4.99011V15.6973L8.12953 13.0508C8.38061 12.8677 8.71858 12.8584 8.97934 13.0274L11.906 14.9243L15.4772 11.4524C15.7683 11.1694 16.2317 11.1694 16.5228 11.4524L19.5 14.3469V4.99011C19.5 4.71397 19.2761 4.49011 19 4.49011ZM4.5 18.9901V17.5537L8.59643 14.5667L11.5921 16.5084C11.8857 16.6987 12.2719 16.6607 12.5228 16.4167L16 13.0361L19.4772 16.4167L19.5 16.3933V18.9901C19.5 19.2663 19.2761 19.4901 19 19.4901H5C4.72386 19.4901 4.5 19.2663 4.5 18.9901Z"})]})},6019(e,t,r){"use strict";r.d(t,{Q:()=>i});var n=r(56427),s=r(78867),o=r(10790);const i=({variant:e="error"})=>{const t=(0,s.A)();return"muted"===e?(0,o.jsx)("span",{className:"jetpack-ai-fair-usage-notice-muted-variant",children:t}):"error"===e?(0,o.jsx)(n.Notice,{status:"error",isDismissible:!1,className:"jetpack-ai-fair-usage-notice",children:t}):null}},95933(e,t,r){"use strict";r.d(t,{x:()=>i});var n=r(56427),s=r(27723),o=r(10790);const __=s.__,i=({onCancel:e,onRetry:t})=>{const r=__("We are sorry. There was an error loading your Jetpack AI plan data. Please, try again.","jetpack"),s=__("We are sorry. There was an error loading your Jetpack AI plan data. Please, reload the page and try again.","jetpack");return(0,o.jsxs)("div",{className:"jetpack-ai-logo-generator-modal__notice-message-wrapper",children:[(0,o.jsx)("div",{className:"jetpack-ai-logo-generator-modal__notice-message",children:(0,o.jsx)("span",{className:"jetpack-ai-logo-generator-modal__loading-message",children:t?r:s})}),(0,o.jsxs)("div",{className:"jetpack-ai-logo-generator-modal__notice-actions",children:[(0,o.jsx)(n.Button,{variant:"tertiary",onClick:e,children:__("Cancel","jetpack")}),t&&(0,o.jsx)(n.Button,{variant:"primary",onClick:t,children:__("Try again","jetpack")})]})]})}},76194(e,t,r){"use strict";r.d(t,{N:()=>i});var n=r(27723),s=r(42669),o=(r(35797),r(10790));const __=n.__,i=({state:e="loadingFeature"})=>{const t=__("Loading…","jetpack"),r=__("Analyzing your site to create the perfect logo…","jetpack"),n=__("Generating logo…","jetpack");return(0,o.jsxs)("div",{className:"jetpack-ai-logo-generator-modal__loading-wrapper",children:[(0,o.jsx)(s.$,{}),(0,o.jsxs)("span",{className:"jetpack-ai-logo-generator-modal__loading-message",children:["loadingFeature"===e&&t,"analyzing"===e&&r,"generating"===e&&n]})]})}},64537(e,t,r){"use strict";r.d(t,{T:()=>S});var n=r(85985),s=r(56427),o=r(47143),i=r(27723),a=r(13022),c=r(10067),l=r.n(c),u=r(51609),d=r(46381),p=r(61356),h=r(60674),m=r(88725),g=r(44461),f=r(19362),b=r(74423),v=r(95933),y=r(76194),k=r(32623),_=r(34706),x=r(11114),w=r(35421),j=r(48204),A=(r(45736),r(10790));const __=i.__,C=l()("jetpack-ai-calypso:generator-modal"),S=({isOpen:e,onClose:t,onApplyLogo:r,onReload:i=null,siteDetails:c,context:l,placement:S})=>{const{tracks:E}=(0,n.st)(),{recordEvent:T}=E,{setSiteDetails:N,fetchAiAssistantFeature:P,loadLogoHistory:R,setIsLoadingHistory:L}=(0,o.useDispatch)(b.E),{getIsRequestingAiAssistantFeature:D}=(0,o.select)(b.E),[I,B]=(0,u.useState)(null),[F,M]=(0,u.useState)(),U=(0,u.useRef)(!0),O=(0,u.useRef)(!1),[z,q]=(0,u.useState)(!1),[$,H]=(0,u.useState)(!1),{selectedLogo:V,getAiAssistantFeature:G,generateFirstPrompt:W,generateLogo:Z,setContext:J,tierPlansEnabled:K,site:Y,requireUpgrade:Q}=(0,m.A)(),{featureFetchError:X,setFeatureFetchError:ee,firstLogoPromptFetchError:te,clearErrors:re}=(0,g.A)(),ne=c?.ID,[se,oe]=(0,u.useState)(!1),{nextTierCheckoutURL:ie}=(0,h.Q)(),ae=G(),ce=(0,u.useCallback)(async()=>{try{B("analyzing"),T(p.vm,{context:l,tool:"first-prompt"});const e=await W();M(e),B("generating"),await Z({prompt:e,style:"none"}),B(null)}catch(e){C("Error generating first logo",e),B(null)}},[l,W,Z]),le=(0,u.useCallback)(async()=>{try{if(!ne)throw new Error("Site ID is missing");if(!ae?.featuresControl?.["logo-generator"]?.enabled)throw ee("Failed to fetch feature data"),new Error("Failed to fetch feature data");const e=!(0,f.NP)(String(ne)),t=ae?.costs?.["jetpack-ai-logo-generator"]?.logo??p._S,r=1,n=ae?.currentTier?.limit||0,s=ae?.currentTier?.value||0,o=ae?.usagePeriod?.requestsCount||0,i=!(K?1===s:s>0)&&!!ae?.nextTier&&!e&&(K?n-o{J(l),T(p.iz,{context:l,placement:S}),le()},[J,l,S,le]),de=()=>{U.current=!0,t(),B(null),q(!1),H(!1),re(),oe(!1),L(!1),T(p.ub,{context:l,placement:S})},pe=(0,u.useCallback)(()=>{i&&(de(),O.current=!1,i())},[i,de]),he=e=>{oe(!0),r?.(e)},me=()=>{T(p.$i,{context:l})};let ge;return(0,u.useEffect)(()=>{if(ne&&N(c),!O.current){D()||(O.current=!0,P())}},[ne,c,N,D]),(0,u.useEffect)(()=>{e&&U.current&&(U.current=!1,ue())},[e,ue]),ge=I?(0,A.jsx)(y.N,{state:I}):X||te?(0,A.jsx)(v.x,{onCancel:de,onRetry:i?pe:null}):z||$?(0,A.jsx)(w.R,{onCancel:de,upgradeURL:ie,reason:z?"feature":"requests"}):(0,A.jsxs)(A.Fragment,{children:[!se&&(0,A.jsx)(x.X,{initialPrompt:F}),(0,A.jsx)(_.s,{logo:V,onApplyLogo:he,logoAccepted:se,siteId:String(ne)}),se?(0,A.jsxs)("div",{className:"jetpack-ai-logo-generator__accept",children:[(0,A.jsx)(j.H,{}),(0,A.jsx)("div",{className:"jetpack-ai-logo-generator__accept-actions",children:(0,A.jsx)(s.Button,{variant:"primary",onClick:de,children:__("Close","jetpack")})})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(k.N,{}),(0,A.jsx)("div",{className:"jetpack-ai-logo-generator__footer",children:(0,A.jsx)(d.A,{onFeedbackClick:me})})]})]}),(0,A.jsx)(A.Fragment,{children:e&&(0,A.jsx)(s.Modal,{className:"jetpack-ai-logo-generator-modal",onRequestClose:de,shouldCloseOnClickOutside:!1,shouldCloseOnEsc:!1,title:__("Jetpack AI Logo Generator","jetpack"),children:(0,A.jsx)("div",{className:(0,a.A)("jetpack-ai-logo-generator-modal__body",{"notice-modal":z||$||X||te}),children:ge})})})}},32623(e,t,r){"use strict";r.d(t,{N:()=>u});var n=r(85985),s=r(56427),o=r(13022),i=r(26076),a=r(61356),c=r(88725),l=(r(24046),r(10790));const u=()=>{const{tracks:e}=(0,n.st)(),{recordEvent:t}=e,{logos:r,selectedLogo:u,setSelectedLogoIndex:d,context:p,isLoadingHistory:h}=(0,c.A)(),m=e=>{const t=new URL(e);return t.searchParams.has("resize")||t.searchParams.append("resize","48,48"),t.toString()};return(0,l.jsxs)("div",{className:"jetpack-ai-logo-generator__carousel",children:[!r.length&&h&&(0,l.jsx)(s.Button,{disabled:!0,className:(0,o.A)("jetpack-ai-logo-generator__carousel-logo"),children:(0,l.jsx)("img",{height:"48",width:"48",src:i,alt:"loading"})}),!r.length&&!h&&(0,l.jsx)("div",{children:" "}),r.map((e,n)=>(0,l.jsx)(s.Button,{className:(0,o.A)("jetpack-ai-logo-generator__carousel-logo",{"is-selected":e.url===u.url}),onClick:()=>(e=>{t(a.Nt,{context:p,logos_count:r.length,selected_logo:e+1}),d(e)})(n),children:(0,l.jsx)("img",{src:m(e.url),alt:e.description})},e.url))]})}},42669(e,t,r){"use strict";r.d(t,{$:()=>i});var n=r(13022),s=r(26076),o=r(10790);const i=({className:e=null})=>(0,o.jsx)("img",{src:s,alt:"Loading",className:(0,n.A)("jetpack-ai-logo-generator-modal__loader",e)})},34706(e,t,r){"use strict";r.d(t,{s:()=>T});var n=r(85985),s=r(56427),o=r(47143),i=r(27723),a=r(10067),c=r.n(a),l=r(11497),u=r(11574),d=r(47621),p=r(97034),h=r(61356),m=r(88725),g=r(44461),f=r(19362),b=r(74423),v=r(42669),y=(r(55941),r(10790));const __=i.__,_x=i._x,k=c()("jetpack-ai-calypso:logo-presenter"),_=({siteId:e})=>{const{tracks:t}=(0,n.st)(),{recordEvent:r}=t,{saveLogo:i,selectedLogo:a,isSavingLogoToLibrary:c,logos:l,selectedLogoIndex:d,context:g}=(0,m.A)(),v=!!a?.mediaId,{loadLogoHistory:_}=(0,o.useDispatch)(b.E),x=_x("Saving…","Logo save button","jetpack"),w=__("Saved","jetpack");return c||v?(0,y.jsxs)(s.Button,{className:"jetpack-ai-logo-generator-modal-presenter__action",children:[(0,y.jsx)(s.Icon,{icon:c?(0,y.jsx)(p.A,{}):(0,y.jsx)(u.A,{})}),(0,y.jsx)("span",{className:"action-text",children:c?x:w})]}):(0,y.jsxs)(s.Button,{className:"jetpack-ai-logo-generator-modal-presenter__action",onClick:async()=>{if(!v&&!c){r(h.h4,{context:g,logos_count:l.length,selected_logo:d?d+1:0});try{const t=await i(a);(0,f.H)({siteId:e,url:a.url,newUrl:t.mediaURL,mediaId:t.mediaId}),_(e)}catch(e){k("Error saving logo",e)}}},children:[(0,y.jsx)(s.Icon,{icon:(0,y.jsx)(p.A,{})}),(0,y.jsx)("span",{className:"action-text",children:__("Save in Library","jetpack")})]})},x=({onApplyLogo:e})=>{const{tracks:t}=(0,n.st)(),{recordEvent:r}=t,{isSavingLogoToLibrary:o,selectedLogo:i,logos:a,selectedLogoIndex:c,context:l}=(0,m.A)();return(0,y.jsxs)(s.Button,{className:"jetpack-ai-logo-generator-modal-presenter__action",onClick:async()=>{o||(r(h.Zb,{context:l,logos_count:a.length,selected_logo:null!=c?c+1:0}),e?.(i?.mediaId))},disabled:o||!i?.mediaId,variant:"secondary",children:[(0,y.jsx)(s.Icon,{icon:(0,y.jsx)(d.A,{})}),(0,y.jsx)("span",{className:"action-text",children:__("Use on block","jetpack")})]})},w=()=>(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(v.$,{className:"jetpack-ai-logo-generator-modal-presenter__logo"}),(0,y.jsx)("span",{className:"jetpack-ai-logo-generator-modal-presenter__loading-text",children:__("Generating new logo…","jetpack")})]}),j=()=>(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(v.$,{className:"jetpack-ai-logo-generator-modal-presenter__logo"}),(0,y.jsx)("span",{className:"jetpack-ai-logo-generator-modal-presenter__loading-text",children:__("Fetching previous logos…","jetpack")})]}),A=()=>(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("div",{style:{width:0,height:"229px"}}),(0,y.jsx)("span",{className:"jetpack-ai-logo-generator-modal-presenter__loading-text",children:__("Once you generate a logo, it will show up here","jetpack")})]}),C=({disabled:e,ratedItem:t,onRate:r})=>{const{logos:n,selectedLogo:s}=(0,m.A)(),o=n.filter(e=>e.rating).reduce((e,t)=>(e[t.url]=t.rating,e),{});return(0,y.jsx)(l.A,{disabled:e,ratedItem:t,feature:"logo-generator",savedRatings:o,options:{mediaLibraryId:s.mediaId,prompt:s.description},onRate:r})},S=({siteId:e,logo:t,onApplyLogo:r})=>(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("img",{src:t.url,alt:t.description,className:"jetpack-ai-logo-generator-modal-presenter__logo"}),(0,y.jsxs)("div",{className:"jetpack-ai-logo-generator-modal-presenter__action-wrapper",children:[(0,y.jsx)("span",{className:"jetpack-ai-logo-generator-modal-presenter__description",children:t.description}),(0,y.jsxs)("div",{className:"jetpack-ai-logo-generator-modal-presenter__actions",children:[(0,y.jsx)(_,{siteId:e}),(0,y.jsx)(x,{onApplyLogo:r}),(0,y.jsx)(C,{ratedItem:t.url,disabled:!1,onRate:r=>{(0,f.H)({siteId:e,url:t.url,newUrl:t.url,mediaId:t.mediaId,rating:r})}})]})]})]}),E=({logo:e})=>(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("img",{src:e.url,alt:e.description,className:"jetpack-ai-logo-generator-modal-presenter__logo"}),(0,y.jsxs)("div",{className:"jetpack-ai-logo-generator-modal-presenter__success-wrapper",children:[(0,y.jsx)(s.Icon,{icon:(0,y.jsx)(u.A,{})}),(0,y.jsx)("span",{children:__("Your new logo was set to the block!","jetpack")})]})]}),T=({logo:e=null,loading:t=!1,onApplyLogo:r,logoAccepted:n=!1,siteId:s})=>{const{isRequestingImage:o}=(0,m.A)(),{saveToLibraryError:i,logoUpdateError:a}=(0,g.A)();let c;return e||o?e?c=t||o?(0,y.jsx)(w,{}):n?(0,y.jsx)(E,{logo:e}):(0,y.jsx)(S,{siteId:String(s),logo:e,onApplyLogo:r}):(k("No logo provided, history still loading or logo being generated"),c=(0,y.jsx)(j,{})):c=(0,y.jsx)(A,{}),(0,y.jsxs)("div",{className:"jetpack-ai-logo-generator-modal-presenter__wrapper",children:[(0,y.jsxs)("div",{className:"jetpack-ai-logo-generator-modal-presenter",children:[(0,y.jsx)("div",{className:"jetpack-ai-logo-generator-modal-presenter__content",children:c}),!n&&(0,y.jsx)("div",{className:"jetpack-ai-logo-generator-modal-presenter__rectangle"})]}),i&&(0,y.jsx)("div",{className:"jetpack-ai-logo-generator__prompt-error",children:__("Error saving the logo to your library. Please try again.","jetpack")}),a&&(0,y.jsx)("div",{className:"jetpack-ai-logo-generator__prompt-error",children:__("Error applying the logo to your site. Please try again.","jetpack")})]})}},11114(e,t,r){"use strict";r.d(t,{X:()=>x});var n=r(85985),s=r(56427),o=r(27723),i=r(13109),a=r(28847),c=r(10067),l=r.n(c),u=r(51609),d=r(66223),p=r(21902),h=r(61356),m=r(60674),g=r(88725),f=r(44461),b=r(6019),v=r(64024),y=(r(47341),r(10790));const __=o.__,k=l()("jetpack-ai-calypso:prompt-box"),_=({prompt:e="",setPrompt:t=()=>{},disabled:r=!1,actionDisabled:n=!1,generateHandler:o=()=>{},placeholder:i="",buttonLabel:a=""})=>{const c=(0,u.useRef)(null);(0,u.useEffect)(()=>{c.current&&c.current.textContent!==e&&(c.current.textContent=e)},[e]);return(0,y.jsxs)("div",{className:"jetpack-ai-image-generator__prompt-query",children:[(0,y.jsx)("div",{role:"textbox",tabIndex:0,ref:c,contentEditable:!r,suppressContentEditableWarning:!0,className:"prompt-query__input",onInput:e=>{t(e.target.textContent||"")},onPaste:e=>{e.preventDefault();const r=e.currentTarget.ownerDocument.getSelection();if(!r||!r.rangeCount)return;const n=e.clipboardData.getData("text/plain");r.deleteFromDocument();r.getRangeAt(0).insertNode(document.createTextNode(n)),r.collapseToEnd(),t(c.current?.textContent||"")},onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),o()),e.stopPropagation()},onKeyUp:()=>{""===c.current?.textContent&&(c.current.innerHTML="")},"data-placeholder":i}),(0,y.jsx)(s.Button,{variant:"primary",className:"jetpack-ai-image-generator__prompt-submit",onClick:o,disabled:n,children:a||__("Generate","jetpack")})]})},x=({initialPrompt:e=""})=>{const{tracks:t}=(0,n.st)(),{recordEvent:r}=t,[c,l]=(0,u.useState)(e),[x,w]=(0,u.useState)(0),{enhancePromptFetchError:j,logoFetchError:A}=(0,f.A)(),{nextTierCheckoutURL:C,hasNextTier:S}=(0,m.Q)(),E=c?.length>=h.N3,[T,N]=(0,u.useState)(!1),[P,R]=(0,u.useState)(null),[L,D]=(0,u.useState)([]),{generateLogo:I,enhancePrompt:B,setIsEnhancingPrompt:F,isBusy:M,isEnhancingPrompt:U,site:O,getAiAssistantFeature:z,requireUpgrade:q,context:$,tierPlansEnabled:H,imageStyles:V,guessStyle:G}=(0,g.A)(),W=__("Enhancing…","jetpack"),Z=__("Enhance prompt","jetpack"),J=U?W:Z,K=(0,u.useRef)(null),Y=(0,u.useCallback)(async()=>{k("Enhancing prompt",c),F(!0),r(h.vm,{context:$,tool:"enhance-prompt"});try{const e=await B({prompt:c});l(e),F(!1)}catch(e){k("Error enhancing prompt",e),F(!1)}},[$,B,c,F]),Q=z(String(O?.id||"")),X=Q?.currentTier?.value||0,ee=Q?.usagePeriod?.requestsCount||0,te=1===X;(0,u.useEffect)(()=>{w(X-ee<=0?0:X-ee)},[X,ee]),(0,u.useEffect)(()=>{K.current&&K.current.textContent!==c&&(K.current.textContent=c)},[c]),(0,u.useEffect)(()=>{V&&V.length>0?(D([V.find(({value:e})=>e===d.Hu),V.find(({value:e})=>e===d.Wp),...V.filter(({value:e})=>![d.Hu,d.Wp].includes(e))].filter(e=>e)),N(!0),R(d.Hu)):(D([]),N(!1),R(null))},[V]);const re=(0,u.useCallback)(async()=>{if(k($),P===d.Wp){F(!0),r(h.Tk,{context:$,tool:"image"});const e=await G(c)||d.Hu;R(e),r(h.vm,{context:$,tool:"image",style:e}),F(!1),I({prompt:c,style:e})}else r(h.vm,{context:$,tool:"image",style:P}),I({prompt:c,style:P})},[$,I,c,P]),ne=(0,u.useCallback)(e=>{k("change style",e),R(e),r(h.UO,{context:$,style:e})},[$,R,r]);return(0,y.jsxs)("div",{className:"jetpack-ai-logo-generator__prompt",children:[(0,y.jsxs)("div",{className:"jetpack-ai-logo-generator__prompt-header",children:[(0,y.jsx)("div",{className:"jetpack-ai-logo-generator__prompt-label",children:__("Describe your site:","jetpack")}),(0,y.jsx)("div",{className:"jetpack-ai-logo-generator__prompt-actions",children:(0,y.jsxs)(s.Button,{variant:"link",disabled:M||q||!E,onClick:Y,children:[(0,y.jsx)(p.A,{}),J]})}),T&&(0,y.jsx)(s.SelectControl,{__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,value:P,options:L,onChange:ne,disabled:M||q})]}),(0,y.jsx)(_,{prompt:c,setPrompt:l,generateHandler:re,disabled:M||q,actionDisabled:M||q||!E,placeholder:__("Describe your site or simply ask for a logo specifying some details about it","jetpack")}),(0,y.jsxs)("div",{className:"jetpack-ai-logo-generator__prompt-footer",children:[!te&&!q&&(0,y.jsxs)("div",{className:"jetpack-ai-logo-generator__prompt-requests",children:[(0,y.jsx)("div",{children:(0,o.sprintf)( // translators: %d is the number of requests __("%d requests remaining.","jetpack"),x)}),S&&(0,y.jsxs)(y.Fragment,{children:[" ",(0,y.jsx)(s.Button,{variant:"link",href:C,target:"_blank",onClick:()=>{r(h.AN,{context:$,placement:h.Cn})},children:(0,y.jsx)("span",{children:__("Upgrade","jetpack")})})]})," ",(0,y.jsx)(s.Tooltip,{text:__("Logo generation costs 10 requests; prompt enhancement costs 1 request each","jetpack"),placement:"bottom",children:(0,y.jsx)(i.A,{className:"prompt-footer__icon",icon:a.A})})]}),q&&H&&(0,y.jsx)(v.G,{}),q&&!H&&(0,y.jsx)(b.Q,{}),j&&(0,y.jsx)("div",{className:"jetpack-ai-logo-generator__prompt-error",children:__("Error enhancing prompt. Please try again.","jetpack")}),A&&(0,y.jsx)("div",{className:"jetpack-ai-logo-generator__prompt-error",children:__("Error generating logo. Please try again.","jetpack")})]})]})}},64024(e,t,r){"use strict";r.d(t,{G:()=>h});var n=r(85985),s=r(56427),o=r(86087),i=r(27723),a=r(13109),c=r(84699),l=r(61356),u=r(60674),d=r(88725),p=(r(58275),r(10790));const __=i.__,h=()=>{const{tracks:e}=(0,n.st)(),{recordEvent:t}=e,r=__("Upgrade","jetpack"),i=(0,o.createInterpolateElement)(__("Not enough requests left to generate a logo. Upgrade now to increase it.","jetpack"),{strong:(0,p.jsx)("strong",{})}),{nextTierCheckoutURL:h}=(0,u.Q)(),{context:m}=(0,d.A)();return(0,p.jsx)("div",{className:"jetpack-upgrade-plan-banner",children:(0,p.jsxs)("div",{className:"jetpack-upgrade-plan-banner__wrapper",children:[(0,p.jsxs)("div",{children:[(0,p.jsx)(a.A,{className:"jetpack-upgrade-plan-banner__icon",icon:c.A}),(0,p.jsx)("span",{className:"jetpack-upgrade-plan-banner__banner-description",children:i})]}),(0,p.jsx)(s.Button,{href:h,target:"_blank",className:"is-primary",onClick:()=>{t(l.AN,{context:m,placement:l.tF})},children:(0,p.jsx)("span",{children:r})})]})})}},35421(e,t,r){"use strict";r.d(t,{R:()=>u});var n=r(3924),s=r(85985),o=r(56427),i=r(27723),a=r(61356),c=r(88725),l=r(10790);const __=i.__,u=({onCancel:e,upgradeURL:t,reason:r})=>{const{tracks:i}=(0,s.st)(),{recordEvent:u}=i,d=__("Upgrade your Jetpack AI for access to logo generation. This upgrade will also increase the amount of monthly requests you can use in for all AI-powered features.","jetpack"),p=__("Not enough requests left to generate a logo. Upgrade your Jetpack AI to increase the amount of requests you can use in all AI-powered features.","jetpack"),h=(0,n.A)("ai-logo-generator-fair-usage-policy",{anchor:"usage-limitations-and-upgrades"}),{context:m}=(0,c.A)();return(0,l.jsxs)("div",{className:"jetpack-ai-logo-generator-modal__notice-message-wrapper",children:[(0,l.jsxs)("div",{className:"jetpack-ai-logo-generator-modal__notice-message",children:[(0,l.jsx)("span",{className:"jetpack-ai-logo-generator-modal__loading-message",children:"feature"===r?d:p})," ",(0,l.jsx)(o.Button,{variant:"link",href:h,target:"_blank",children:(0,l.jsx)("span",{children:__("Learn more about Jetpack AI.","jetpack")})})]}),(0,l.jsxs)("div",{className:"jetpack-ai-logo-generator-modal__notice-actions",children:[(0,l.jsx)(o.Button,{variant:"tertiary",onClick:e,children:(0,l.jsx)("span",{children:__("Cancel","jetpack")})}),(0,l.jsx)(o.Button,{variant:"primary",href:t,target:"_blank",onClick:()=>{u(a.AN,{context:m,placement:a.Tz}),e()},children:(0,l.jsx)("span",{children:__("Upgrade","jetpack")})})]})]})}},48204(e,t,r){"use strict";r.d(t,{H:()=>l});var n=r(56427),s=r(27723),o=r(1866),i=r(13022),a=r(36791),c=(r(86263),r(10790));const __=s.__,l=({className:e=null,onVisitBlankTarget:t})=>(0,c.jsxs)("div",{className:(0,i.A)("jetpack-ai-logo-generator-modal-visit-site-banner",e),children:[(0,c.jsx)("div",{className:"jetpack-ai-logo-generator-modal-visit-site-banner__jetpack-logo",children:(0,c.jsx)("img",{src:a,alt:"Jetpack"})}),(0,c.jsxs)("div",{className:"jetpack-ai-logo-generator-modal-visit-site-banner__content",children:[(0,c.jsx)("strong",{children:__("Do you want to know all the amazing things you can do with Jetpack AI?","jetpack")}),(0,c.jsx)("span",{children:__("Generate and tweak content, create forms, get feedback and much more.","jetpack")}),(0,c.jsx)("div",{children:(0,c.jsxs)(n.Button,{variant:"link",href:"https://jetpack.com/redirect/?source=logo_generator_learn_more_about_jetpack_ai",target:"_blank",onClick:t||null,children:[(0,c.jsx)("span",{children:__("Learn more about Jetpack AI","jetpack")}),(0,c.jsx)(n.Icon,{icon:o.A,size:20})]})})]})]})},61356(e,t,r){"use strict";r.d(t,{$i:()=>l,AN:()=>u,Cn:()=>h,N3:()=>f,Nt:()=>c,Tk:()=>p,Tz:()=>m,UO:()=>d,Zb:()=>a,_S:()=>b,h4:()=>i,iz:()=>n,tF:()=>g,ub:()=>s,vm:()=>o});const n="jetpack_ai_logo_generator_modal_open",s="jetpack_ai_logo_generator_modal_close",o="jetpack_ai_logo_generator_generate",i="jetpack_ai_logo_generator_save",a="jetpack_ai_logo_generator_use",c="jetpack_ai_logo_generator_navigate",l="jetpack_ai_logo_generator_feedback",u="jetpack_ai_upgrade_button",d="jetpack_ai_logo_generator_switch_style",p="jetpack_ai_logo_generator_guess_style",h="input_footer",m="free_user_screen",g="upgrade_prompt",f=3,b=10},60674(e,t,r){"use strict";r.d(t,{Q:()=>a});var n=r(97999),s=r(85985),o=r(47143),i=r(74423);const a=()=>{const{nextTier:e,tierPlansEnabled:t}=(0,o.useSelect)(e=>{const t=e(i.E);return{nextTier:t.getAiAssistantFeature().nextTier,tierPlansEnabled:t.getAiAssistantFeature().tierPlansEnabled}},[]),r=!(0,n.isWpcomPlatformSite)(),a=r?"jetpack-ai-upgrade-url-for-jetpack-sites":"jetpack-ai-yearly-tier-upgrade-nudge",c=(0,s.GE)(),l=`https://wordpress.com/home/${c}`,u=new URL("https://jetpack.com/redirect/");u.searchParams.set("source",a),u.searchParams.set("site",c),u.searchParams.set("path",t?`jetpack_ai_yearly:-q-${e?.limit}`:"jetpack_ai_yearly"),r||u.searchParams.set("query",`redirect_to=${encodeURIComponent(l)}`);return{nextTierCheckoutURL:u.toString(),hasNextTier:!!e}}},78867(e,t,r){"use strict";r.d(t,{A:()=>l});var n=r(3924),s=r(47143),o=r(86087),i=r(27723),a=r(74423),c=r(10790);const __=i.__,l=()=>{const{usagePeriod:e}=(0,s.useSelect)(e=>({usagePeriod:e(a.E).getAiAssistantFeature().nextTier}),[]),t=(e=>{const t=__("You've reached this month's request limit, per our fair usage policy.","jetpack");if(!e)return t; // Translators: %s is the date when the requests will reset. const r=__("Requests will reset on %s.","jetpack");return`${t} ${(0,i.sprintf)(r,e)}`})((e=>{if(!e?.nextStart)return null;const t=new Date(e.nextStart);return t.toLocaleString("default",{month:"long"})+" "+t.getDate()})(e)),r=(0,n.A)("ai-logo-generator-fair-usage-policy",{anchor:"jetpack-ai-usage-limit"});return(0,o.createInterpolateElement)(t,{link:(0,c.jsx)("a",{href:r,target:"_blank",rel:"noreferrer"}),span:(0,c.jsx)("span",{})})}},88725(e,t,r){"use strict";r.d(t,{A:()=>f});var n=r(47143),s=r(10067),o=r.n(s),i=r(51609),a=r(31439),c=r(62614),l=r(93869),u=r(51391),d=r(19362),p=r(28229),h=r(74423),m=r(44461);const g=o()("jetpack-ai-calypso:use-logo-generator"),f=()=>{const{setSelectedLogoIndex:e,setIsSavingLogoToLibrary:t,setIsApplyingLogo:r,setIsRequestingImage:s,setIsEnhancingPrompt:o,increaseAiAssistantRequestsCount:f,addLogoToHistory:b,setContext:v,setIsLoadingHistory:y}=(0,n.useDispatch)(h.E),{logos:k,selectedLogoIndex:_,selectedLogo:x,siteDetails:w,isSavingLogoToLibrary:j,isApplyingLogo:A,isEnhancingPrompt:C,isBusy:S,isRequestingImage:E,getAiAssistantFeature:T,requireUpgrade:N,context:P,tierPlansEnabled:R,isLoadingHistory:L}=(0,n.useSelect)(e=>{const t=e(h.E);return{logos:t.getLogos(),selectedLogoIndex:t.getSelectedLogoIndex(),selectedLogo:t.getSelectedLogo(),siteDetails:t.getSiteDetails(),isSavingLogoToLibrary:t.getIsSavingLogoToLibrary(),isApplyingLogo:t.getIsApplyingLogo(),isRequestingImage:t.getIsRequestingImage(),isEnhancingPrompt:t.getIsEnhancingPrompt(),isBusy:t.getIsBusy(),getAiAssistantFeature:t.getAiAssistantFeature,requireUpgrade:t.getRequireUpgrade(),context:t.getContext(),tierPlansEnabled:t.getTierPlansEnabled(),isLoadingHistory:t.getIsLoadingHistory()}},[]),{setFirstLogoPromptFetchError:D,setEnhancePromptFetchError:I,setLogoFetchError:B,setSaveToLibraryError:F,setLogoUpdateError:M}=(0,m.A)(),{generateImageWithParameters:U}=(0,c.Ay)(),{saveToMediaLibrary:O}=(0,l.A)(),{ID:z=null,name:q=null,description:$=null}=w||{},H=z?String(z):null,V=T(H),G=V?.costs?.["jetpack-ai-logo-generator"]?.logo,W=V?.featuresControl?.["logo-generator"],Z=W?.styles||[],J=(0,i.useCallback)(async function(){D(null),f();try{const e=await(0,u.A)();if(!e||!e.token)throw new Error("No token provided");g("Generating first prompt for site");const t={question:`Generate a simple and short prompt asking for a logo based on the site's name and description, keeping the same language.\nExample for a site named "The minimalist fashion blog", described as "Daily inspiration for all things fashion": A logo for a minimalist fashion site focused on daily sartorial inspiration with a clean and modern aesthetic that is sleek and sophisticated.\nAnother example, now for a site called "El observatorio de aves", described as "Un sitio dedicado a nuestros compañeros y compañeras entusiastas de la observación de aves.": Un logo para un sitio web dedicado a la observación de aves, capturando la esencia de la naturaleza y la pasión por la avifauna en un diseño elegante y representativo, reflejando una estética natural y apasionada por la vida silvestre.\n\nSite name: ${q}\nSite description: ${$}`,feature:"jetpack-ai-logo-generator",stream:!1},r="https://public-api.wordpress.com/wpcom/v2/jetpack-ai-query",n={Authorization:`Bearer ${e.token}`,"Content-Type":"application/json"},s=await fetch(r,{method:"POST",headers:n,body:JSON.stringify(t)}).then(e=>e.json());return s?.choices?.[0]?.message?.content}catch(e){throw f(-1),D(e),e}},[D,f,q,$]),K=(0,i.useCallback)(async function(e){if(B(null),!Z||!Z.length)return null;const t=[{role:"jetpack-ai",context:{type:"ai-assistant-guess-logo-style",request:e,name:q,description:$}}];try{const e=await(0,a.A)(t,{feature:"jetpack-ai-logo-generator"});if(!e)return null;const r=Z.find(({value:t})=>t===e);return r?r.value:null}catch(e){g("Error guessing style",e),Promise.reject(e)}},[Z,q,$]),Y=(0,i.useCallback)(async function({prompt:e,style:t=null}){B(null);try{const r=await(0,u.A)();if(!r||!r.token)throw new Error("No token provided");if("auto"===t)throw new Error("Auto style is not supported");g("Generating image with prompt",e);const n={prompt:`I NEED to test how the tool works with extremely simple prompts. DO NOT add any detail, just use it AS-IS:\nCreate a single text-free iconic vector logo that symbolically represents the user request, using abstract or symbolic imagery.\nThe design should be modern, with either a vivid color scheme full of gradients or a color scheme that's monochromatic. Use any of those styles based on the user request mood.\nEnsure the logo is set against a clean solid background.\nEnsure the logo works in small sizes.\nThe imagery in the logo should subtly hint at the mood of the user request but DO NOT use any text, letters, or the name of the site on the imagery.\nThe image should contain a single icon, without variations, color palettes or different versions.\n\nUser request:${e}`,messages:t?[{role:"jetpack-ai",context:{type:"ai-assistant-generate-logo",request:e,name:q,description:$,style:t}}]:[],feature:"jetpack-ai-logo-generator",response_format:"b64_json",style:t||""};return await U(n)}catch(e){throw B(e),e}},[q,$]),Q=(0,i.useCallback)(async e=>{F(null);try{if(g("Saving logo for site"),e.mediaId)return{mediaId:e.mediaId,mediaURL:e.url};const r={mediaId:0,mediaURL:""};t(!0);const{id:n,url:s}=await O(e.url,"site-logo.png");return r.mediaId=parseInt(n),r.mediaURL=s,r}catch(e){throw F(e),e}finally{t(!1)}},[t,F]),X=(0,i.useCallback)(async()=>{M(null);try{if(!H||!x)throw new Error("Missing siteId or logo");g("Applying logo for site",H),r(!0);const{mediaId:e}=x;if(!e)throw new Error("Missing mediaId");await(0,p.Z)({siteId:H,imageId:String(e)})}catch(e){throw M(e),e}finally{r(!1)}},[x,r,M,H]),ee=(0,i.useCallback)(e=>{b(e),(0,d.hm)({...e,siteId:String(H)})},[H,b,d.hm]),te=(0,i.useCallback)(async function({prompt:e,style:t}){g("Generating logo for site"),s(!0);try{if(!G)throw new Error("Missing cost information");let r;f(G);try{if(r=await Y({prompt:e,style:t}),!r||!r.data.length)throw new Error("No image returned")}catch(e){throw f(-G),e}const n=r.data[0].revised_prompt||null,s={url:"data:image/png;base64,"+r.data[0].b64_json,description:e,revisedPrompt:n};try{const t=await Q(s);ee({url:t.mediaURL,description:e,mediaId:t.mediaId,revisedPrompt:n})}catch(e){throw ee(s),e}}finally{s(!1)}},[G,f,Q,ee,Y]);return{logos:k,selectedLogoIndex:_,selectedLogo:x,setSelectedLogoIndex:e,site:{id:H,name:q,description:$},generateFirstPrompt:J,saveLogo:Q,applyLogo:X,generateImage:Y,enhancePrompt:async function({prompt:e}){I(null),f();try{const t=await(0,u.A)();if(!t||!t.token)throw new Error("No token provided");g("Enhancing prompt",e);const r={messages:[{role:"system",content:"Enhance the prompt you receive.\nThe prompt is meant for generating a logo. Return the same prompt enhanced, and make each enhancement wrapped in brackets.\nDo not add any mention to text, letters, typography or the name of the site in the prompt.\nFor example: user's prompt: A logo for an ice cream shop. Returned prompt: A logo for an ice cream shop [that is pink] [and vibrant]."},{role:"user",content:e}],feature:"jetpack-ai-logo-generator",stream:!1},n="https://public-api.wordpress.com/wpcom/v2/jetpack-ai-query",s={Authorization:`Bearer ${t.token}`,"Content-Type":"application/json"},o=await fetch(n,{method:"POST",headers:s,body:JSON.stringify(r)}).then(e=>e.json());return o?.choices?.[0]?.message?.content}catch(e){throw f(-1),I(e),e}},storeLogo:ee,generateLogo:te,setIsEnhancingPrompt:o,setIsRequestingImage:s,setIsSavingLogoToLibrary:t,setIsApplyingLogo:r,setContext:v,isEnhancingPrompt:C,isRequestingImage:E,isSavingLogoToLibrary:j,isApplyingLogo:A,isBusy:S,getAiAssistantFeature:T,requireUpgrade:N,context:P,tierPlansEnabled:R,isLoadingHistory:L,setIsLoadingHistory:y,imageStyles:Z,guessStyle:K}}},44461(e,t,r){"use strict";r.d(t,{A:()=>o});var n=r(47143),s=r(74423);const o=()=>{const{setFeatureFetchError:e,setFirstLogoPromptFetchError:t,setEnhancePromptFetchError:r,setLogoFetchError:o,setSaveToLibraryError:i,setLogoUpdateError:a}=(0,n.useDispatch)(s.E),{featureFetchError:c,firstLogoPromptFetchError:l,enhancePromptFetchError:u,logoFetchError:d,saveToLibraryError:p,logoUpdateError:h}=(0,n.useSelect)(e=>{const t=e(s.E);return{featureFetchError:t.getFeatureFetchError(),firstLogoPromptFetchError:t.getFirstLogoPromptFetchError(),enhancePromptFetchError:t.getEnhancePromptFetchError(),logoFetchError:t.getLogoFetchError(),saveToLibraryError:t.getSaveToLibraryError(),logoUpdateError:t.getLogoUpdateError()}},[]);return{setFeatureFetchError:e,setFirstLogoPromptFetchError:t,setEnhancePromptFetchError:r,setLogoFetchError:o,setSaveToLibraryError:i,setLogoUpdateError:a,clearErrors:()=>{e(null),t(null),r(null),o(null),i(null),a(null)},featureFetchError:c,firstLogoPromptFetchError:l,enhancePromptFetchError:u,logoFetchError:d,saveToLibraryError:p,logoUpdateError:h}}},23101(e,t,r){"use strict";r.d(t,{T:()=>n.T});var n=r(64537);r(11114)},19362(e,t,r){"use strict";r.d(t,{$t:()=>i,H:()=>o,NP:()=>a,Pv:()=>c,hm:()=>s});var n=r(13858);function s({siteId:e,url:t,description:r,mediaId:n,revisedPrompt:s}){const o=i(e),a={url:t,description:r,mediaId:n,revisedPrompt:s};return o.push(a),localStorage.setItem(`logo-history-${e}`,JSON.stringify(o.slice(-10))),a}function o({siteId:e,url:t,newUrl:r,mediaId:n,rating:s}){const o=i(e),a=o.findIndex(e=>e.url===t);return a>-1&&(o[a].url=r,o[a].mediaId=n,o[a].rating=s),localStorage.setItem(`logo-history-${e}`,JSON.stringify(o.slice(-10))),o[a]}function i(e){const t=localStorage.getItem(`logo-history-${e}`);let r=t?JSON.parse(t):[];return Array.isArray(r)||(r=[]),r=r.slice(-10),r=r.filter(e=>"object"==typeof e&&"string"==typeof e.url&&"string"==typeof e.description).map(e=>({url:e.url,description:e.description,mediaId:e.mediaId,rating:e.rating})),r}function a(e){return 0===i(e).length}async function c(e){const t=i(e).filter(({mediaId:e})=>void 0!==e).map(({mediaId:t})=>new Promise((r,s)=>{(0,n.T)({siteId:e,mediaId:t}).then(e=>r({mediaId:t,exists:e})).catch(e=>s(e))}));try{(await Promise.all(t)).filter(({exists:e})=>!e).forEach(({mediaId:t})=>function({siteId:e,mediaId:t}){const r=i(e),n=r.findIndex(e=>e.mediaId===t);-1!==n&&(r.splice(n,1),localStorage.setItem(`logo-history-${e}`,JSON.stringify(r)))}({siteId:e,mediaId:t}))}catch{}}},13858(e,t,r){"use strict";r.d(t,{T:()=>s});var n=r(48931);async function s({mediaId:e}){const t=Number(e);if(Number.isNaN(t))return!1;try{return await(0,n.A)({path:`/wp/v2/media/${Number(e)}`,method:"GET"}),!0}catch(e){const t=e?.data?.status;if(404===t)return!1;throw e}}},28229(e,t,r){"use strict";r.d(t,{Z:()=>s});var n=r(22746);async function s({siteId:e,imageId:t}){const r={site_logo:t,site_icon:t};return(0,n.A)({path:`/sites/${String(e)}/settings`,apiVersion:"v2",apiNamespace:"wp/v2",body:r,query:"source=jetpack-ai",method:"POST"})}},22746(e,t,r){"use strict";r.d(t,{A:()=>o});var n=r(48931);let s=0;async function o(e){if(s+=1,s>5)throw s-=1,new Error("Too many requests");return(0,n.A)(e).finally(()=>{s-=1})}},9624(e,t,r){"use strict";r.d(t,{A:()=>a});var n=r(19362),s=r(22746),o=r(9938);const i={storeAiAssistantFeature:e=>({type:o.UU,feature:e}),fetchAiAssistantFeature:()=>async({dispatch:e})=>{e({type:o.ql});try{const t=await(0,s.A)({path:"/wpcom/v2/jetpack-ai/ai-assistant-feature",query:"force=wpcom"});if(t.data)throw new Error("Failed to fetch");e(i.storeAiAssistantFeature(function(e){return{hasFeature:!!e["has-feature"],isOverLimit:!!e["is-over-limit"],requestsCount:e["requests-count"],requestsLimit:e["requests-limit"],requireUpgrade:!!e["site-require-upgrade"],errorMessage:e["error-message"],errorCode:e["error-code"],upgradeType:e["upgrade-type"],usagePeriod:{currentStart:e["usage-period"]?.["current-start"],nextStart:e["usage-period"]?.["next-start"],requestsCount:e["usage-period"]?.["requests-count"]||0},currentTier:e["current-tier"],nextTier:e["next-tier"],tierPlansEnabled:!!e["tier-plans-enabled"],costs:e.costs,featuresControl:e["features-control"]}}(t)))}catch(t){e({type:o.Rx,error:t})}},increaseAiAssistantRequestsCount:(e=1)=>({dispatch:t})=>{t({type:o.Lg,count:e})},setAiAssistantFeatureRequireUpgrade:(e=!0)=>({type:o.Kt,requireUpgrade:e}),setTierPlansEnabled:(e=!0)=>({type:o.c1,tierPlansEnabled:e}),setSiteDetails:e=>({type:o.Bz,siteDetails:e}),setSelectedLogoIndex:e=>({type:o.BG,selectedLogoIndex:e}),addLogoToHistory:e=>({type:o.sG,logo:e}),setIsSavingLogoToLibrary:e=>({type:o.E6,isSavingLogoToLibrary:e}),setIsApplyingLogo:e=>({type:o.Ep,isApplyingLogo:e}),updateSelectedLogo:(e,t)=>({type:o.r_,mediaId:e,url:t}),setIsRequestingImage:e=>({type:o.vk,isRequestingImage:e}),setIsEnhancingPrompt:e=>({type:o.O5,isEnhancingPrompt:e}),loadLogoHistory(e){const t=(0,n.$t)(e);return{type:o.ZI,history:t}},setFeatureFetchError:e=>({type:o.Rx,error:e}),setFirstLogoPromptFetchError:e=>({type:o.MQ,error:e}),setEnhancePromptFetchError:e=>({type:o.gG,error:e}),setLogoFetchError:e=>({type:o.q_,error:e}),setSaveToLibraryError:e=>({type:o.x0,error:e}),setLogoUpdateError:e=>({type:o.FN,error:e}),setContext:e=>({type:o.kZ,context:e}),setIsLoadingHistory:e=>({type:o.hY,isLoadingHistory:e})},a=i},9938(e,t,r){"use strict";r.d(t,{BG:()=>h,Bz:()=>c,E6:()=>g,Ep:()=>f,FN:()=>S,GB:()=>l,Kt:()=>i,Lg:()=>o,MQ:()=>w,O5:()=>y,Rx:()=>x,UU:()=>n,ZI:()=>k,c1:()=>a,gG:()=>j,hY:()=>_,kZ:()=>p,mx:()=>d,nb:()=>u,q_:()=>A,ql:()=>s,r_:()=>b,sG:()=>m,vk:()=>v,x0:()=>C});const n="STORE_AI_ASSISTANT_FEATURE",s="REQUEST_AI_ASSISTANT_FEATURE",o="INCREASE_AI_ASSISTANT_REQUESTS_COUNT",i="SET_AI_ASSISTANT_FEATURE_REQUIRE_UPGRADE",a="SET_TIER_PLANS_ENABLED",c="SET_SITE_DETAILS",l=20,u=3e3,d=3,p="SET_CONTEXT",h="SET_SELECTED_LOGO_INDEX",m="ADD_LOGO_TO_HISTORY",g="SET_IS_SAVING_LOGO_TO_LIBRARY",f="SET_IS_APPLYING_LOGO",b="SAVE_SELECTED_LOGO",v="SET_IS_REQUESTING_IMAGE",y="SET_IS_ENHANCING_PROMPT",k="SET_SITE_HISTORY",_="SET_IS_LOADING_HISTORY",x="SET_FEATURE_FETCH_ERROR",w="SET_FIRST_LOGO_PROMPT_FETCH_ERROR",j="SET_ENHANCE_PROMPT_FETCH_ERROR",A="SET_LOGO_FETCH_ERROR",C="SET_SAVE_TO_LIBRARY_ERROR",S="SET_LOGO_UPDATE_ERROR"},74423(e,t,r){"use strict";r.d(t,{E:()=>a});var n=r(47143),s=r(9624),o=r(23695),i=r(80037);const a="jetpack-ai/logo-generator",c=(0,n.createReduxStore)(a,{__experimentalUseThunks:!0,actions:s.A,reducer:o.A,selectors:i.A});(0,n.register)(c)},94891(e,t,r){"use strict";r.d(t,{A:()=>s});var n=r(9938);const s={siteDetails:{},features:{aiAssistantFeature:{hasFeature:!0,isOverLimit:!1,requestsCount:0,requestsLimit:n.GB,requireUpgrade:!1,errorMessage:"",errorCode:"",upgradeType:"default",currentTier:{slug:"ai-assistant-tier-free",value:0,limit:20},usagePeriod:{currentStart:"",nextStart:"",requestsCount:0},nextTier:null,tierPlansEnabled:!1,_meta:{isRequesting:!1,asyncRequestCountdown:n.mx,asyncRequestTimerId:0,isRequestingImage:!1},featuresControl:{"logo-generator":{enabled:!1,styles:[]}}}},history:[],selectedLogoIndex:0}},23695(e,t,r){"use strict";r.d(t,{A:()=>i});var n=r(61356),s=r(9938),o=r(94891);function i(e=o.A,t){switch(t.type){case s.ql:return{...e,_meta:{...e._meta??{},featureFetchError:null},features:{...e.features,aiAssistantFeature:{...e.features.aiAssistantFeature,_meta:{...e?.features?.aiAssistantFeature?._meta,isRequesting:!0,asyncRequestCountdown:s.mx,asyncRequestTimerId:0}}}};case s.UU:{const r={"jetpack-ai-logo-generator":{logo:n._S}};return{...e,features:{...e.features,aiAssistantFeature:{costs:r,...t.feature,requireUpgrade:t.feature?.requireUpgrade||0===t.feature?.currentTier?.value,_meta:{...e?.features?.aiAssistantFeature?._meta,isRequesting:!1}}}}}case s.Lg:{const r=e?.features?.aiAssistantFeature?.usagePeriod||{requestsCount:0},n=(e?.features?.aiAssistantFeature?.requestsCount||0)+(t.count??1);r.requestsCount+=t.count??1;const o=e?.features?.aiAssistantFeature?.currentTier?.value,i=void 0===o&&!e?.features?.aiAssistantFeature?.hasFeature||0===o,a=void 0===o&&e?.features?.aiAssistantFeature?.hasFeature||1===o;let c=e?.features?.aiAssistantFeature?.currentTier?.limit||s.GB;a?c=s.nb:i&&(c=e?.features?.aiAssistantFeature?.requestsLimit);const l=(a||i?n:e?.features?.aiAssistantFeature?.usagePeriod?.requestsCount||0)>=c,u=i||l&&null!==e?.features?.aiAssistantFeature?.nextTier;return{...e,features:{...e.features,aiAssistantFeature:{...e.features.aiAssistantFeature,isOverLimit:l,requestsCount:n,requireUpgrade:u,usagePeriod:{...r}}}}}case s.Kt:return{...e,features:{...e.features,aiAssistantFeature:{...e.features.aiAssistantFeature,requireUpgrade:t.requireUpgrade,...t.requireUpgrade?{isOverLimit:!0}:{}}}};case s.c1:return{...e,features:{...e.features,aiAssistantFeature:{...e.features.aiAssistantFeature,tierPlansEnabled:t.tierPlansEnabled}}};case s.Bz:return{...e,siteDetails:t.siteDetails};case s.BG:return{...e,selectedLogoIndex:t.selectedLogoIndex};case s.sG:{const r=[...e.history,t.logo];return{...e,history:r,selectedLogoIndex:r.length-1}}case s.E6:return{...e,_meta:{...e._meta??{},isSavingLogoToLibrary:t.isSavingLogoToLibrary}};case s.Ep:return{...e,_meta:{...e._meta??{},isApplyingLogo:t.isApplyingLogo}};case s.r_:{const r=e.history?.[e.selectedLogoIndex];return{...e,history:[...e.history.slice(0,e.selectedLogoIndex),{...r,mediaId:t.mediaId,url:t.url},...e.history.slice(e.selectedLogoIndex+1)]}}case s.vk:return{...e,_meta:{...e._meta??{},isRequestingImage:t.isRequestingImage}};case s.O5:return{...e,_meta:{...e._meta??{},isEnhancingPrompt:t.isEnhancingPrompt}};case s.ZI:return{...e,history:t.history,selectedLogoIndex:t.history?.length?t.history.length-1:0};case s.Rx:return{...e,features:{...e.features,aiAssistantFeature:{...e?.features?.aiAssistantFeature,_meta:{...e?.features?.aiAssistantFeature?._meta,isRequesting:!1}}},_meta:{...e._meta??{},featureFetchError:t.error}};case s.MQ:return{...e,_meta:{...e._meta??{},firstLogoPromptFetchError:t.error}};case s.gG:return{...e,_meta:{...e._meta??{},enhancePromptFetchError:t.error}};case s.q_:return{...e,_meta:{...e._meta??{},logoFetchError:t.error}};case s.x0:return{...e,_meta:{...e._meta??{},saveToLibraryError:t.error}};case s.FN:return{...e,_meta:{...e._meta??{},logoUpdateError:t.error}};case s.kZ:return{...e,_meta:{...e._meta??{},context:t.context}};case s.hY:return{...e,_meta:{...e._meta??{},isLoadingHistory:t.isLoadingHistory}}}return e}},80037(e,t,r){"use strict";r.d(t,{A:()=>o});var n=r(61356);const s={getAiAssistantFeature(e){const t={...e.features.aiAssistantFeature};return delete t._meta,t},getSiteDetails:e=>e.siteDetails,getIsRequestingAiAssistantFeature:e=>e.features.aiAssistantFeature?._meta?.isRequesting??!1,getLogos:e=>e.history??[],getSelectedLogoIndex:e=>e.selectedLogoIndex??null,getSelectedLogo:e=>e.history?.[e.selectedLogoIndex]??null,getIsSavingLogoToLibrary:e=>e._meta?.isSavingLogoToLibrary??!1,getIsApplyingLogo:e=>e._meta?.isApplyingLogo??!1,getIsEnhancingPrompt:e=>e._meta?.isEnhancingPrompt??!1,getIsRequestingImage:e=>e._meta?.isRequestingImage??!1,getIsBusy:e=>s.getIsApplyingLogo(e)||s.getIsSavingLogoToLibrary(e)||s.getIsRequestingImage(e)||s.getIsEnhancingPrompt(e),getRequireUpgrade(e){const t=e.features.aiAssistantFeature;if(!t?.tierPlansEnabled)return t?.requireUpgrade;const r=t?.costs?.["jetpack-ai-logo-generator"]?.logo??n._S,s=t?.currentTier?.value||0,o=t?.usagePeriod?.requestsCount||0,i=1===s,a=!t?.nextTier;return e.features.aiAssistantFeature?.requireUpgrade||!i&&!a&&s-oe._meta?.featureFetchError??null,getFirstLogoPromptFetchError:e=>e._meta?.firstLogoPromptFetchError??null,getEnhancePromptFetchError:e=>e._meta?.enhancePromptFetchError??null,getLogoFetchError:e=>e._meta?.logoFetchError??null,getSaveToLibraryError:e=>e._meta?.saveToLibraryError??null,getLogoUpdateError:e=>e._meta?.logoUpdateError??null,getContext:e=>e._meta?.context??"",getTierPlansEnabled:e=>e.features.aiAssistantFeature?.tierPlansEnabled??!1,getIsLoadingHistory:e=>e._meta?.isLoadingHistory??!1},o=s},53664(e,t,r){"use strict";r.d(t,{A:()=>u});var n=r(7675),s=r(10067),o=r.n(s),i=r(46219),a=r(51391),c=r(78836);const l=o()("jetpack-ai-client:suggestions-event-source");class u extends EventTarget{constructor(e){super(),this.fullMessage="",this.fullFunctionCall={name:"",arguments:""},this.isPromptClear=!1,this.controller=new AbortController,this.initEventSource(e)}async initEventSource({url:e,question:t,token:r,options:s={}}){if(!r)try{l("Token was not provided, requesting one..."),r=(await(0,a.A)()).token}catch(e){return void this.processErrorEvent(e)}const o={};if(Number.isInteger(parseInt(s.postId))&&(o.post_id=+s.postId),!e){const t=new URL("https://public-api.wordpress.com/wpcom/v2/jetpack-ai-query");s?.fromCache&&t.searchParams.append("stream_cache","true"),e=t.toString(),l("URL not provided, using default: %o",e)}Array.isArray(t)?o.messages=t:o.question=t,s?.feature?.length&&(l("Feature: %o",s.feature),o.feature=s.feature),s?.functions?.length&&(l("Functions: %o",s.functions),o.functions=s.functions),s?.model?.length&&(l("Model: %o",s.model),o.model=s.model),s?.languageCode?.length&&(l("Language: %o",s.languageCode),o.language_code=s.languageCode),this.errorUnclearPromptTriggered=!1,await(0,n.y)(e,{openWhenHidden:!0,method:"POST",headers:{"Content-type":"application/json",Authorization:"Bearer "+r},body:JSON.stringify(o),onclose:()=>{l("Stream closed")},onerror:e=>{throw this.processErrorEvent(e),e},onmessage:e=>{this.processEvent(e)},onopen:async e=>{if(e.ok)return;let t;throw e.status>=400&&e.status<=500&&![413,422,429].includes(e.status)&&(l("Connection error: %o",e),t=c.mA,this.dispatchEvent(new CustomEvent(c.mA,{detail:e}))),503===e.status&&(t=c.AZ,this.dispatchEvent(new CustomEvent(c.AZ))),413===e.status&&(t=c.cT,this.dispatchEvent(new CustomEvent(c.cT))),422===e.status&&(t=c.ud,this.dispatchEvent(new CustomEvent(c.ud))),429===e.status&&(t=c.Or,this.dispatchEvent(new CustomEvent(c.Or))),this.dispatchEvent(new CustomEvent(c.zn,{detail:(0,i.fC)(t)})),new Error},signal:this.controller.signal})}checkForUnclearPrompt(){if(this.isPromptClear)return;const e=this.fullMessage.replace(/__|(\*\*)/g,"");if(e.startsWith("JETPACK_AI_ERROR")){if(this.errorUnclearPromptTriggered)return;this.errorUnclearPromptTriggered=!0,this.dispatchEvent(new CustomEvent(c.L9)),l("Unclear error prompt dispatched"),this.dispatchEvent(new CustomEvent(c.zn,{detail:(0,i.fC)(c.L9)}))}else"JETPACK_AI_ERROR".startsWith(e)?l(this.fullMessage):this.isPromptClear=!0}close(){this.controller.abort()}processEvent(e){if("[DONE]"===e.data){if(this.errorUnclearPromptTriggered)return;if(this.fullMessage.length)return this.dispatchEvent(new CustomEvent("done",{detail:this.fullMessage})),void l("Done: %o",this.fullMessage);if(this.fullFunctionCall.name.length)return this.dispatchEvent(new CustomEvent("function_done",{detail:this.fullFunctionCall})),void l("Done: %o",this.fullFunctionCall)}let t;try{t=JSON.parse(e.data)}catch(t){return void l("Error parsing JSON",e,t)}const{delta:r}=t?.choices?.[0]??{delta:{content:null,function_call:null}},n=r.content,s=r.function_call;n&&(this.fullMessage+=n,this.checkForUnclearPrompt(),this.isPromptClear&&(this.dispatchEvent(new CustomEvent("chunk",{detail:n})),l("suggestion: %o",this.fullMessage),this.dispatchEvent(new CustomEvent("suggestion",{detail:this.fullMessage})))),s&&(null!=s.name&&(this.fullFunctionCall.name+=s.name),null!=s.arguments&&(this.fullFunctionCall.arguments+=s.arguments),this.dispatchEvent(new CustomEvent("functionCallChunk",{detail:this.fullFunctionCall})))}processErrorEvent(e){l("onerror: %o",e),this.dispatchEvent(new CustomEvent(c.mA,{detail:e})),this.dispatchEvent(new CustomEvent(c.zn,{detail:(0,i.fC)(c.mA)}))}}},78836(e,t,r){"use strict";r.d(t,{AZ:()=>s,L9:()=>l,Np:()=>d,Or:()=>o,cT:()=>a,mA:()=>c,uH:()=>n.u,ud:()=>i,zn:()=>u});var n=r(97784);const s="error_service_unavailable",o="error_quota_exceeded",i="error_moderation",a="error_context_too_large",c="error_network",l="error_unclear_prompt",u="error_response",d="default"},90372(e,t,r){"use strict";r.d(t,{A:()=>c});var n=r(10067);const s=r.n(n)()("dops:analytics");let o,i;window._tkq=window._tkq||[],window.ga=window.ga||function(){(window.ga.q=window.ga.q||[]).push(arguments)},window.ga.l=+new Date;const a={initialize:function(e,t,r){a.setUser(e,t),a.setSuperProps(r),a.identifyUser()},setGoogleAnalyticsEnabled:function(e,t=null){this.googleAnalyticsEnabled=e,this.googleAnalyticsKey=t},setMcAnalyticsEnabled:function(e){this.mcAnalyticsEnabled=e},setUser:function(e,t){i={ID:e,username:t}},setSuperProps:function(e){o=e},assignSuperProps:function(e){o=Object.assign(o||{},e)},mc:{bumpStat:function(e,t){const r=function(e,t){let r="";if("object"==typeof e){for(const t in e)r+="&x_"+encodeURIComponent(t)+"="+encodeURIComponent(e[t]);s("Bumping stats %o",e)}else r="&x_"+encodeURIComponent(e)+"="+encodeURIComponent(t),s('Bumping stat "%s" in group "%s"',t,e);return r}(e,t);a.mcAnalyticsEnabled&&((new Image).src=document.location.protocol+"//pixel.wp.com/g.gif?v=wpcom-no-pv"+r+"&t="+Math.random())},bumpStatWithPageView:function(e,t){const r=function(e,t){let r="";if("object"==typeof e){for(const t in e)r+="&"+encodeURIComponent(t)+"="+encodeURIComponent(e[t]);s("Built stats %o",e)}else r="&"+encodeURIComponent(e)+"="+encodeURIComponent(t),s('Built stat "%s" in group "%s"',t,e);return r}(e,t);a.mcAnalyticsEnabled&&((new Image).src=document.location.protocol+"//pixel.wp.com/g.gif?v=wpcom"+r+"&t="+Math.random())}},pageView:{record:function(e,t){a.tracks.recordPageView(e),a.ga.recordPageView(e,t)}},purchase:{record:function(e,t,r,n,s,o,i){a.ga.recordPurchase(e,t,r,n,s,o,i)}},tracks:{recordEvent:function(e,t){t=t||{},0===e.indexOf("akismet_")||0===e.indexOf("jetpack_")?(!t.blog_id&&"object"==typeof window.jpTracksContext&&window.jpTracksContext.blog_id&&(t.blog_id=window.jpTracksContext.blog_id),o&&(s("- Super Props: %o",o),t=Object.assign(t,o)),s('Record event "%s" called with props %s',e,JSON.stringify(t)),window._tkq.push(["recordEvent",e,t])):s('- Event name must be prefixed by "akismet_" or "jetpack_"')},recordJetpackClick:function(e){const t="object"==typeof e?e:{target:e};a.tracks.recordEvent("jetpack_wpa_click",t)},recordPageView:function(e){a.tracks.recordEvent("akismet_page_view",{path:e})},setOptOut:function(e){s("Pushing setOptOut: %o",e),window._tkq.push(["setOptOut",e])}},ga:{initialized:!1,initialize:function(){let e={};a.ga.initialized||(i&&(e={userId:"u-"+i.ID}),window.ga("create",this.googleAnalyticsKey,"auto",e),a.ga.initialized=!0)},recordPageView:function(e,t){a.ga.initialize(),s("Recording Page View ~ [URL: "+e+"] [Title: "+t+"]"),this.googleAnalyticsEnabled&&(window.ga("set","page",e),window.ga("send",{hitType:"pageview",page:e,title:t}))},recordEvent:function(e,t,r,n){a.ga.initialize();let o="Recording Event ~ [Category: "+e+"] [Action: "+t+"]";void 0!==r&&(o+=" [Option Label: "+r+"]"),void 0!==n&&(o+=" [Option Value: "+n+"]"),s(o),this.googleAnalyticsEnabled&&window.ga("send","event",e,t,r,n)},recordPurchase:function(e,t,r,n,s,o,i){window.ga("require","ecommerce"),window.ga("ecommerce:addTransaction",{id:e,revenue:n,currency:i}),window.ga("ecommerce:addItem",{id:e,name:t,sku:r,price:s,quantity:o}),window.ga("ecommerce:send")}},identifyUser:function(){i&&window._tkq.push(["identifyUser",i.ID,i.username])},setProperties:function(e){window._tkq.push(["setProperties",e])},clearedIdentity:function(){window._tkq.push(["clearIdentity"])}},c=a},5932(e,t,r){"use strict";r.d(t,{Ay:()=>d});var n=r(56439),s=r(93832);function o(e){class t extends Error{constructor(...t){super(...t),this.name=e}}return t}const i=o("JsonParseError"),a=o("JsonParseAfterRedirectError"),c=o("Api404Error"),l=o("Api404AfterRedirectError"),u=o("FetchNetworkError");const d=new function(e,t){let r=e,o=e,i={"X-WP-Nonce":t},a={credentials:"same-origin",headers:i},c={method:"post",credentials:"same-origin",headers:Object.assign({},i,{"Content-type":"application/json"})},l=function(e){const t=e.split("?"),r=t.length>1?t[1]:"",n=r.length?r.split("&"):[];return n.push("_cacheBuster="+(new Date).getTime()),t[0]+"?"+n.join("&")};const u={setApiRoot(e){r=e},setWpcomOriginApiUrl(e){o=e},setApiNonce(e){i={"X-WP-Nonce":e},a={credentials:"same-origin",headers:i},c={method:"post",credentials:"same-origin",headers:Object.assign({},i,{"Content-type":"application/json"})}},setCacheBusterCallback:e=>{l=e},registerSite:(e,t,s)=>{const o={};return(0,n.jetpackConfigHas)("consumer_slug")&&(o.plugin_slug=(0,n.jetpackConfigGet)("consumer_slug")),null!==t&&(o.redirect_uri=t),s&&(o.from=s),m(`${r}jetpack/v4/connection/register`,c,{body:JSON.stringify(o)}).then(p).then(h)},fetchAuthorizationUrl:e=>d((0,s.addQueryArgs)(`${r}jetpack/v4/connection/authorize_url`,{no_iframe:"1",redirect_uri:e}),a).then(p).then(h),fetchSiteConnectionData:()=>d(`${r}jetpack/v4/connection/data`,a).then(h),fetchSiteConnectionStatus:()=>d(`${r}jetpack/v4/connection`,a).then(h),fetchSiteConnectionTest:()=>d(`${r}jetpack/v4/connection/test`,a).then(p).then(h),fetchUserConnectionData:()=>d(`${r}jetpack/v4/connection/data`,a).then(h),fetchUserTrackingSettings:()=>d(`${r}jetpack/v4/tracking/settings`,a).then(p).then(h),updateUserTrackingSettings:e=>m(`${r}jetpack/v4/tracking/settings`,c,{body:JSON.stringify(e)}).then(p).then(h),disconnectSite:()=>m(`${r}jetpack/v4/connection`,c,{body:JSON.stringify({isActive:!1})}).then(p).then(h),fetchConnectUrl:()=>d(`${r}jetpack/v4/connection/url`,a).then(p).then(h),unlinkUser:(e=!1,t={})=>{const n={linked:!1,force:!!e};return t.disconnectAllUsers&&(n["disconnect-all-users"]=!0),m(`${r}jetpack/v4/connection/user`,c,{body:JSON.stringify(n)}).then(p).then(h)},reconnect:()=>m(`${r}jetpack/v4/connection/reconnect`,c).then(p).then(h),fetchConnectedPlugins:()=>d(`${r}jetpack/v4/connection/plugins`,a).then(p).then(h),setHasSeenWCConnectionModal:()=>m(`${r}jetpack/v4/seen-wc-connection-modal`,c).then(p).then(h),fetchModules:()=>d(`${r}jetpack/v4/module/all`,a).then(p).then(h),fetchModule:e=>d(`${r}jetpack/v4/module/${e}`,a).then(p).then(h),activateModule:e=>m(`${r}jetpack/v4/module/${e}/active`,c,{body:JSON.stringify({active:!0})}).then(p).then(h),deactivateModule:e=>m(`${r}jetpack/v4/module/${e}/active`,c,{body:JSON.stringify({active:!1})}),updateModuleOptions:(e,t)=>m(`${r}jetpack/v4/module/${e}`,c,{body:JSON.stringify(t)}).then(p).then(h),updateSettings:e=>m(`${r}jetpack/v4/settings`,c,{body:JSON.stringify(e)}).then(p).then(h),getProtectCount:()=>d(`${r}jetpack/v4/module/protect/data`,a).then(p).then(h),resetOptions:e=>m(`${r}jetpack/v4/options/${e}`,c,{body:JSON.stringify({reset:!0})}).then(p).then(h),activateVaultPress:()=>m(`${r}jetpack/v4/plugins`,c,{body:JSON.stringify({slug:"vaultpress",status:"active"})}).then(p).then(h),getVaultPressData:()=>d(`${r}jetpack/v4/module/vaultpress/data`,a).then(p).then(h),installPlugin:(e,t)=>{const n={slug:e,status:"active"};return t&&(n.source=t),m(`${r}jetpack/v4/plugins`,c,{body:JSON.stringify(n)}).then(p).then(h)},activateAkismet:()=>m(`${r}jetpack/v4/plugins`,c,{body:JSON.stringify({slug:"akismet",status:"active"})}).then(p).then(h),getAkismetData:()=>d(`${r}jetpack/v4/module/akismet/data`,a).then(p).then(h),checkAkismetKey:()=>d(`${r}jetpack/v4/module/akismet/key/check`,a).then(p).then(h),checkAkismetKeyTyped:e=>m(`${r}jetpack/v4/module/akismet/key/check`,c,{body:JSON.stringify({api_key:e})}).then(p).then(h),getFeatureTypeStatus:e=>d(`${r}jetpack/v4/feature/${e}`,a).then(p).then(h),fetchStatsData:e=>d(function(e){let t=`${r}jetpack/v4/module/stats/data`;-1!==t.indexOf("?")?t+=`&range=${encodeURIComponent(e)}`:t+=`?range=${encodeURIComponent(e)}`;return t}(e),a).then(p).then(h).then(f),getPluginUpdates:()=>d(`${r}jetpack/v4/updates/plugins`,a).then(p).then(h),getPlans:()=>d(`${r}jetpack/v4/plans`,a).then(p).then(h),fetchSettings:()=>d(`${r}jetpack/v4/settings`,a).then(p).then(h),updateSetting:e=>m(`${r}jetpack/v4/settings`,c,{body:JSON.stringify(e)}).then(p).then(h),fetchSiteData:()=>d(`${r}jetpack/v4/site`,a).then(p).then(h).then(e=>JSON.parse(e.data)),fetchSiteFeatures:()=>d(`${r}jetpack/v4/site/features`,a).then(p).then(h).then(e=>JSON.parse(e.data)),fetchSiteProducts:()=>d(`${r}jetpack/v4/site/products`,a).then(p).then(h),fetchSitePurchases:()=>d(`${r}jetpack/v4/site/purchases`,a).then(p).then(h).then(e=>JSON.parse(e.data)),fetchSiteBenefits:()=>d(`${r}jetpack/v4/site/benefits`,a).then(p).then(h).then(e=>JSON.parse(e.data)),fetchSiteDiscount:()=>d(`${r}jetpack/v4/site/discount`,a).then(p).then(h).then(e=>e.data),fetchSetupQuestionnaire:()=>d(`${r}jetpack/v4/setup/questionnaire`,a).then(p).then(h),fetchRecommendationsData:()=>d(`${r}jetpack/v4/recommendations/data`,a).then(p).then(h),fetchRecommendationsProductSuggestions:()=>d(`${r}jetpack/v4/recommendations/product-suggestions`,a).then(p).then(h),fetchRecommendationsUpsell:()=>d(`${r}jetpack/v4/recommendations/upsell`,a).then(p).then(h),fetchRecommendationsConditional:()=>d(`${r}jetpack/v4/recommendations/conditional`,a).then(p).then(h),saveRecommendationsData:e=>m(`${r}jetpack/v4/recommendations/data`,c,{body:JSON.stringify({data:e})}).then(p),fetchProducts:()=>d(`${r}jetpack/v4/products`,a).then(p).then(h),fetchRewindStatus:()=>d(`${r}jetpack/v4/rewind`,a).then(p).then(h).then(e=>JSON.parse(e.data)),fetchScanStatus:()=>d(`${r}jetpack/v4/scan`,a).then(p).then(h).then(e=>JSON.parse(e.data)),dismissJetpackNotice:e=>m(`${r}jetpack/v4/notice/${e}`,c,{body:JSON.stringify({dismissed:!0})}).then(p).then(h),fetchPluginsData:()=>d(`${r}jetpack/v4/plugins`,a).then(p).then(h),fetchIntroOffers:()=>d(`${r}jetpack/v4/intro-offers`,a).then(p).then(h),fetchVerifySiteGoogleStatus:e=>d(null!==e?`${r}jetpack/v4/verify-site/google/${e}`:`${r}jetpack/v4/verify-site/google`,a).then(p).then(h),verifySiteGoogle:e=>m(`${r}jetpack/v4/verify-site/google`,c,{body:JSON.stringify({keyring_id:e})}).then(p).then(h),submitSurvey:e=>m(`${r}jetpack/v4/marketing/survey`,c,{body:JSON.stringify(e)}).then(p).then(h),saveSetupQuestionnaire:e=>m(`${r}jetpack/v4/setup/questionnaire`,c,{body:JSON.stringify(e)}).then(p).then(h),updateLicensingError:e=>m(`${r}jetpack/v4/licensing/error`,c,{body:JSON.stringify(e)}).then(p).then(h),updateLicenseKey:e=>m(`${r}jetpack/v4/licensing/set-license`,c,{body:JSON.stringify({license:e})}).then(p).then(h),getUserLicensesCounts:()=>d(`${r}jetpack/v4/licensing/user/counts`,a).then(p).then(h),getUserLicenses:()=>d(`${r}jetpack/v4/licensing/user/licenses`,a).then(p).then(h),updateLicensingActivationNoticeDismiss:e=>m(`${r}jetpack/v4/licensing/user/activation-notice-dismiss`,c,{body:JSON.stringify({last_detached_count:e})}).then(p).then(h),updateRecommendationsStep:e=>m(`${r}jetpack/v4/recommendations/step`,c,{body:JSON.stringify({step:e})}).then(p),confirmIDCSafeMode:()=>m(`${r}jetpack/v4/identity-crisis/confirm-safe-mode`,c).then(p),startIDCFresh:e=>m(`${r}jetpack/v4/identity-crisis/start-fresh`,c,{body:JSON.stringify({redirect_uri:e})}).then(p).then(h),migrateIDC:()=>m(`${r}jetpack/v4/identity-crisis/migrate`,c).then(p),attachLicenses:e=>m(`${r}jetpack/v4/licensing/attach-licenses`,c,{body:JSON.stringify({licenses:e})}).then(p).then(h),fetchSearchPlanInfo:()=>d(`${o}jetpack/v4/search/plan`,a).then(p).then(h),fetchSearchSettings:()=>d(`${o}jetpack/v4/search/settings`,a).then(p).then(h),updateSearchSettings:e=>m(`${o}jetpack/v4/search/settings`,c,{body:JSON.stringify(e)}).then(p).then(h),fetchSearchStats:()=>d(`${o}jetpack/v4/search/stats`,a).then(p).then(h),fetchWafSettings:()=>d(`${r}jetpack/v4/waf`,a).then(p).then(h),updateWafSettings:e=>m(`${r}jetpack/v4/waf`,c,{body:JSON.stringify(e)}).then(p).then(h),fetchWordAdsSettings:()=>d(`${r}jetpack/v4/wordads/settings`,a).then(p).then(h),updateWordAdsSettings:e=>m(`${r}jetpack/v4/wordads/settings`,c,{body:JSON.stringify(e)}),fetchSearchPricing:()=>d(`${o}jetpack/v4/search/pricing`,a).then(p).then(h),fetchMigrationStatus:()=>d(`${r}jetpack/v4/migration/status`,a).then(p).then(h),fetchBackupUndoEvent:()=>d(`${r}jetpack/v4/site/backup/undo-event`,a).then(p).then(h),fetchBackupPreflightStatus:()=>d(`${r}jetpack/v4/site/backup/preflight`,a).then(p).then(h)};function d(e,t){return fetch(l(e),t)}function m(e,t,r){return fetch(e,Object.assign({},t,r)).catch(g)}function f(e){return e.general&&void 0===e.general.response||e.week&&void 0===e.week.response||e.month&&void 0===e.month.response?e:{}}Object.assign(this,u)};function p(e){return e.status>=200&&e.status<300?e:404===e.status?new Promise(()=>{throw e.redirected?new l(e.redirected):new c}):e.json().catch(e=>m(e)).then(t=>{const r=new Error(`${t.message} (Status ${e.status})`);throw r.response=t,r.name="ApiError",r})}function h(e){return e.json().catch(t=>m(t,e.redirected,e.url))}function m(e,t,r){throw t?new a(r):new i}function g(){throw new u}},11876(e,t,r){"use strict";r.d(t,{A:()=>i});var n=r(13022),s=r(13372),o=r(10790);const i=({children:e=null,width:t=null,height:r=null,className:i=""})=>(0,o.jsx)("div",{className:(0,n.A)(s.A.placeholder,i),style:{width:t,height:r},children:e})},50723(e,t,r){"use strict";r.d(t,{Ay:()=>p});var n=r(51609),s=r(74116),o=r(10790);const i={"--font-headline-medium":"48px","--font-headline-small":"36px","--font-title-medium":"24px","--font-title-small":"20px","--font-body":"16px","--font-body-small":"14px","--font-body-extra-small":"12px","--font-title-large":"var(--font-headline-small)","--font-label":"var(--font-body-extra-small)"},a={"--jp-black":"#000000","--jp-black-80":"#2c3338","--jp-white":"#ffffff","--jp-white-off":"#f9f9f6","--jp-gray":"#dcdcde","--jp-gray-0":"#F6F7F7","--jp-gray-5":"var(--jp-gray)","--jp-gray-10":"#C3C4C7","--jp-gray-20":"#A7AAAD","--jp-gray-40":"#787C82","--jp-gray-50":"#646970","--jp-gray-60":"#50575E","--jp-gray-70":"#3C434A","--jp-gray-80":"#2C3338","--jp-gray-90":"#1d2327","--jp-gray-off":"#e2e2df","--jp-red-0":"#F7EBEC","--jp-red-5":"#FACFD2","--jp-red-40":"#E65054","--jp-red-50":"#D63638","--jp-red-60":"#B32D2E","--jp-red-70":"#8A2424","--jp-red-80":"#691C1C","--jp-red":"#d63639","--jp-yellow-5":"#F5E6B3","--jp-yellow-10":"#F2CF75","--jp-yellow-20":"#F0C930","--jp-yellow-30":"#DEB100","--jp-yellow-40":"#C08C00","--jp-yellow-50":"#9D6E00","--jp-yellow-60":"#7D5600","--jp-blue-20":"#68B3E8","--jp-blue-40":"#1689DB","--jp-pink":"#C9356E","--jp-green-0":"#f0f2eb","--jp-green-5":"#d0e6b8","--jp-green-10":"#9dd977","--jp-green-20":"#64ca43","--jp-green-30":"#2fb41f","--jp-green-40":"#069e08","--jp-green-50":"#008710","--jp-green-60":"#007117","--jp-green-70":"#005b18","--jp-green-80":"#004515","--jp-green-90":"#003010","--jp-green-100":"#001c09","--jp-green":"#069e08","--jp-green-primary":"var( --jp-green-40 )","--jp-green-secondary":"var( --jp-green-30 )"},c={"--jp-border-radius":"4px","--jp-menu-border-height":"1px","--jp-underline-thickness":"2px"},l={"--spacing-base":"8px"},u={},d=(e,t,r)=>{const n={...i,...a,...c,...l};for(const t in n)e.style.setProperty(t,n[t]);r&&e.classList.add(s.A.global),t&&(u[t]={provided:!0,root:e})},p=({children:e=null,targetDom:t,id:r,withGlobalStyles:s=!0})=>{const i=(0,n.useRef)(),a=u?.[r]?.provided;return(0,n.useLayoutEffect)(()=>{if(!a)return t?d(t,r,s):void(i?.current&&d(i.current,r,s))},[t,i,a,r,s]),t?(0,o.jsx)(o.Fragment,{children:e}):(0,o.jsx)("div",{ref:i,children:e})}},3924(e,t,r){"use strict";function n(e,t={}){const r={};let n;if("undefined"!=typeof window&&(n=window?.JP_CONNECTION_INITIAL_STATE?.calypsoEnv),0===e.search("https://")){const t=new URL(e);e=`https://${t.host}${t.pathname}`,r.url=encodeURIComponent(e)}else r.source=encodeURIComponent(e);for(const e in t)r[e]=encodeURIComponent(t[e]);!Object.keys(r).includes("site")&&"undefined"!=typeof jetpack_redirects&&Object.hasOwn(jetpack_redirects,"currentSiteRawUrl")&&(r.site=jetpack_redirects.currentBlogID??jetpack_redirects.currentSiteRawUrl),n&&(r.calypso_env=n);return"https://jetpack.com/redirect/?"+Object.keys(r).map(e=>e+"="+r[e]).join("&")}r.d(t,{A:()=>n})},56439(e,t,r){let n={};try{n=r(74277)}catch{console.error("jetpackConfig is missing in your webpack config file. See @automattic/jetpack-config"),n={missingConfig:!0}}const s=e=>Object.hasOwn(n,e);e.exports={jetpackConfigHas:s,jetpackConfigGet:e=>{if(!s(e))throw'This app requires the "'+e+'" Jetpack Config to be defined in your webpack configuration file. See details in @automattic/jetpack-config package docs.';return n[e]}}},14882(e,t,r){"use strict";r.d(t,{A:()=>l});var n=r(5932),s=r(97999),o=r(47143),i=r(51609),a=r(34293);const c=window?.JP_CONNECTION_INITIAL_STATE||(0,s.getScriptData)()?.connection||{};function l({registrationNonce:e=c.registrationNonce,apiRoot:t=c.apiRoot,apiNonce:r=c.apiNonce,redirectUri:s,autoTrigger:l,from:u,skipUserConnection:d,skipPricingPage:p}={}){const{registerSite:h,connectUser:m,refreshConnectedPlugins:g}=(0,o.useDispatch)(a.a),f=(0,o.useSelect)(e=>e(a.a).getRegistrationError(),[]),{siteIsRegistering:b,userIsConnecting:v,userConnectionData:y,connectedPlugins:k,connectionErrors:_,isRegistered:x,isUserConnected:w,hasConnectedOwner:j,isOfflineMode:A}=(0,o.useSelect)(e=>{const t=e(a.a).getConnectionStatus();return{siteIsRegistering:e(a.a).getSiteIsRegistering(),userIsConnecting:e(a.a).getUserIsConnecting(),userConnectionData:e(a.a).getUserConnectionData()||{},connectedPlugins:e(a.a).getConnectedPlugins(),connectionErrors:e(a.a).getConnectionErrors(),isOfflineMode:e(a.a).getIsOfflineMode(),isRegistered:t.isRegistered??!1,isUserConnected:t.isUserConnected??!1,hasConnectedOwner:t.hasConnectedOwner??!1}},[]),C=()=>d?s?(window.location.href=s,Promise.resolve(s)):Promise.resolve():m({from:u,redirectUri:s,skipPricingPage:p}),S=t=>(t&&t.preventDefault(),x?C():h({registrationNonce:e,redirectUri:s,from:u}).then(()=>C()));return(0,i.useEffect)(()=>{n.Ay.setApiRoot(t),n.Ay.setApiNonce(r)},[t,r]),(0,i.useEffect)(()=>{!l||b||v||S()},[]),{handleRegisterSite:S,handleConnectUser:C,refreshConnectedPlugins:g,isRegistered:x,isUserConnected:w,siteIsRegistering:b,userIsConnecting:v,registrationError:f,userConnectionData:y,hasConnectedOwner:j,connectedPlugins:k,connectionErrors:_,isOfflineMode:A}}},33935(e,t,r){"use strict";r.d(t,{A1:()=>c,Ay:()=>x,DO:()=>a,Ij:()=>i,Kl:()=>h,LW:()=>l,MU:()=>m,XY:()=>u,ZO:()=>o,dz:()=>d,gH:()=>p,v_:()=>s});var n=r(5932);const s="SET_CONNECTION_STATUS",o="SET_CONNECTION_STATUS_IS_FETCHING",i="SET_SITE_IS_REGISTERING",a="SET_USER_IS_CONNECTING",c="SET_REGISTRATION_ERROR",l="CLEAR_REGISTRATION_ERROR",u="SET_AUTHORIZATION_URL",d="DISCONNECT_USER_SUCCESS",p="SET_CONNECTED_PLUGINS",h="SET_CONNECTION_ERRORS",m="SET_IS_OFFLINE_MODE",g=e=>({type:s,connectionStatus:e}),f=e=>({type:i,isRegistering:e}),b=e=>({type:a,isConnecting:e}),v=e=>({type:c,registrationError:e}),y=()=>({type:l}),k=e=>({type:u,authorizationUrl:e}),_=e=>({type:p,connectedPlugins:e});const x={setConnectionStatus:g,setConnectionStatusIsFetching:e=>({type:o,isFetching:e}),fetchConnectionStatus:()=>({type:"FETCH_CONNECTION_STATUS"}),fetchAuthorizationUrl:e=>({type:"FETCH_AUTHORIZATION_URL",redirectUri:e}),setSiteIsRegistering:f,setUserIsConnecting:b,setRegistrationError:v,clearRegistrationError:y,setAuthorizationUrl:k,registerSite:function*({registrationNonce:e,redirectUri:t,from:r=""}){yield y(),yield f(!0);try{const n=yield{type:"REGISTER_SITE",registrationNonce:e,redirectUri:t,from:r};return yield g({isRegistered:!0}),yield k(n.authorizeUrl),yield f(!1),Promise.resolve(n)}catch(e){return yield v(e),yield f(!1),Promise.reject(e)}},connectUser:function*({from:e,redirectFunc:t,redirectUri:r,skipPricingPage:n}={}){yield b(!0),yield{type:"CONNECT_USER",from:e,redirectFunc:t,redirectUri:r,skipPricingPage:n}},disconnectUserSuccess:()=>({type:d}),setConnectedPlugins:_,refreshConnectedPlugins:()=>async({dispatch:e})=>await new Promise(t=>n.Ay.fetchConnectedPlugins().then(r=>{e(_(r)),t(r)})),setConnectionErrors:e=>({type:h,connectionErrors:e}),setIsOfflineMode:e=>({type:m,isOfflineMode:e})}},27938(e,t,r){"use strict";function n(e){return window.location.assign(e)}r.d(t,{d:()=>n})},22494(e,t,r){"use strict";r.d(t,{A:()=>a});var n=r(5932),s=r(47143),o=r(27938),i=r(32279);const a={FETCH_AUTHORIZATION_URL:({redirectUri:e})=>n.Ay.fetchAuthorizationUrl(e),REGISTER_SITE:({redirectUri:e,from:t})=>n.Ay.registerSite(null,e,t),CONNECT_USER:(0,s.createRegistryControl)(({resolveSelect:e})=>({from:t,redirectFunc:r,redirectUri:n,skipPricingPage:s}={})=>new Promise((a,c)=>{e(i.A).getAuthorizationUrl(n).then(e=>{const n=r||(e=>(0,o.d)(e)),i=new URL(e);s&&i.searchParams.set("skip_pricing","true"),t&&i.searchParams.set("from",encodeURIComponent(t));const c=i.toString();n(c),a(c)}).catch(e=>{c(e)})}))}},5051(e,t,r){"use strict";r.d(t,{A:()=>o});var n=r(47143),s=r(33935);const o=(0,n.combineReducers)({connectionStatus:(e={},t)=>{switch(t.type){case s.v_:return{...e,...t.connectionStatus};case s.dz:return{...e,isUserConnected:!1}}return e},connectionStatusIsFetching:(e=!1,t)=>t.type===s.ZO?t.isFetching:e,siteIsRegistering:(e=!1,t)=>t.type===s.Ij?t.isRegistering:e,userIsConnecting:(e=!1,t)=>t.type===s.DO?t.isConnecting:e,registrationError:(e,t)=>{switch(t.type){case s.LW:return!1;case s.A1:return t.registrationError;default:return e}},authorizationUrl:(e,t)=>t.type===s.XY?t.authorizationUrl:e,userConnectionData:(e,t)=>(t.type,e),connectedPlugins:(e={},t)=>t.type===s.gH?t.connectedPlugins:e,connectionErrors:(e={},t)=>t.type===s.Kl?t.connectionErrors:e,isOfflineMode:(e=!1,t)=>t.type===s.MU?t.isConnecting:e})},58019(e,t,r){"use strict";r.d(t,{A:()=>i});var n=r(47143),s=r(33935),o=r(32279);const i={...{getAuthorizationUrl:{isFulfilled:(e,...t)=>{const r=Boolean(e.authorizationUrl),s=(0,n.select)(o.A).hasFinishedResolution("getAuthorizationUrl",t);return r&&!s&&(0,n.dispatch)(o.A).finishResolution("getAuthorizationUrl",t),r},*fulfill(e){const t=yield s.Ay.fetchAuthorizationUrl(e);yield s.Ay.setAuthorizationUrl(t.authorizeUrl)}}}}},52676(e,t,r){"use strict";r.d(t,{A:()=>n});const n={...{getConnectionStatus:e=>e.connectionStatus||{},getConnectionStatusIsFetching:()=>!1,getSiteIsRegistering:e=>e.siteIsRegistering||!1,getUserIsConnecting:e=>e.userIsConnecting||!1,getRegistrationError:e=>e.registrationError||!1,getAuthorizationUrl:e=>e.authorizationUrl||!1,getUserConnectionData:e=>e.userConnectionData||!1,getConnectedPlugins:e=>e.connectedPlugins||[],getConnectionErrors:e=>e.connectionErrors||[],getIsOfflineMode:e=>e.isOfflineMode||!1,getWpcomUser:e=>e?.userConnectionData?.currentUser?.wpcomUser,getBlogId:e=>e?.userConnectionData?.currentUser?.blogId}}},18734(e,t,r){"use strict";r.d(t,{A:()=>o});var n=r(47143);class s{static store=null;static mayBeInit(e,t){null===s.store&&(s.store=(0,n.createReduxStore)(e,t),(0,n.register)(s.store))}}const o=s},32279(e,t,r){"use strict";r.d(t,{A:()=>n});const n="jetpack-connection"},34293(e,t,r){"use strict";r.d(t,{a:()=>u.A});var n=r(97999),s=r(33935),o=r(22494),i=r(5051),a=r(58019),c=r(52676),l=r(18734),u=r(32279);const d=window.JP_CONNECTION_INITIAL_STATE||(0,n.getScriptData)()?.connection;d||console.error("Jetpack Connection package: Initial state is missing. Check documentation to see how to use the Connection composer package to set up the initial state."),l.A.mayBeInit(u.A,{__experimentalUseThunks:!0,reducer:i.A,actions:s.Ay,selectors:c.A,resolvers:a.A,controls:o.A,initialState:d||{}})},63673(e,t,r){"use strict";r.d(t,{FALLBACK_CURRENCY:()=>s,FALLBACK_LOCALE:()=>n});r(38443);const n="en",s="USD"},11452(e,t,r){"use strict";r.d(t,{A:()=>i});var n=r(63673),s=r(49980),o=r(91167);const i=function(){let e,t;const r=()=>{const t="undefined"!=typeof window?window.wp?.date?.getSettings?.()?.l10n?.locale:void 0,r="undefined"!=typeof window?window?.navigator?.language:void 0;return(e??(t||r)??n.FALLBACK_LOCALE).split("_")[0]};return{setLocale:t=>{e=t},setGeoLocation:e=>{t=e},formatNumber:(e,{decimals:t=0,forceLatin:n=!0,numberFormatOptions:s={}}={})=>{try{return(0,o.j)({browserSafeLocale:r(),decimals:t,forceLatin:n,numberFormatOptions:s}).format(e)}catch{return String(e)}},formatNumberCompact:(e,{decimals:t=0,forceLatin:n=!0,numberFormatOptions:s={}}={})=>{try{return(0,o.c)({browserSafeLocale:r(),decimals:t,forceLatin:n,numberFormatOptions:s}).format(e)}catch{return String(e)}},formatCurrency:(e,n,{stripZeros:o=!1,isSmallestUnit:i=!1,signForPositive:a=!1,forceLatin:c=!0}={})=>(0,s.u)({number:e,currency:n,browserSafeLocale:r(),stripZeros:o,isSmallestUnit:i,signForPositive:a,geoLocation:t,forceLatin:c}),getCurrencyObject:(e,n,{stripZeros:o=!1,isSmallestUnit:i=!1,signForPositive:a=!1,forceLatin:c=!0}={})=>(0,s.v)({number:e,currency:n,browserSafeLocale:r(),stripZeros:o,isSmallestUnit:i,signForPositive:a,geoLocation:t,forceLatin:c})}}},3328(e,t,r){"use strict";r.d(t,{J:()=>c});var n=r(10067),s=r.n(n),o=r(63673);const i=s()("number-formatters:get-cached-formatter"),a=new Map;function c({locale:e,fallbackLocale:t=o.FALLBACK_LOCALE,options:r,retries:n=1}){const s=JSON.stringify([e,r]);try{return a.get(s)??a.set(s,new Intl.NumberFormat(e,r)).get(s)}catch(s){if(i(`Intl.NumberFormat was called with a non-existent locale "${e}"; falling back to ${t}`),n)return c({locale:t,options:r,retries:n-1});throw s}}},54268(e,t,r){"use strict";r.d(t,{vv:()=>c});const n=(0,r(11452).A)(),{setLocale:s,setGeoLocation:o,formatNumber:i,formatNumberCompact:a,formatCurrency:c,getCurrencyObject:l}=n},76673(e,t,r){"use strict";r.d(t,{a:()=>n});const n={AED:{symbol:"د.إ.‏"},AFN:{symbol:"؋"},ALL:{symbol:"Lek"},AMD:{symbol:"֏"},ANG:{symbol:"ƒ"},AOA:{symbol:"Kz"},ARS:{symbol:"$"},AUD:{symbol:"A$"},AWG:{symbol:"ƒ"},AZN:{symbol:"₼"},BAM:{symbol:"КМ"},BBD:{symbol:"Bds$"},BDT:{symbol:"৳"},BGN:{symbol:"лв."},BHD:{symbol:"د.ب.‏"},BIF:{symbol:"FBu"},BMD:{symbol:"$"},BND:{symbol:"$"},BOB:{symbol:"Bs"},BRL:{symbol:"R$"},BSD:{symbol:"$"},BTC:{symbol:"Ƀ"},BTN:{symbol:"Nu."},BWP:{symbol:"P"},BYR:{symbol:"р."},BZD:{symbol:"BZ$"},CAD:{symbol:"C$"},CDF:{symbol:"FC"},CHF:{symbol:"CHF"},CLP:{symbol:"$"},CNY:{symbol:"¥"},COP:{symbol:"$"},CRC:{symbol:"₡"},CUC:{symbol:"CUC"},CUP:{symbol:"$MN"},CVE:{symbol:"$"},CZK:{symbol:"Kč"},DJF:{symbol:"Fdj"},DKK:{symbol:"kr."},DOP:{symbol:"RD$"},DZD:{symbol:"د.ج.‏"},EGP:{symbol:"ج.م.‏"},ERN:{symbol:"Nfk"},ETB:{symbol:"ETB"},EUR:{symbol:"€"},FJD:{symbol:"FJ$"},FKP:{symbol:"£"},GBP:{symbol:"£"},GEL:{symbol:"Lari"},GHS:{symbol:"₵"},GIP:{symbol:"£"},GMD:{symbol:"D"},GNF:{symbol:"FG"},GTQ:{symbol:"Q"},GYD:{symbol:"G$"},HKD:{symbol:"HK$"},HNL:{symbol:"L."},HRK:{symbol:"kn"},HTG:{symbol:"G"},HUF:{symbol:"Ft"},IDR:{symbol:"Rp"},ILS:{symbol:"₪"},INR:{symbol:"₹"},IQD:{symbol:"د.ع.‏"},IRR:{symbol:"﷼"},ISK:{symbol:"kr."},JMD:{symbol:"J$"},JOD:{symbol:"د.ا.‏"},JPY:{symbol:"¥"},KES:{symbol:"S"},KGS:{symbol:"сом"},KHR:{symbol:"៛"},KMF:{symbol:"CF"},KPW:{symbol:"₩"},KRW:{symbol:"₩"},KWD:{symbol:"د.ك.‏"},KYD:{symbol:"$"},KZT:{symbol:"₸"},LAK:{symbol:"₭"},LBP:{symbol:"ل.ل.‏"},LKR:{symbol:"₨"},LRD:{symbol:"L$"},LSL:{symbol:"M"},LYD:{symbol:"د.ل.‏"},MAD:{symbol:"د.م.‏"},MDL:{symbol:"lei"},MGA:{symbol:"Ar"},MKD:{symbol:"ден."},MMK:{symbol:"K"},MNT:{symbol:"₮"},MOP:{symbol:"MOP$"},MRO:{symbol:"UM"},MTL:{symbol:"₤"},MUR:{symbol:"₨"},MVR:{symbol:"MVR"},MWK:{symbol:"MK"},MXN:{symbol:"MX$"},MYR:{symbol:"RM"},MZN:{symbol:"MT"},NAD:{symbol:"N$"},NGN:{symbol:"₦"},NIO:{symbol:"C$"},NOK:{symbol:"kr"},NPR:{symbol:"₨"},NZD:{symbol:"NZ$"},OMR:{symbol:"﷼"},PAB:{symbol:"B/."},PEN:{symbol:"S/."},PGK:{symbol:"K"},PHP:{symbol:"₱"},PKR:{symbol:"₨"},PLN:{symbol:"zł"},PYG:{symbol:"₲"},QAR:{symbol:"﷼"},RON:{symbol:"lei"},RSD:{symbol:"Дин."},RUB:{symbol:"₽"},RWF:{symbol:"RWF"},SAR:{symbol:"﷼"},SBD:{symbol:"S$"},SCR:{symbol:"₨"},SDD:{symbol:"LSd"},SDG:{symbol:"£‏"},SEK:{symbol:"kr"},SGD:{symbol:"S$"},SHP:{symbol:"£"},SLL:{symbol:"Le"},SOS:{symbol:"S"},SRD:{symbol:"$"},STD:{symbol:"Db"},SVC:{symbol:"₡"},SYP:{symbol:"£"},SZL:{symbol:"E"},THB:{symbol:"฿"},TJS:{symbol:"TJS"},TMT:{symbol:"m"},TND:{symbol:"د.ت.‏"},TOP:{symbol:"T$"},TRY:{symbol:"TL"},TTD:{symbol:"TT$"},TVD:{symbol:"$T"},TWD:{symbol:"NT$"},TZS:{symbol:"TSh"},UAH:{symbol:"₴"},UGX:{symbol:"USh"},USD:{},UYU:{symbol:"$U"},UZS:{symbol:"сўм"},VEB:{symbol:"Bs."},VEF:{symbol:"Bs. F."},VND:{symbol:"₫"},VUV:{symbol:"VT"},WST:{symbol:"WS$"},XAF:{symbol:"F"},XCD:{symbol:"$"},XOF:{symbol:"F"},XPF:{symbol:"F"},YER:{symbol:"﷼"},ZAR:{symbol:"R"},ZMW:{symbol:"ZK"},WON:{symbol:"₩"}}},49980(e,t,r){"use strict";r.d(t,{u:()=>g,v:()=>f});var n=r(10067),s=r.n(n),o=r(63673),i=r(3328),a=r(76673);const c=s()("number-formatters:number-format-currency");function l(e,t){return"USD"===e&&t&&""!==t&&"US"!==t?{symbol:"US$"}:a.a[e]}function u(e,t){return l(e,t)?e:(c(`getValidCurrency was called with a non-existent currency "${e}"; falling back to ${o.FALLBACK_CURRENCY}`),o.FALLBACK_CURRENCY)}function d({number:e,currency:t,browserSafeLocale:r,forceLatin:n=!0,stripZeros:s,signForPositive:o}){const a=`${r}${n?"-u-nu-latn":""}`,c={style:"currency",currency:t,...s&&Number.isInteger(e)&&{maximumFractionDigits:0,minimumFractionDigits:0},...o&&{signDisplay:"exceptZero"}};return(0,i.J)({locale:a,options:c})}function p(e,t,r){return d({number:0,currency:t,browserSafeLocale:e,forceLatin:r}).resolvedOptions().maximumFractionDigits}function h(e,t){const r=Math.pow(10,t);return Math.round(e*r)/r}function m(e,t,r){if(isNaN(e))return c("formatCurrency was called with NaN"),0;if(r){Number.isInteger(e)||c("formatCurrency was called with isSmallestUnit and a float which will be rounded",e);const r=10**t;return h(Math.round(e)/r,t)}return h(e,t)}const g=({number:e,browserSafeLocale:t,currency:r,stripZeros:n,isSmallestUnit:s,signForPositive:o,geoLocation:i,forceLatin:a})=>{const c=u(r,i),h=l(c,i),g=p(t,c,a);if(s&&void 0===g)throw new Error(`Could not determine currency precision for ${c} in ${t}`);const f=m(e,g??0,s);return d({number:f,currency:c,browserSafeLocale:t,forceLatin:a,stripZeros:n,signForPositive:o}).formatToParts(f).reduce((e,t)=>"currency"===t.type&&h?.symbol?e+h.symbol:e+t.value,"")},f=({number:e,browserSafeLocale:t,currency:r,stripZeros:n,isSmallestUnit:s,signForPositive:o,geoLocation:i,forceLatin:a})=>{const c=u(r,i),h=l(c,i),g=m(e,p(t,c,a)??0,s),f=d({number:g,currency:c,browserSafeLocale:t,forceLatin:a,stripZeros:n,signForPositive:o}).formatToParts(g);let b="",v="$",y="before",k=!1,_=!1,x="",w="";f.forEach(e=>{switch(e.type){case"currency":return v=h?.symbol??e.value,void(k&&(y="after"));case"group":case"integer":return x+=e.value,void(k=!0);case"decimal":case"fraction":return w+=e.value,k=!0,void(_=!0);case"minusSign":return void(b="-");case"plusSign":b="+"}});const j=!Number.isInteger(g)&&_;return{sign:b,symbol:v,symbolPosition:y,integer:x,fraction:w,hasNonZeroFraction:j,floatValue:g}}},91167(e,t,r){"use strict";r.d(t,{c:()=>o,j:()=>s});var n=r(3328);const s=({browserSafeLocale:e,decimals:t=0,forceLatin:r=!0,numberFormatOptions:s={}})=>{const o=`${e}${r?"-u-nu-latn":""}`,i={minimumFractionDigits:t,maximumFractionDigits:t,...s};return(0,n.J)({locale:o,options:i})},o=({numberFormatOptions:e={},...t})=>s({...t,numberFormatOptions:{notation:"compact",maximumFractionDigits:1,...e}})},85985(e,t,r){"use strict";r.d(t,{$i:()=>n.A,BT:()=>a.A,Bd:()=>p.Bd,CP:()=>b.C,Cq:()=>m.C,Dk:()=>c.Dk,FB:()=>i.A,GE:()=>s.A,GT:()=>c.GT,M_:()=>g.M,Mm:()=>f.A,Ti:()=>p.Ti,W4:()=>c.W4,ZR:()=>d.A,_6:()=>v.A,_X:()=>p._X,aq:()=>c.aq,ds:()=>p.ds,gB:()=>l.A,pP:()=>o.p,q7:()=>h.A,sH:()=>c.sH,sh:()=>m.s,st:()=>u.A,tu:()=>c.tu,xI:()=>b.x});var n=r(34972),s=r(54815),o=(r(41409),r(62634)),i=r(8573),a=(r(82034),r(65595)),c=r(53265),l=r(49354),u=r(73489),d=r(89581),p=r(20710),h=(r(58406),r(76923)),m=r(30335),g=r(88290),f=r(44360),b=r(9061),v=r(25929);r(5765)},5765(e,t,r){"use strict";r(98490)},82201(e,t,r){"use strict";r.d(t,{cb:()=>n.c});r(15877);var n=r(30984);r(82308)},15877(e,t,r){"use strict";r(97999),r(27723),r(68071),r(10790)},30984(e,t,r){"use strict";r.d(t,{c:()=>a});var n=r(56427),s=r(27723),o=r(13022),i=(r(15016),r(10790));const __=s.__,a=({className:e,description:t,align:r=null,title:s=null,buttonText:a=null,visible:c=!0,context:l=null,checkoutUrl:u=null,goToCheckoutPage:d=null,isRedirecting:p=!1,showButton:h=!0,target:m="_top"})=>{const g=(0,o.A)(e,"jetpack-upgrade-plan-banner",{"wp-block":"editor-canvas"===l,"block-editor-block-list__block":"editor-canvas"===l,"jetpack-upgrade-plan__hidden":!c}),f=__("Redirecting…","jetpack");return(0,i.jsx)("div",{className:g,"data-align":r,children:(0,i.jsxs)("div",{className:"jetpack-upgrade-plan-banner__wrapper",children:[s&&(0,i.jsx)("strong",{className:(0,o.A)("banner-title",{[`${e}__title`]:e}),children:s}),t&&(0,i.jsx)("span",{className:`${e}__description banner-description`,children:t}),h&&(0,i.jsx)(n.Button,{href:p?null:u,onClick:d,target:m,className:(0,o.A)("is-primary",{"jetpack-upgrade-plan__hidden":!u}),isBusy:p,children:(0,i.jsx)("span",{children:p?f:a})})]})})}},82308(e,t,r){"use strict";r(56427),r(47143),r(51609),r(10790)},30335(e,t,r){"use strict";r.d(t,{C:()=>o,s:()=>s});var n=r(86087);function s(e){const t={};let r="span",s=e.icon;const o=document.createElement("div");o.innerHTML=e.icon;const i=o.querySelector("svg");return i&&(r="svg",s=i.innerHTML,Array.from(i.attributes).forEach(({nodeName:e,nodeValue:r})=>t[e]=r)),(0,n.createElement)(r,{...t,dangerouslySetInnerHTML:{__html:s||""}})}function o(e){return{src:s(e)}}},34972(e,t,r){"use strict";r.d(t,{A:()=>n});function n(){return"object"==typeof window?window?.Jetpack_Editor_Initial_State??null:null}},8573(e,t,r){"use strict";r.d(t,{A:()=>s});var n=r(34972);function s(e){const t=(0,n.A)(),r=t?.available_blocks?.[e]?.available??!1,s=t?.available_blocks?.[e]?.unavailable_reason??"unknown";return{available:r,...!r&&{details:t?.available_blocks?.[e]?.details??{},unavailableReason:s}}}},54815(e,t,r){"use strict";r.d(t,{A:()=>s});var n=r(97999);function s(){return window&&window.Jetpack_Editor_Initial_State&&window.Jetpack_Editor_Initial_State.siteFragment?window.Jetpack_Editor_Initial_State.siteFragment:(0,n.getScriptData)()?.site?.suffix??null}},73489(e,t,r){"use strict";r.d(t,{A:()=>c});var n=r(90372),s=r(14882),o=r(86087);const{tracks:i}=n.A,{recordEvent:a}=i,c=({pageViewEventName:e=null,pageViewNamespace:t="jetpack",pageViewSuffix:r="page_view",pageViewEventProperties:c={}}={})=>{const[l,u]=(0,o.useState)(!1),{isUserConnected:d,isRegistered:p,userConnectionData:h={}}=(0,s.A)(),{wpcomUser:{login:m,ID:g}={},blogId:f}=h.currentUser||{},b=(0,o.useCallback)(async(e,t={})=>{d&&g&&m&&a(e,t)},[d,g,m]);return(0,o.useEffect)(()=>{d&&g&&m&&f&&n.A.initialize(g,m,{blog_id:f})},[f,g,m,d]),(0,o.useEffect)(()=>{const n=e?`${t}_${e}_${r}`:null;p&&n&&(l||(b(n,c),u(!0)))},[l,t,e,r,p,c,b]),{recordEvent:b,tracks:i}}},89581(e,t,r){"use strict";r.d(t,{A:()=>i});var n=r(47143),s=r(86087);const o=()=>{};function i(e=null,t=o){const[r,i]=(0,s.useState)(!1),{isAutosaveablePost:a,isDirtyPost:c,currentPost:l}=(0,n.useSelect)(e=>{const t=e("core/editor");return{isAutosaveablePost:t.isEditedPostAutosaveable(),isDirtyPost:t.isEditedPostDirty(),currentPost:t.getCurrentPost()}},[]),u=Object.keys(l).length>0,d=(0,n.useSelect)(e=>!!window.wp?.customize||!!e("core/edit-widgets")),p=(0,n.dispatch)("core/editor").savePost,h=(0,n.useSelect)(e=>e("core").__experimentalGetDirtyEntityRecords()),m=async e=>{e?.preventDefault(),u?c&&a&&await p(e):await(async()=>{for(let e=0;e{n?.preventDefault(),r||(i(!0),m(n).then(()=>{e&&function(e,t,r=!1){t&&t(e),r?window.open(e,"_blank"):window.top.location.href=e}(e,t,d)}))},isRedirecting:r}}},76923(e,t,r){"use strict";r.d(t,{A:()=>i});var n=r(47143),s=r(86087),o=r(88290);const i=e=>{const{isModuleActive:t,isChangingStatus:r,isLoadingModules:i}=(0,n.useSelect)(t=>{const r=t(o.F);return{isModuleActive:r.isModuleActive(e),isChangingStatus:r.isModuleUpdating(e),isLoadingModules:r.areModulesLoading(e)}},[e]),{updateJetpackModuleStatus:a}=(0,n.useDispatch)(o.F),c=(0,s.useCallback)(t=>a({name:e,active:t}),[e,a]);return(0,s.useMemo)(()=>({isLoadingModules:i,isChangingStatus:r,isModuleActive:t,changeStatus:c}),[i,r,t,c])}},20710(e,t,r){"use strict";r.d(t,{Bd:()=>i,Ti:()=>o,_X:()=>n,ds:()=>s});const n="free",s="tiered",o="unlimited",i=e=>e?0===e?.value?n:1===e?.value?o:s:null},58406(e,t,r){"use strict";r(86087)},25929(e,t,r){"use strict";r.d(t,{A:()=>l});var n=r(47143),s=r(52619),o=r(53265),i=r(89581);const a=()=>{},c="a8c.wpcom-block-editor.openCheckoutModal";function l(e,t=a){const{checkoutUrl:r,planData:l}=(0,n.useSelect)(t=>{const r=t("core/editor"),n=t("wordpress-com/plans"),{id:s,type:i}=r.getCurrentPost(),a=n&&n.getPlan(e);return{checkoutUrl:(0,o.Q4)({plan:a,planSlug:e,postId:s,postType:i}),planData:a}},[e]),{autosave:u,autosaveAndRedirect:d,isRedirecting:p}=(0,i.A)(r,t);return[r,async e=>{if(e.preventDefault(),(0,s.hasAction)(c))return e.preventDefault(),u(e),void(0,s.doAction)(c,{products:[l]});d(e)},p,l]}},62410(e,t,r){"use strict";r.d(t,{KZ:()=>p,M4:()=>u,QB:()=>d,T3:()=>l,ik:()=>m,oW:()=>g,ud:()=>h,ux:()=>c});var n=r(38377),s=r(56427),o=r(13022),i=(r(1103),r(10790));const a=n.T["Jetpack Green 40"],c=({size:e=24,border:t=0,className:r="",color:n=a})=>{const c=t?-t/e*32:0;return(0,i.jsxs)(s.SVG,{className:(0,o.A)("jetpack-logo",r),width:e,height:e,viewBox:`${c} ${c} ${32-2*c} ${32-2*c}`,children:[(0,i.jsx)(s.Path,{className:"jetpack-logo__icon-circle",fill:n,stroke:t?"#fff":"transparent",strokeWidth:t,d:"M16,0C7.2,0,0,7.2,0,16s7.2,16,16,16s16-7.2,16-16S24.8,0,16,0z"}),(0,i.jsx)(s.Polygon,{className:"jetpack-logo__icon-triangle",fill:"#fff",points:`15,19 ${7-.5*c},19 15,${3-c}`}),(0,i.jsx)(s.Polygon,{className:"jetpack-logo__icon-triangle",fill:"#fff",points:`17,${29+c} 17,13 ${25+.5*c},13`})]})},l={src:(0,i.jsx)(s.SVG,{viewBox:"0 0 100 100",children:(0,i.jsx)(s.Path,{d:"M100,44H72.4l23.9-13.8l-6-10.4L66.4,33.6L80.2,9.7l-10.4-6L56,27.59V0H44v27.6L30.2,3.7l-10.4,6l13.8,23.9 L9.7,19.8l-6,10.4L27.6,44H0V56h27.6L3.7,69.8l6,10.4l23.9-13.8L19.8,90.3l10.4,6L44,72.4V100H56V72.41l13.8,23.9l10.4-6L66.4,66.4 l23.9,13.8l6-10.4L72.4,56H100V44z M50,65.23c-8.41,0-15.23-6.82-15.23-15.23c0-8.41,6.82-15.23,15.23-15.23S65.23,41.59,65.23,50 C65.23,58.41,58.41,65.23,50,65.23z"})})},u={src:(0,i.jsx)(s.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20.7 17",xmlSpace:"preserve",children:(0,i.jsx)(s.Path,{d:"m20.7 12.9-.9-11c0-.5-.2-.9-.5-1.3-.3-.3-.8-.5-1.3-.5L1.9 0h-.1c-.2 0-.5 0-.7.1C.9.2.7.4.5.5.4.7.2.9.1 1.1c-.1.2-.1.5-.1.7v.1l.9 13.4c0 .5.2.9.5 1.3.3.2.8.4 1.3.4H3l16.1-2c.4 0 .9-.3 1.1-.6.3-.3.5-.8.5-1.2v-.3zm-3.1.8L4.2 15.3H4c-.4 0-.8-.1-1-.4-.3-.3-.4-.6-.5-1L1.7 3.2v-.1c0-.4.2-.8.5-1 .3-.3.7-.4 1-.4h.1l13.5.1c.4 0 .8.1 1 .4.3.3.4.6.5 1L19 12v.3c0 .4-.2.7-.4 1-.3.2-.6.4-1 .4z"})})},d={src:(0,i.jsx)(s.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 43 43",xmlSpace:"preserve",children:(0,i.jsx)(s.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M12 31.908c0 1.376.893 2.268 2.27 2.268h6.63c3.956 0 7.192-1.337 9.392-3.68H12v1.412zM20.901 9H14.27C12.893 9 12 9.893 12 11.269v1.411h18.294C28.093 10.338 24.857 9 20.9 9zm5.787 16.176c0 1.113.726 1.835 1.845 1.835h3.973c.45-1.117.753-2.345.894-3.671h-4.867c-1.119 0-1.845.722-1.845 1.836zm-5.507-7.166c0 1.113.725 1.836 1.844 1.836H33.4a13.644 13.644 0 0 0-.894-3.672h-9.481c-1.119 0-1.844.723-1.844 1.836zm1.843 7.166c0-1.114-.726-1.836-1.845-1.836H12v3.671h9.18c1.118 0 1.843-.722 1.843-1.835zm-5.508-7.166c0-1.113-.726-1.836-1.844-1.836H12v3.672h3.672c1.118 0 1.844-.723 1.844-1.836zm41.151 3.199"})})},p=(s.SVG,s.Rect,s.G,s.Path,s.SVG,s.Rect,s.G,s.Path,s.SVG,s.Rect,s.G,s.Path,s.SVG,s.Rect,s.G,s.Path,s.Path,s.Path,s.SVG,s.Rect,s.G,s.Path,s.Path,s.Path,s.SVG,s.Path,s.SVG,s.Path,s.SVG,s.Path,s.SVG,s.Path,s.Path,(0,i.jsx)(s.SVG,{width:"29",height:"21",viewBox:"0 0 29 21",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,i.jsx)(s.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M2.79037 0.59375C4.0363 0.59375 5.13102 1.41658 5.47215 2.60947L8.8452 14.4044C8.8486 14.4164 8.85411 14.4273 8.86124 14.4368L12.8572 0.59375H15.0927H21.2721C25.6033 0.59375 28.5066 3.39892 28.5066 7.64565C28.5066 11.9411 25.5272 14.6196 21.0818 14.6196H18.1499H14.3719L13.6379 16.8813C12.9796 18.9095 11.0827 20.2839 8.94152 20.2839C6.80035 20.2839 4.90341 18.9095 4.24517 16.8813L0.137069 4.22276C-0.444671 2.43022 0.898038 0.59375 2.79037 0.59375ZM15.7374 10.4119H20.0156C21.8718 10.4119 22.9856 9.35018 22.9856 7.64565C22.9856 5.93137 21.8718 4.91839 20.0156 4.91839H17.5202L15.7374 10.4119Z",fill:"#000000"})})),h=(0,i.jsx)(s.SVG,{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,i.jsx)(s.Path,{d:"M4.75725 2.075C4.60279 1.97745 4.41041 1.97489 4.25365 2.06832C4.09689 2.16174 4 2.3367 4 2.52632V21.4737C4 21.6633 4.09689 21.8383 4.25365 21.9317C4.41041 22.0251 4.60279 22.0226 4.75725 21.925L19.7573 12.4513C19.9079 12.3562 20 12.1849 20 12C20 11.8151 19.9079 11.6438 19.7573 11.5487L4.75725 2.075Z",fill:"white"})}),m=(s.SVG,s.Path,s.SVG,s.Path,s.Path,s.SVG,s.Path,s.SVG,s.Path,(0,i.jsx)(s.SVG,{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,i.jsx)(s.Path,{d:"M20 3H4c-.6 0-1 .4-1 1v16c0 .5.4 1 1 1h8.6v-7h-2.3v-2.7h2.3v-2c0-2.3 1.4-3.6 3.5-3.6 1 0 1.8.1 2.1.1v2.4h-1.4c-1.1 0-1.3.5-1.3 1.3v1.7h2.7l-.4 2.8h-2.3v7H20c.5 0 1-.4 1-1V4c0-.6-.4-1-1-1z"})})),g=(0,i.jsx)(s.SVG,{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,i.jsx)(s.G,{children:(0,i.jsx)(s.Path,{d:"M12 4.622c2.403 0 2.688.01 3.637.052.877.04 1.354.187 1.67.31.42.163.72.358 1.036.673.315.315.51.615.673 1.035.123.317.27.794.31 1.67.043.95.052 1.235.052 3.638s-.01 2.688-.052 3.637c-.04.877-.187 1.354-.31 1.67-.163.42-.358.72-.673 1.036-.315.315-.615.51-1.035.673-.317.123-.794.27-1.67.31-.95.043-1.234.052-3.638.052s-2.688-.01-3.637-.052c-.877-.04-1.354-.187-1.67-.31-.42-.163-.72-.358-1.036-.673-.315-.315-.51-.615-.673-1.035-.123-.317-.27-.794-.31-1.67-.043-.95-.052-1.235-.052-3.638s.01-2.688.052-3.637c.04-.877.187-1.354.31-1.67.163-.42.358-.72.673-1.036.315-.315.615-.51 1.035-.673.317-.123.794-.27 1.67-.31.95-.043 1.235-.052 3.638-.052M12 3c-2.444 0-2.75.01-3.71.054s-1.613.196-2.185.418c-.592.23-1.094.538-1.594 1.04-.5.5-.807 1-1.037 1.593-.223.572-.375 1.226-.42 2.184C3.01 9.25 3 9.555 3 12s.01 2.75.054 3.71.196 1.613.418 2.186c.23.592.538 1.094 1.038 1.594s1.002.808 1.594 1.038c.572.222 1.227.375 2.185.418.96.044 1.266.054 3.71.054s2.75-.01 3.71-.054 1.613-.196 2.186-.418c.592-.23 1.094-.538 1.594-1.038s.808-1.002 1.038-1.594c.222-.572.375-1.227.418-2.185.044-.96.054-1.266.054-3.71s-.01-2.75-.054-3.71-.196-1.613-.418-2.186c-.23-.592-.538-1.094-1.038-1.594s-1.002-.808-1.594-1.038c-.572-.222-1.227-.375-2.185-.418C14.75 3.01 14.445 3 12 3zm0 4.378c-2.552 0-4.622 2.07-4.622 4.622s2.07 4.622 4.622 4.622 4.622-2.07 4.622-4.622S14.552 7.378 12 7.378zM12 15c-1.657 0-3-1.343-3-3s1.343-3 3-3 3 1.343 3 3-1.343 3-3 3zm4.804-8.884c-.596 0-1.08.484-1.08 1.08s.484 1.08 1.08 1.08c.596 0 1.08-.484 1.08-1.08s-.483-1.08-1.08-1.08z"})})})},49354(e,t,r){"use strict";r.d(t,{A:()=>s});var n=r(34972);function s(){return!(!(0,n.A)()?.jetpack?.is_current_user_connected&&!window?.JP_CONNECTION_INITIAL_STATE?.connectionStatus?.isUserConnected)}},44360(e,t,r){"use strict";r.d(t,{A:()=>s});var n=r(34972);function s(){return!0===(0,n.A)()?.jetpack?.is_my_jetpack_available}},9520(e,t,r){"use strict";r.d(t,{C:()=>d,x:()=>u});var n=r(97999),s=r(10067),o=r.n(s);const i=window?.JP_CONNECTION_INITIAL_STATE,a=o()("shared-extension-utils:connection");let c=!1;const l=e=>{c||(a(e),c=!0)};function u(){return(0,n.isSimpleSite)()?(l("Simple site connected ✅"),!0):(0,n.isWoASite)()?(l("Atomic site connected ✅"),!0):i?.connectionStatus?.isUserConnected?(l("Jetpack user is connected ✅"),!0):(l("User is not connected ❌"),!1)}function d(){if((0,n.isSimpleSite)())return!0;return!1==!(i?.userConnectionData?.currentUser?.permissions??{}).manage_options}},9061(e,t,r){"use strict";r.d(t,{C:()=>n.C,x:()=>n.x});var n=r(9520)},27105(e,t,r){"use strict";r.d(t,{Ay:()=>u,E9:()=>l,F6:()=>a});var n=r(97999),s=r(47143),o=r(94478),i=r(88290);function a(e){return l({isLoading:e})}function c(e,t){return{type:"SET_MODULE_UPDATING",name:e,isUpdating:t}}function l(e){return{type:"SET_JETPACK_MODULES",options:e}}const u={updateJetpackModuleStatus:function*(e){try{yield c(e.name,!0),yield(0,o.sB)(e);const t=yield(0,o.wz)();return yield l({data:t}),!0}catch{const e=(0,s.select)(i.F).getJetpackModules();return yield l(e),!1}finally{yield c(e.name,!1)}},setJetpackModules:l,fetchModules:function*(){if((0,n.isSimpleSite)())return!0;try{yield a(!0);const e=yield(0,o.wz)();return yield l({data:e}),!0}catch{const e=(0,s.select)(i.F).getJetpackModules();return yield l(e),!1}finally{yield a(!1)}}}},94478(e,t,r){"use strict";r.d(t,{Ay:()=>l,sB:()=>c,wz:()=>a});var n=r(1455),s=r.n(n);const o="FETCH_JETPACK_MODULES",i="UPDATE_JETPACK_MODULE_STATUS",a=()=>({type:o}),c=e=>({type:i,settings:e}),l={[o]:function(){return s()({path:"/jetpack/v4/module/all",method:"GET"})},[i]:function({settings:e}){return s()({path:`/jetpack/v4/module/${e.name}/active`,method:"POST",data:{active:e.active}})}}},88290(e,t,r){"use strict";r.d(t,{F:()=>l,M:()=>u});var n=r(47143),s=r(27105),o=r(94478),i=r(38862),a=r(62701),c=r(31640);const l="jetpack-modules",u=(0,n.createReduxStore)(l,{reducer:i.A,actions:s.Ay,controls:o.Ay,resolvers:a.A,selectors:c.A});(0,n.register)(u);const d=window?.Initial_State?.getModules||window?.Jetpack_Editor_Initial_State?.modules||null;null!==d&&(0,n.dispatch)(l).setJetpackModules({data:{...d}})},38862(e,t,r){"use strict";r.d(t,{A:()=>s});const n={isLoading:!1,isUpdating:{},data:{}},s=(e=n,t)=>{switch(t.type){case"SET_JETPACK_MODULES":return{...e,...t.options};case"SET_MODULE_UPDATING":return{...e,isUpdating:{...e.isUpdating,[t.name]:t.isUpdating}}}return e}},62701(e,t,r){"use strict";r.d(t,{A:()=>o});var n=r(27105),s=r(94478);const o={getJetpackModules:function*(){try{yield(0,n.F6)(!0);const e=yield(0,s.wz)();if(e)return(0,n.E9)({data:e})}catch(e){console.error(e)}finally{yield(0,n.F6)(!1)}}}},31640(e,t,r){"use strict";r.d(t,{A:()=>s});var n=r(97999);const s={getJetpackModules:e=>e.data,isModuleActive:(e,t)=>(0,n.isSimpleSite)()||(e?.data?.[t]?.activated??!1),areModulesLoading:e=>e.isLoading??!1,isModuleUpdating:(e,t)=>e?.isUpdating?.[t]??!1}},53265(e,t,r){"use strict";r.d(t,{Dk:()=>m,GT:()=>f,Q4:()=>l,W4:()=>u,aq:()=>d,sH:()=>g,tu:()=>p});var n=r(97999),s=r(27723),o=r(93832),i=r(34972),a=r(8573),c=r(54815);const __=s.__;function l({planSlug:e,plan:t,postId:r,postType:s}){const i=e.startsWith("jetpack_")?e:t?.path_slug,a=(void 0===s?()=>{const e=new URLSearchParams(window.location.search);return(0,o.addQueryArgs)(window.location.protocol+`//${(0,c.A)().replace("::","/")}/wp-admin/site-editor.php`,{postId:e.get("postId"),postType:e.get("postType"),plan_upgraded:1})}:()=>{const e=["page","post"].includes(s)?"":"edit";return(0,n.isSimpleSite)()?(0,o.addQueryArgs)("/"+[e,s,(0,c.A)(),r].filter(Boolean).join("/"),{plan_upgraded:1}):(0,o.addQueryArgs)(window.location.protocol+`//${(0,c.A)().replace("::","/")}/wp-admin/post.php`,{action:"edit",post:r,plan_upgraded:1})})();return(0,n.isWoASite)()?(0,o.addQueryArgs)(`https://wordpress.com/plans/${(0,c.A)()}`,{redirect_to:a,customerType:"business"}):i&&(0,o.addQueryArgs)(`https://wordpress.com/checkout/${(0,c.A)()}/${i}`,{redirect_to:a})}function u(e){if(!e)return!1;const t=/^jetpack\//.test(e)?e.substr(8,e.length):e,{available:r,unavailableReason:n}=(0,a.A)(t);return!r&&"missing_plan"===n}function d(e,t){return"missing_plan"===e&&t.required_plan}function p(e){if(!e)return!1;const t=/^jetpack\//.test(e)?e.substr(8,e.length):e,{details:r,unavailableReason:n}=(0,a.A)(t);return d(n,r)}const h=[{name:"core/cover",mediaPlaceholder:!0,mediaReplaceFlow:!0,fileType:"video",description:__("Upgrade your plan to use video covers","jetpack")},{name:"core/audio",mediaPlaceholder:!0,mediaReplaceFlow:!0,fileType:"audio",description:__("Upgrade your plan to upload audio","jetpack")}];function m(){return(0,i.A)()?.jetpack?.enable_upgrade_nudge??!1}const g=e=>h.some(t=>t.name===e),f=e=>h.filter(({name:t})=>t===e)[0]},82034(e,t,r){"use strict";r(92279)},41409(e,t,r){"use strict";r(97999)},62634(e,t,r){"use strict";r.d(t,{p:()=>s});var n=r(34972);function s(){const e=(0,n.A)();return e?.jetpack?.is_private_site??!1}},26047(e,t,r){"use strict";r.d(t,{A:()=>a});var n=r(1455),s=r.n(n),o=r(41325);const i={setPlans:e=>({type:o.PC,plans:e}),fetchFromAPI:e=>({type:o.iH,url:e}),storeAiAssistantFeature:e=>({type:o.UU,feature:e}),fetchAiAssistantFeature:()=>async({dispatch:e})=>{e({type:o.ql});try{const t=await s()({path:o.J8});e(i.storeAiAssistantFeature(function(e){return{hasFeature:!!e["has-feature"],isOverLimit:!!e["is-over-limit"],requestsCount:e["requests-count"],requestsLimit:e["requests-limit"],requireUpgrade:!!e["site-require-upgrade"],errorMessage:e["error-message"],errorCode:e["error-code"],upgradeType:e["upgrade-type"],usagePeriod:{currentStart:e["usage-period"]?.["current-start"],nextStart:e["usage-period"]?.["next-start"],requestsCount:e["usage-period"]?.["requests-count"]||0},currentTier:e["current-tier"],nextTier:e["next-tier"],tierPlansEnabled:!!e["tier-plans-enabled"],costs:e.costs,featuresControl:e["features-control"]}}(t)))}catch(e){console.error(e)}},increaseAiAssistantRequestsCount:(e=1)=>({dispatch:t})=>{t({type:o.Lg,count:e}),t(i.decreaseAsyncRequestCountdownValue())},decreaseAsyncRequestCountdownValue:()=>async({dispatch:e,select:t})=>{e({type:o.yO});t.getAsyncRequestCountdownValue()<=0&&e(i.enqueueAiAssistantFeatureAsyncRequest())},enqueueAiAssistantFeatureAsyncRequest:()=>({dispatch:e})=>{e.dequeueAiAssistantFeatureAsyncRequest();const t=setTimeout(()=>{e(i.fetchAiAssistantFeature())},o.gW);e({type:o.jM,timerId:t})},dequeueAiAssistantFeatureAsyncRequest:()=>({dispatch:e,select:t})=>{e({type:o.js,timerId:0});const r=t.getAsyncRequestCountdownTimerId();r&&window?.clearTimeout(r)},setAiAssistantFeatureRequireUpgrade:(e=!0)=>({type:o.Kt,requireUpgrade:e}),setTierPlansEnabled:(e=!0)=>({type:o.c1,tierPlansEnabled:e})},a=i},41325(e,t,r){"use strict";r.d(t,{GB:()=>d,J8:()=>u,Kt:()=>c,Lg:()=>a,PC:()=>n,UU:()=>o,c1:()=>l,gW:()=>m,iH:()=>s,jM:()=>f,js:()=>b,mx:()=>h,nb:()=>p,ql:()=>i,yO:()=>g});const n="SET_PLANS",s="FETCH_FROM_API",o="STORE_AI_ASSISTANT_FEATURE",i="REQUEST_AI_ASSISTANT_FEATURE",a="INCREASE_AI_ASSISTANT_REQUESTS_COUNT",c="SET_AI_ASSISTANT_FEATURE_REQUIRE_UPGRADE",l="SET_TIER_PLANS_ENABLED",u="/wpcom/v2/jetpack-ai/ai-assistant-feature",d=20,p=3e3,h=3,m=5e3,g="DECREASE_NEW_ASYNC_REQUEST_COUNTDOWN",f="ENQUEUE_ASYNC_COUNTDOWN_REQUEST",b="DEQUEUE_ASYNC_COUNTDOWN_REQUEST"},74960(e,t,r){"use strict";var n=r(47143),s=r(26047),o=r(17740);const i={getPlan:(e,t)=>e.plans.find(e=>e.product_slug===t),getAiAssistantFeature(e){const t={...e.features.aiAssistant};return delete t._meta,t},getIsRequestingAiAssistantFeature:e=>e.features.aiAssistant?._meta?.isRequesting,getAsyncRequestCountdownValue:e=>e.features.aiAssistant?._meta?.asyncRequestCountdown,getAsyncRequestCountdownTimerId:e=>e.features.aiAssistant?._meta?.asyncRequestTimerId},a=(0,n.createReduxStore)("wordpress-com/plans",{actions:s.A,reducer:o.A,selectors:i,controls:{FETCH_FROM_API:({url:e})=>fetch(e).then(e=>e.json())},resolvers:{*getPlan(){const e=yield s.A.fetchFromAPI("https://public-api.wordpress.com/rest/v1.5/plans");return s.A.setPlans(e)},getAiAssistantFeature:e=>{if(!e?.features?.aiAssistant)return s.A.fetchAiAssistantFeature()}}});(0,n.register)(a)},17740(e,t,r){"use strict";r.d(t,{A:()=>o});var n=r(41325);const s={plans:[],features:{aiAssistant:{hasFeature:!0,isOverLimit:!1,requestsCount:0,requestsLimit:n.GB,requireUpgrade:!1,errorMessage:"",errorCode:"",upgradeType:"default",currentTier:{slug:"ai-assistant-tier-free",value:0,limit:20},usagePeriod:{currentStart:"",nextStart:"",requestsCount:0},nextTier:null,tierPlansEnabled:!1,_meta:{isRequesting:!1,asyncRequestCountdown:n.mx,asyncRequestTimerId:0}}}};function o(e=s,t){switch(t.type){case n.PC:return{...e,plans:t.plans};case n.ql:return{...e,features:{...e.features,aiAssistant:{...e.features.aiAssistant,_meta:{...e.features.aiAssistant._meta,isRequesting:!0,asyncRequestCountdown:n.mx,asyncRequestTimerId:0}}}};case n.UU:return{...e,features:{...e.features,aiAssistant:{...t.feature,_meta:{...e.features.aiAssistant._meta,isRequesting:!1}}}};case n.Lg:{const r=e.features.aiAssistant.usagePeriod||{requestsCount:0},s=e.features.aiAssistant.requestsCount+t.count;r.requestsCount+=t.count;const o=e.features.aiAssistant.currentTier?.value,i=void 0===o&&!e.features.aiAssistant.hasFeature||0===o,a=void 0===o&&e.features.aiAssistant.hasFeature||1===o;let c=e.features.aiAssistant.currentTier?.limit;a?c=n.nb:i&&(c=e.features.aiAssistant.requestsLimit);const l=(i?s:e.features.aiAssistant.usagePeriod?.requestsCount)>=c,u=l&&null!==e.features.aiAssistant.nextTier;return{...e,features:{...e.features,aiAssistant:{...e.features.aiAssistant,isOverLimit:l,requestsCount:s,requireUpgrade:u,usagePeriod:{...r}}}}}case n.yO:return{...e,features:{...e.features,aiAssistant:{...e.features.aiAssistant,_meta:{...e.features.aiAssistant._meta,asyncRequestCountdown:e.features.aiAssistant._meta.asyncRequestCountdown-1}}}};case n.jM:return{...e,features:{...e.features,aiAssistant:{...e.features.aiAssistant,_meta:{...e.features.aiAssistant._meta,asyncRequestTimerId:t.timerId}}}};case n.Kt:return{...e,features:{...e.features,aiAssistant:{...e.features.aiAssistant,requireUpgrade:t.requireUpgrade,...t.requireUpgrade?{isOverLimit:!0}:{}}}};case n.c1:return{...e,features:{...e.features,aiAssistant:{...e.features.aiAssistant,tierPlansEnabled:t.tierPlansEnabled}}}}return e}},65595(e,t,r){"use strict";r.d(t,{A:()=>o});var n=r(29491),s=(r(28745),r(10790));const o=e=>(0,n.createHigherOrderComponent)(t=>r=>(0,s.jsx)(t,{...r,className:r.name===e?"has-warning is-interactive":r.className}),"withHasWarningIsInteractiveClassNames")},52068(e,t,r){"use strict";r.d(t,{Ay:()=>x});var n=r(96865),s=r(56427),o=r(47143),i=r(27723),a=r(55565),c=r(73493),l=r(93761),u=r(90437),d=r(80224),p=r(27571),h=r(48499),m=r(2162),g=r(62402),f=(r(34927),r(10790));const __=i.__,b="correct-spelling",v="simplify",y="make-longer",k="make-shorter",_={default:[{name:n.DD,key:b,aiSuggestion:n.yy,icon:d.A}],"core/paragraph":[{name:n.HM,key:v,aiSuggestion:n.A4,icon:u.A},{name:n.JR,key:"summarize",aiSuggestion:n.UA,icon:l.A},{name:n.K2,key:y,aiSuggestion:n.br,icon:c.A},{name:n.UD,key:k,aiSuggestion:n.fD,icon:c.A}],"core/list-item":[{name:n.HM,key:v,aiSuggestion:n.A4,icon:u.A},{name:n.K2,key:y,aiSuggestion:n.br,icon:c.A},{name:n.UD,key:k,aiSuggestion:n.fD,icon:c.A}],"core/list":p.L.includes("core/list")?[{name:n.HM,key:v,aiSuggestion:n.A4,icon:u.A},{name:n.K2,key:y,aiSuggestion:n.br,icon:c.A},{name:n.UD,key:k,aiSuggestion:n.fD,icon:c.A},{name:n.mI,key:"turn-list-into-table",aiSuggestion:n.d5,icon:a.A,options:{alwaysTransformToAIAssistant:!0,rootParentOnly:!0}}]:[{name:n.yQ,key:"write-post-from-list",aiSuggestion:n.pE,icon:u.A,options:{userPrompt:"Write a post based on the list items. Include a title as first order heading and try to use secondary headings for each entry"}}]};function x({blockType:e,clientId:t,disabled:r=!1,onAskAiAssistant:i,onRequestSuggestion:a}){const c=(0,h.C)("ai-correct-spelling"),l=_[e]??[],{getBlockParents:u}=(0,o.select)("core/block-editor"),d=u(t);return(0,f.jsxs)(f.Fragment,{children:[r&&(0,f.jsx)(s.Notice,{status:"warning",isDismissible:!1,className:"jetpack-ai-assistant__info",children:__("Add content to activate the tools below","jetpack")}),(0,f.jsxs)(s.MenuGroup,{children:[(0,f.jsx)(s.MenuItem,{icon:n.cj,iconPosition:"left",onClick:i,disabled:r,children:(0,f.jsx)("div",{className:"jetpack-ai-assistant__menu-item",children:__("Ask AI Assistant","jetpack")})},"key-ai-assistant"),[..._.default,...l].filter(e=>!(e.options?.rootParentOnly&&d.length>0||e.key===b&&!c)).map(e=>(0,f.jsx)(s.MenuItem,{icon:e?.icon,iconPosition:"left",onClick:()=>{a(e.aiSuggestion,{...e.options??{}})},disabled:r,children:(0,f.jsx)("div",{className:"jetpack-ai-assistant__menu-item",children:e.name})},`key-${e.key}`)),(0,f.jsx)(g.hN,{onChange:e=>{a(n.eJ,{tone:e})},disabled:r}),(0,f.jsx)(m.HU,{onChange:e=>{a(n.Gm,{language:e})},disabled:r})]})]})}},32249(e,t,r){"use strict";r.d(t,{A:()=>a});var n=r(3924),s=r(56427),o=r(27723),i=(r(26233),r(10790));const __=o.__;const a=function(){const e=(0,n.A)("jetpack-ai-feedback");return(0,i.jsx)("div",{className:"jetpack-ai-feedback-control",children:(0,i.jsxs)(s.BaseControl,{children:[(0,i.jsx)(s.BaseControl.VisualLabel,{children:__("Feedback","jetpack")}),(0,i.jsx)("p",{children:__("Your feedback is valuable in our commitment to refine and improve this feature.","jetpack")}),(0,i.jsx)(s.ExternalLink,{href:e,children:__("Share your feedback","jetpack")})]})})}},2162(e,t,r){"use strict";r.d(t,{Ay:()=>g,HU:()=>f});var n=r(96865),s=r(85985),o=r(56427),i=r(27723),a=r(13109),c=r(48329),l=r(41490),u=(r(50920),r(10790));const __=i.__,d=["en","es","fr","de","it","pt","ru","zh","ja","ar","hi","ko"],p=window?.Jetpack_Editor_Initial_State?.siteLocale||navigator?.language,h=p?.split("-")[0]||"en",m=(p?.split("-"),({value:e,onChange:t})=>{const r=[...d.filter(e=>e!==h)];return d.includes(h)&&r.unshift(h),(0,u.jsx)(o.MenuGroup,{label:__("Select language","jetpack"),children:r.map(r=>(0,u.jsx)(o.MenuItem,{onClick:()=>t(r+" ("+n.so[r].label+")"),isSelected:e===r,children:n.so[r].label},`key-${r}`))})});function g({value:e=h,label:t=n.u0,onChange:r,disabled:i=!1}){const{tracks:c}=(0,s.st)();return i?(0,u.jsx)(o.Tooltip,{text:t,children:(0,u.jsx)(o.Button,{disabled:!0,children:(0,u.jsx)(a.A,{icon:l.A})})}):(0,u.jsx)(o.ToolbarDropdownMenu,{icon:l.A,label:t,popoverProps:{variant:"toolbar"},onToggle:e=>{e&&c.recordEvent("jetpack_ai_assistant_block_toolbar_menu_show",{tool:"i18n"})},children:()=>(0,u.jsx)(m,{value:e,onChange:r})})}function f({value:e=h,label:t=n.u0,onChange:r,disabled:s=!1}){return(0,u.jsx)(o.DropdownMenu,{className:"ai-assistant__i18n-dropdown",icon:l.A,label:t,toggleProps:{children:(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("div",{className:"ai-assistant__i18n-dropdown__toggle-label",children:t}),(0,u.jsx)(a.A,{icon:c.A})]}),disabled:s},children:({onClose:t})=>(0,u.jsx)(m,{onChange:(...e)=>{r(...e),t()},value:e})})}},99050(e,t,r){"use strict";r.d(t,{Ay:()=>u});var n=r(96865),s=r(85985),o=r(56427),i=r(27723),a=r(33196),c=r(10790);const __=i.__,l=[{name:__("Summarize","jetpack"),key:"summarize",aiSuggestion:n.UA},{name:__("Make longer","jetpack"),key:"make-longer",aiSuggestion:n.br},{name:__("Make shorter","jetpack"),key:"make-shorter",aiSuggestion:n.fD}];function u({key:e,label:t=__("Improve","jetpack"),exclude:r=[],onChange:n,disabled:i=!1}){const{tracks:u}=(0,s.st)();return i?(0,c.jsx)(o.Tooltip,{text:t,children:(0,c.jsx)(o.Button,{disabled:!0,children:(0,c.jsx)(o.Icon,{icon:a.A})})}):(0,c.jsx)(o.ToolbarDropdownMenu,{icon:a.A,label:t,popoverProps:{variant:"toolbar"},onToggle:e=>{e&&u.recordEvent("jetpack_ai_assistant_block_toolbar_menu_show",{tool:"improve"})},children:()=>{const s=l.filter(e=>!r.includes(e.key));return(0,c.jsx)(o.MenuGroup,{label:t,children:s.map(t=>(0,c.jsx)(o.MenuItem,{onClick:()=>n(t.aiSuggestion,{contentType:"generated"}),isSelected:e===t.key,children:t.name},`key-${t.key}`))})}})}},33468(e,t,r){"use strict";r.d(t,{Ay:()=>b});var n=r(96865),s=r(85985),o=r(56427),i=r(27723),a=r(33196),c=r(73493),l=r(93761),u=r(90437),d=r(80224),p=r(55507),h=r(48499),m=r(10790);const __=i.__,g=[{label:__("Post about…","jetpack"),description:{original:"Write a post about ",translated:__("Write a post about","jetpack")+" "}},{label:__("Informative article on…","jetpack"),description:{original:"Craft an informative article explaining ",translated:__("Craft an informative article explaining","jetpack")+" "}},{label:__("Step-by-step tutorial on…","jetpack"),description:{original:"Write a step-by-step tutorial on ",translated:__("Write a step-by-step tutorial on","jetpack")+" "}},{label:__("Motivational post on…","jetpack"),description:{original:"Create a motivational post on ",translated:__("Create a motivational post on","jetpack")+" "}}],f=[{label:__("Say it differently…","jetpack"),description:{original:"Rewrite it in a way that ",translated:__("Rewrite it in a way that","jetpack")+" "}},{label:__("Add…","jetpack"),description:{original:"Add more details about ",translated:__("Add more details about","jetpack")+" "}},{label:__("Remove…","jetpack"),description:{original:"Remove unnecessary details about ",translated:__("Remove unnecessary details about","jetpack")+" "}}];function b({hasContentBefore:e,hasContent:t,hasPostTitle:r,contentIsLoaded:i,onPromptSelect:b,onSuggestionSelect:v}){const y=__("Write with AI…","jetpack"),k=(0,h.C)("ai-correct-spelling"),{tracks:_}=(0,s.st)();return(0,m.jsx)(o.ToolbarDropdownMenu,{className:"jetpack-ai-assistant__templates-control",icon:null,label:y,text:y,onToggle:e=>{e&&_.recordEvent("jetpack_ai_assistant_block_toolbar_menu_show",{tool:"write-with-ai"})},children:({onClose:s})=>i?(0,m.jsx)(o.MenuGroup,{label:__("Write…","jetpack"),children:f.map((e,t)=>(0,m.jsx)(o.MenuItem,{icon:a.A,iconPosition:"left",onClick:()=>{s(),b(e.description)},children:e.label},`key-${t}`))}):(0,m.jsxs)(m.Fragment,{children:[e&&(0,m.jsxs)(o.MenuGroup,{label:__("Based on preceding content…","jetpack"),children:[(0,m.jsx)(o.MenuItem,{icon:c.A,iconPosition:"left",onClick:()=>v(n.sn),children:n.DT}),k&&(0,m.jsx)(o.MenuItem,{icon:d.A,iconPosition:"left",onClick:()=>v(n.yy),children:n.DD}),(0,m.jsx)(o.MenuItem,{icon:u.A,iconPosition:"left",onClick:()=>v(n.A4),children:n.HM})]}),t&&(0,m.jsxs)(o.MenuGroup,{label:__("Based on entire content…","jetpack"),children:[t&&(0,m.jsx)(o.MenuItem,{icon:l.A,iconPosition:"left",onClick:()=>v(n.UA),children:n.JR}),t&&(0,m.jsx)(o.MenuItem,{icon:p.A,iconPosition:"left",onClick:()=>v(n.vE),children:n.mT})]}),(0,m.jsxs)(o.MenuGroup,{label:__("Write…","jetpack"),children:[r&&(0,m.jsx)(o.MenuItem,{icon:a.A,iconPosition:"left",onClick:()=>v(n.im),children:n.Rq}),g.map((e,t)=>(0,m.jsx)(o.MenuItem,{icon:a.A,iconPosition:"left",onClick:()=>{s(),b(e.description)},children:e.label},`key-${t}`))]})]})})}},62402(e,t,r){"use strict";r.d(t,{Ay:()=>h,US:()=>u,hN:()=>p});var n=r(96865),s=r(85985),o=r(56427),i=r(27723),a=r(48329),c=(r(45608),r(10790));const __=i.__,l=["formal","informal","optimistic","humorous","serious","skeptical","empathetic","confident","passionate","provocative"],u="formal",d=({value:e,onChange:t})=>(0,c.jsx)(o.MenuGroup,{label:__("Select tone","jetpack"),children:l.map(r=>(0,c.jsx)(o.MenuItem,{onClick:()=>t(r),isSelected:e===r,children:`${n.oZ[r].emoji} ${n.oZ[r].label}`},`key-${r}`))});function p({label:e=n.uQ,value:t=u,onChange:r,disabled:s=!1}){return(0,c.jsx)(o.DropdownMenu,{icon:n.Qr,label:e,className:"ai-assistant__tone-dropdown",popoverProps:{variant:"toolbar"},toggleProps:{children:(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)("div",{className:"ai-assistant__tone-dropdown__toggle-label",children:e}),(0,c.jsx)(o.Icon,{icon:a.A})]}),disabled:s},children:({onClose:e})=>(0,c.jsx)(d,{value:t,onChange:t=>{r(t),e()}})})}function h({value:e=u,onChange:t,disabled:r=!1}){const{tracks:i}=(0,s.st)();return r?(0,c.jsx)(o.Tooltip,{text:n.uQ,children:(0,c.jsx)(o.Button,{disabled:!0,children:(0,c.jsx)(o.Icon,{icon:n.Qr})})}):(0,c.jsx)(o.ToolbarDropdownMenu,{icon:n.Qr,label:n.uQ,popoverProps:{variant:"toolbar"},onToggle:e=>{e&&i.recordEvent("jetpack_ai_assistant_block_toolbar_menu_show",{tool:"tone"})},children:()=>(0,c.jsx)(d,{value:e,onChange:t})})}},51698(e,t,r){"use strict";r.d(t,{A:()=>m});var n=r(96865),s=r(94715),o=r(56427),i=r(27723),a=r(88901),c=r(60484),l=r(2162),u=r(99050),d=r(33468),p=r(62402),h=r(10790);const __=i.__,m=({contentIsLoaded:e,getSuggestionFromOpenAI:t,retryRequest:r,handleAcceptContent:i,handleTryAgain:m,showRetry:g,contentBefore:f,hasPostTitle:b,wholeContent:v,setUserPrompt:y,recordEvent:k,isGeneratingTitle:_})=>(0,h.jsx)(h.Fragment,{children:(0,h.jsxs)(s.BlockControls,{children:[!g&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.ToolbarGroup,{children:(0,h.jsx)(d.Ay,{hasContentBefore:!!f?.length,hasContent:!!v?.length,hasPostTitle:b,contentIsLoaded:e,onPromptSelect:e=>{k("jetpack_editor_ai_assistant_block_toolbar_button_click",{type:"prompt-template",prompt:e.original}),y(e.translated)},onSuggestionSelect:e=>{k("jetpack_editor_ai_assistant_block_toolbar_button_click",{type:"suggestion",suggestion:e}),t(e)}})}),(0,h.jsxs)(s.BlockControls,{group:"block",children:[(0,h.jsx)(p.Ay,{value:"neutral",onChange:r=>{k("jetpack_editor_ai_assistant_block_toolbar_button_click",{type:"suggestion",suggestion:n.eJ}),t(n.eJ,{tone:r,contentType:e?"generated":null})},disabled:!e&&!v?.length}),(0,h.jsx)(l.Ay,{value:"en",onChange:r=>{k("jetpack_editor_ai_assistant_block_toolbar_button_click",{type:"suggestion",suggestion:n.Gm}),t(n.Gm,{language:r,contentType:e?"generated":null})},disabled:!e&&!v?.length}),(0,h.jsx)(u.Ay,{onChange:t,exclude:_?["summarize"]:[],disabled:!e})]})]}),(g||m)&&(0,h.jsxs)(o.ToolbarGroup,{children:[!g&&e&&m&&(0,h.jsx)(o.ToolbarButton,{onClick:m,children:__("Try Again","jetpack")}),g&&e&&(0,h.jsx)(o.ToolbarButton,{icon:a.A,onClick:i,children:__("Accept","jetpack")}),g&&(0,h.jsx)(o.ToolbarButton,{icon:c.A,onClick:r,children:__("Retry","jetpack")})]})]})})},3586(e,t,r){"use strict";r.d(t,{A:()=>w});var n=r(96865),s=r(85985),o=r(94715),i=r(74997),a=r(56427),c=r(29491),l=r(47143),u=r(86087),d=r(27723),p=r(13022),h=r(27970),m=r(56199),g=r(2274),f=r(32249),b=r(51698),v=r(4393),y=r(44732),k=r(76695),_=(r(47894),r(10790));const __=d.__,x="post"===window?.Jetpack_Editor_Initial_State?.screenBase;function w({attributes:e,setAttributes:t,clientId:r,isSelected:d}){const[w,j]=(0,u.useState)(null),{tracks:A}=(0,s.st)(),{getBlock:C}=(0,l.useSelect)("core/block-editor"),S=(0,u.useRef)(null),E=(0,u.useRef)(null),{replaceBlocks:T,removeBlock:N}=(0,l.useDispatch)("core/block-editor"),{editPost:P}=(0,l.useDispatch)("core/editor"),[R,L]=(0,u.useState)((0,n.MB)(e.preTransformAction)),{isOverLimit:D,requireUpgrade:I,increaseRequestsCount:B,requestsCount:F,requestsLimit:M,currentTier:U,loading:O,tierPlansEnabled:z}=(0,n.yM)(),q=Math.max(M-F,0),{autosaveAndRedirect:$}=(0,n.ON)(),H=(0,s.Bd)(U),V=()=>{setTimeout(()=>{S.current?.focus?.()},100)},G=()=>{setTimeout(()=>{E.current?.focus?.()},100)},W=(0,c.useViewportMatch)("medium","<"),Z=(0,u.useRef)(null),{getSuggestionFromOpenAI:J,stopSuggestion:K,showRetry:Y,contentBefore:Q,postTitle:X,retryRequest:ee,wholeContent:te,requestingState:re,error:ne}=(0,v.A)({onSuggestionDone:(0,u.useCallback)(()=>{V(),B()},[B]),onUnclearPrompt:(0,u.useCallback)(()=>{G(),B()},[B]),onModeration:V,attributes:e,clientId:r,content:e.content,tracks:A,userPrompt:e.userPrompt,requireUpgrade:I,initialRequestingState:e.requestingState,contentRef:Z,blockRef:E}),se="requesting"===re,oe=["requesting","suggesting"].includes(re),ie=(0,s.xI)(),{productPageUrl:ae}=(0,y.A)(),ce=(0,k.y)(r);(0,u.useEffect)(()=>{if(!ce)return;const e=JSON.parse(localStorage.getItem(ce));if(!e)return;const{type:t,options:r}=e;localStorage.removeItem(ce),J(t,r)},[ce,J]),(0,u.useEffect)(()=>{ne&&j(!1)},[ne]),(0,u.useEffect)(()=>{["init","done"].includes(re)&&t({requestingState:re})},[re,t]);const le=!!e.content,ue=e.promptType===n.vE,de=__("Accept","jetpack"),pe=__("Accept title","jetpack"),he=ue?pe:de,me=async()=>{let t=[],s=(0,n._E)({content:e.content||""});if(s?.split("\n").length>1&&s?.split("\n")?.[0]?.match(/^

    .*<\/h1>$/)&&!X){const e=s.split("\n"),t=e.shift();s=e.join("\n"),P({title:t.replace(/<[^>]*>/g,"")})}t=(0,i.rawHandler)({HTML:s}),await T(r,t);const o=(e=>{let t=null;return e.forEach(e=>{const r=document.querySelector(`.wp-block[data-block="${e.clientId}"]`);if(!r)return;"true"===r.contentEditable&&(t=r);const n=r.querySelectorAll("[contenteditable=true]");t=n.length?n[n.length-1]:t}),t})(t);o&&(e=>{const t=e.ownerDocument.getSelection();t.selectAllChildren(e),t.collapseToEnd(),e.focus()})(o)},ge=()=>{me(),A.recordEvent("jetpack_ai_assistant_block_accept",{feature:"ai-assistant"})},fe=()=>{x?(P({title:e.content?e.content.trim():""}),N(r),A.recordEvent("jetpack_ai_assistant_block_accept",{feature:"ai-assistant"})):ge()},be=()=>{K(),V(),A.recordEvent("jetpack_ai_assistant_block_stop",{feature:"ai-assistant"})},ve=(0,o.useBlockProps)({ref:E,className:(0,p.A)({"is-waiting-response":se})}),ye=__("Ask Jetpack AI…","jetpack"),ke=__("Write about… Make a table for…","jetpack"),_e=(0,_.jsxs)(_.Fragment,{children:[D&&d&&(0,_.jsx)(n.Hb,{placement:"ai-assistant-block"}),!ie&&(0,_.jsx)(g.A,{block:"AI Assistant"})]}),xe=(0,_.jsx)(_.Fragment,{children:ne?.message&&!w&&"error_quota_exceeded"!==ne?.code&&(0,_.jsx)(a.Notice,{status:ne.status,isDismissible:!1,className:"jetpack-ai-assistant__error",children:ne.message})}),we=D&&H===s.Ti?(0,_.jsx)(n.QA,{variant:"muted"}):null,je=(0,u.useCallback)(e=>{e.preventDefault(),A.recordEvent("jetpack_ai_upgrade_button",{current_tier_slug:U?.slug,requests_count:F,placement:"jetpack_ai_assistant_block"}),$(e)},[A,U,F,$]);return(0,_.jsx)(a.KeyboardShortcuts,{bindGlobal:!0,shortcuts:{esc:()=>{["requesting","suggesting"].includes(re)&&be()}},children:(0,_.jsxs)("div",{...ve,children:[le&&(0,_.jsx)("div",{ref:Z,className:"jetpack-ai-assistant__content",children:(0,_.jsx)(u.RawHTML,{children:(0,n._E)({content:e.content||""})})}),(0,_.jsxs)(o.InspectorControls,{children:[we&&(0,_.jsxs)("div",{className:"block-editor-block-card",style:{paddingTop:0},children:[(0,_.jsx)("span",{className:"block-editor-block-icon"}),we]}),(0,_.jsxs)("div",{className:"block-editor-block-card",style:{paddingTop:0},children:[(0,_.jsx)("span",{className:"block-editor-block-icon"}),(0,_.jsx)(a.ExternalLink,{href:ae,children:__("Discover all features","jetpack")})]}),(H===s._X||z&&H!==s.Ti)&&(0,_.jsx)(a.PanelBody,{initialOpen:!0,children:(0,_.jsx)(a.PanelRow,{children:(0,_.jsx)(h.A,{placement:m.k})})}),(0,_.jsx)(a.PanelBody,{initialOpen:!0,children:(0,_.jsx)(a.PanelRow,{children:(0,_.jsx)(f.A,{})})})]}),!oe&&ie&&!I&&(0,_.jsx)(b.A,{isWaitingState:oe,contentIsLoaded:le,getSuggestionFromOpenAI:(e,t)=>{const r=(0,n.MB)(e,t);L(r),J(e,t)},retryRequest:ee,handleAcceptContent:ge,handleAcceptTitle:fe,handleTryAgain:null,showRetry:Y,contentBefore:Q,hasPostTitle:!!X?.length,wholeContent:te,promptType:e.promptType,setUserPrompt:e=>{if(!S?.current)return;S.current.focus(),t({userPrompt:e})},recordEvent:A.recordEvent,isGeneratingTitle:ue}),(0,_.jsx)(n.N0,{ref:S,disabled:I||!ie,value:e.userPrompt,placeholder:e?.content?ye:ke,onChange:e=>{j(!0),t({userPrompt:e})},onSend:()=>{L(e.userPrompt),((...e)=>{J(...e),G()})("userPrompt"),A.recordEvent("jetpack_ai_assistant_block_generate",{feature:"ai-assistant"})},onStop:be,onAccept:()=>{ue?fe():ge()},onDiscard:()=>{const n=e?.content===C(r).attributes?.content;t({content:e?.originalContent,promptType:void 0,messages:e?.originalMessages}),me(),n?A.recordEvent("jetpack_ai_assistant_block_dismiss"):A.recordEvent("jetpack_ai_assistant_block_discard",{feature:"ai-assistant"})},state:re,isTransparent:I||!ie,showButtonLabels:!W,showAccept:"init"!==re&&le&&!oe,acceptLabel:he,showGuideLine:le,showRemove:e?.content?.length>0,banner:_e,error:xe,customFooter:q%5!=0&&1!==F||O||H!==s._X?null:(0,_.jsx)(n.AK,{requestsRemaining:q,onUpgradeClick:je}),lastAction:R})]})})}},61351(e,t,r){"use strict";var n=r(94375),s=r(54681),o=r(3586),i=r(13802);r(47894),r(50797),r(78118);(0,n.M)(s,{edit:o.A,save:()=>null,transforms:i.Ay})},31124(e,t,r){"use strict";r.d(t,{A:()=>a});var n=r(96865),s=r(56427),o=r(27723),i=r(10790);const __=o.__;function a({label:e=__("AI Assistant","jetpack"),behavior:t,onAction:r,onDropdownToggle:o,renderContent:a,behaviorContext:c,disabled:l}){return(0,i.jsx)(s.Dropdown,{popoverProps:{variant:"toolbar"},renderToggle:({isOpen:o,onToggle:a})=>(0,i.jsx)(s.ToolbarButton,{className:"jetpack-ai-assistant__button",showTooltip:!0,onClick:()=>{if("function"!=typeof t)switch(t){case"action":r?.();break;case"dropdown":a()}else t({context:c})},"aria-haspopup":"true","aria-expanded":o,label:e,icon:n.cj,disabled:l}),onToggle:o,renderContent:a})}},9731(e,t,r){"use strict";r.d(t,{A:()=>b});var n=r(96865),s=r(85985),o=r(56427),i=r(86087),a=r(27723),c=r(83147),l=r(28755),u=r(10067),d=r.n(u),p=r(31124),h=r(89872),m=(r(16282),r(10790));const __=a.__,g=d()("jetpack-ai:image-extension-toolbar-dropdown"),f=(0,i.forwardRef)(({onClose:e,onRequestAltText:t,onRequestCaption:r,loadingAltText:s,loadingCaption:a},u)=>{const{requireUpgrade:d}=(0,n.yM)(),p=(0,i.useCallback)(async n=>{try{n===h.X?await(t?.()):await(r?.()),e?.()}catch(e){g("Error generating %s",n,e)}},[t,r,e]);return(0,m.jsx)("div",{className:"jetpack-ai-assistant-image-toolbar-dropdown-wrapper",tabIndex:-1,ref:u,children:(0,m.jsxs)(o.MenuGroup,{children:[(0,m.jsx)(o.MenuItem,{icon:s?(0,m.jsx)(o.Spinner,{}):l.A,iconPosition:"left",onClick:()=>{p(h.X)},disabled:!!s||d,children:__("Generate alt text","jetpack")},"key-ai-assistant-alt-text"),(0,m.jsx)(o.MenuItem,{icon:a?(0,m.jsx)(o.Spinner,{}):c.A,iconPosition:"left",onClick:()=>{p(h.Q)},disabled:!!a||d,children:__("Generate caption","jetpack")},"key-ai-assistant-caption")]})})});function b({label:e=__("AI Assistant","jetpack"),onRequestAltText:t,onRequestCaption:r,loadingAltText:o=!1,loadingCaption:a=!1,disabled:c=!1,wrapperRef:l}){const{requireUpgrade:u}=(0,n.yM)(),{tracks:d}=(0,s.st)(),h=(0,i.useCallback)(e=>{e&&(d.recordEvent("jetpack_ai_assistant_extension_toolbar_menu_show",{block_type:"core/image"}),u&&(0,n.Fs)())},[u,d]),g=(0,i.useCallback)(()=>(d.recordEvent("jetpack_editor_ai_assistant_extension_toolbar_button_click",{suggestion:"alt-text",block_type:"core/image"}),t?.()),[t,d]),b=(0,i.useCallback)(()=>(d.recordEvent("jetpack_editor_ai_assistant_extension_toolbar_button_click",{suggestion:"caption",block_type:"core/image"}),r?.()),[r,d]);return(0,m.jsx)(p.A,{label:e,behavior:"dropdown",onDropdownToggle:h,disabled:c,renderContent:({onClose:e})=>(0,m.jsx)(f,{ref:l,onClose:e,onRequestAltText:g,onRequestCaption:b,loadingAltText:o,loadingCaption:a})})}},78118(e,t,r){"use strict";var n=r(96865),s=r(94715),o=r(29491),i=r(47143),a=r(43656),c=r(86087),l=r(52619),u=r(10067),d=r.n(u),p=r(16204),h=r(35317),m=r(48499),g=r(10821),f=r(4647),b=r(89872),v=r(9731),y=r(10790);const k=d()("jetpack-ai:image-extension"),_=(0,m.C)("ai-assistant-image-extension"),x={group:"block"};const w=(0,o.createHigherOrderComponent)(e=>{function t(t){const{increaseRequestsCount:r,dequeueAsyncRequest:o,requireUpgrade:l}=(0,n.yM)(),{getCurrentPostId:u,isImageBusy:d}=(0,i.useSelect)(e=>{const{getCurrentPostId:r}=e(a.store);return{getCurrentPostId:r,isImageBusy:e(p.M)?.isImageBusy(t.clientId)??!1}},[t.clientId]),{getPostContent:h}=(0,n.dh)(),[m,g]=(0,c.useState)(d),[_,w]=(0,c.useState)(!1),{updateBlockAttributes:j}=(0,i.useDispatch)(a.store),{createNotice:A}=(0,i.useDispatch)("core/notices"),C=(0,c.useRef)(null),S=!!t.attributes.url,E=m||_;(0,c.useEffect)(()=>{g(d)},[d]);const T=(e,t)=>{e===b.X?g(t):e===b.Q&&w(t)},N=(0,c.useCallback)(e=>{C.current&&(C.current.setAttribute("tabindex","0"),C.current.focus()),T(e,!0)},[]),P=(0,c.useCallback)(e=>{A("error",e,{isDismissible:!0})},[A]);(0,c.useEffect)(()=>{E||C.current&&C.current.setAttribute("tabindex","-1")},[E]);const R=(0,c.useCallback)(async(e,s=!1)=>{if(!l){N(e);try{const i={};e===b.X&&(0,n.in)(t.clientId),e===b.Q&&(i.positions=[t.clientId]),o();const a=await(0,n.R0)([{role:"jetpack-ai",context:{type:e,content:h(f.P),...i,images:[{url:s?await(0,n.Zo)(t.attributes.url):t.attributes.url}]}}],{postId:u(),feature:"jetpack-ai-image-extension"});r();const c=JSON.parse(a?.replace?.(/^```json\s*/,"")?.replace(/```$/,""));if(e===b.X){const e=c.texts?.[0];j(t.clientId,{alt:e})}else if(e===b.Q){const e=c.captions?.[0];j(t.clientId,{caption:e})}T(e,!1)}catch(t){if(t?.message.includes("The image URL is invalid")&&!s)return k("Retrying with base64 image"),R(e,!0);k(`Error generating ${e}`,t),t?.message&&P(`Image ${e===b.X?"alt text":"caption"} generation failed: ${t.message}`),T(e,!1)}}},[o,u,h,r,t.attributes.url,t.clientId,l,P,N,j]);return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(e,{...t}),(0,y.jsx)(s.BlockControls,{...x,children:(0,y.jsx)(v.A,{onRequestAltText:()=>R(b.X),onRequestCaption:()=>R(b.Q),loadingAltText:m,loadingCaption:_,disabled:!S,wrapperRef:C})})]})}return r=>(0,h.A)(r.name)?(0,y.jsx)(t,{...r}):(0,y.jsx)(e,{...r})},"blockEditWithAiComponents");(0,l.addFilter)("blocks.registerBlockType","jetpack/ai-assistant-support/with-ai-image-extension",function(e,t){var r;return(r=t,!!(0,g.Bi)()&&!!_&&"core/image"===r)?{...e,edit:w(e.edit),supports:{...e.supports,"jetpack/ai":{assistant:!0}}}:e},100)},10821(e,t,r){"use strict";r.d(t,{Bi:()=>a});var n=r(85985),s=r(74997),o=r(47143);const i=(0,r(48499).C)("ai-assistant-support");function a(){if(!(0,s.getBlockType)("jetpack/ai-assistant"))return!1;if(!i)return!1;if(!(0,n.xI)())return!1;return!((0,o.select)("core/edit-post")?.getHiddenBlockTypes?.()??[]).includes("jetpack/ai-assistant")}},4647(e,t,r){"use strict";r.d(t,{P:()=>s});var n=r(96865);const s=e=>{const t=(0,n._G)().filter(e=>"core/image"===e.name);let r=0;return e=(e=e.replace(/]*>.*?<\/figcaption>/g,"")).replace(//gs,()=>{const e=t[r];return r++,e?``:""})}},52998(e,t,r){"use strict";r.d(t,{mt:()=>i});var n=r(96865),s=r(74997),o=r(47143);class i{renderRules=[];firstUpdate=!0;behavior="dropdown";isChildBlock=!1;feature="ai-assistant";adjustPosition=!0;startOpen=!1;hideOnBlockFocus=!0;supports={};constructor(e,t=[]){this.clientId=e,this.renderRules=t}getBlock(){const{getBlock:e}=(0,o.select)("core/block-editor");return e(this.clientId)}getContent(){const e=this.getBlock();return t=(0,s.getBlockContent)(e),(0,n.rh)({content:t});var t}renderContent(e){return function(e,t=[]){return(0,n._E)({content:e,rules:t,extension:!0})}(e,this.renderRules)}onSuggestion(e){if(!e)return;const t=this.renderContent(e);this.replaceBlockContent(t)}onDone(e){this.firstUpdate=!0}replaceBlockContent(e){const[t]=(0,s.rawHandler)({HTML:e});if(!t)return;const{updateBlockAttributes:r,replaceInnerBlocks:n,__unstableMarkNextChangeAsNotPersistent:i}=(0,o.dispatch)("core/block-editor");this.firstUpdate?this.firstUpdate=!1:i(),r(this.clientId,t.attributes),i(),n(this.clientId,t.innerBlocks)}getExtensionInputPlaceholder(){return null}}},96306(e,t,r){"use strict";r.d(t,{A:()=>u});var n=r(96865),s=r(85985),o=r(86087),i=r(27723),a=r(13022),c=(r(14808),r(10790));const __=i.__,l=(0,a.A)("jetpack-ai-assistant-extension-ai-input","wp-block");function u({customPlaceholder:e,className:t,requestingState:r,requestingError:i,inputRef:u,wrapperRef:d,action:p,blockType:h,feature:m,request:g,stopSuggestion:f,close:b,undo:v,tryAgain:y,lastAction:k}){const _=e||__("Ask Jetpack AI to edit…","jetpack"),[x,w]=(0,o.useState)(""),[j,A]=(0,o.useState)(_),{checkoutUrl:C}=(0,n.ON)(),{tracks:S}=(0,s.st)(),[E,T]=(0,o.useState)(0),[N,P]=(0,o.useState)(!1),{requireUpgrade:R,requestsCount:L,requestsLimit:D,loading:I,nextTier:B,currentTier:F}=(0,n.yM)(),M=(0,o.useMemo)(()=>R||["requesting","suggesting"].includes(r),[R,r]),U=(0,o.useMemo)(()=>R&&1===F?.value,[R,F]),O=(0,o.useCallback)(()=>{S.recordEvent("jetpack_ai_assistant_extension_generate",{block_type:h,feature:m}),g?.(x)},[h,m,g,S,x]),z=(0,o.useCallback)(()=>{S.recordEvent("jetpack_ai_assistant_extension_stop",{block_type:h}),A(_),f?.()},[h,_,f,S]);const q=(0,o.useCallback)(()=>{S.recordEvent("jetpack_ai_assistant_undo",{block_type:h,prompt:k||null}),v?.()},[h,k,S,v]),$=(0,o.useCallback)(()=>{S.recordEvent("jetpack_ai_upgrade_button",{current_tier_slug:F?.slug,requests_count:L,placement:"jetpack_ai_assistant_extension"})},[F?.slug,L,S]),H=(0,o.useCallback)(()=>{S.recordEvent("jetpack_ai_assistant_try_again",{block_type:h}),y?.()},[h,S,y]);return(0,o.useEffect)(()=>{["init","done"].includes(r)&&w("")},[r]),(0,o.useEffect)(()=>{A(p||_),p&&w("")},[p,_]),(0,o.useEffect)(()=>{P(!I&&!!B&&0===x.length)},[I,B,x]),(0,o.useEffect)(()=>{const e=Math.max(D-L,0);T(e)},[D,L]),(0,c.jsx)(n.FC,{className:(0,a.A)(l,t),placeholder:j,disabled:M,value:x,state:r,showGuideLine:!0,error:i,requestsRemaining:E,showUpgradeMessage:N,showFairUsageMessage:U,upgradeUrl:C,onChange:w,onSend:O,onStop:z,onClose:function(){b?.()},onUndo:q,onUpgrade:$,onTryAgain:H,wrapperRef:d,ref:u,lastAction:k,blockType:h})}},37931(e,t,r){"use strict";r.d(t,{A:()=>p});var n=r(85985),s=r(86087),o=r(27723),i=r(52068),a=r(76695),c=r(31124),l=r(21785),u=r(10790);const __=o.__;function d({blockType:e,onClose:t,onAskAiAssistant:r,onRequestSuggestion:n}){const{canTransformToAIAssistant:o,transformToAIAssistant:c,getSelectedBlockClientIds:l}=(0,a.A)(),d=(0,s.useCallback)(s=>{const i=l(),[a]=i,u=s?.options?.alwaysTransformToAIAssistant||!1;!(i.length<2)&&o({clientId:a,blockName:e})||u?c({request:s}):(s?n?.(s.promptType,s.options):r?.(),t?.())},[e,o,l,r,t,n,c]),[p]=l();return(0,u.jsx)(i.Ay,{blockType:e,clientId:p,onRequestSuggestion:(e,t)=>{d({promptType:e,options:t})},onAskAiAssistant:async()=>{d()},disabled:!1})}function p({behavior:e,blockType:t,label:r=__("AI Assistant","jetpack"),onAskAiAssistant:o,onRequestSuggestion:i}){const{tracks:a}=(0,n.st)(),p=(0,s.useContext)(l.B),h=(0,s.useCallback)(e=>{e&&a.recordEvent("jetpack_ai_assistant_extension_toolbar_menu_show",{block_type:t})},[t,a]),m=(0,s.useCallback)(()=>{a.recordEvent("jetpack_editor_ai_assistant_extension_toolbar_prompt_show",{block_type:t}),o?.()},[t,o,a]),g=(0,s.useCallback)((e,r)=>{a.recordEvent("jetpack_editor_ai_assistant_extension_toolbar_button_click",{suggestion:e,block_type:t}),i?.(e,r)},[t,i,a]);return(0,u.jsx)(c.A,{label:r,behavior:e,onAction:m,onDropdownToggle:h,renderContent:({onClose:e})=>(0,u.jsx)(d,{blockType:t,onClose:e,onAskAiAssistant:m,onRequestSuggestion:g}),behaviorContext:p})}},27571(e,t,r){"use strict";r.d(t,{L:()=>s,l:()=>n});const n=["jetpack/field-name","jetpack/field-number","jetpack/field-email","jetpack/field-text","jetpack/field-textarea","jetpack/field-time","jetpack/field-checkbox","jetpack/field-date","jetpack/field-telephone","jetpack/field-url","jetpack/field-checkbox-multiple","jetpack/field-radio","jetpack/field-select","jetpack/field-consent","jetpack/button"],s=["core/heading","core/paragraph","core/list-item","core/list","jetpack/contact-form",...n]},21785(e,t,r){"use strict";r.d(t,{B:()=>g,Q:()=>f});var n=r(86087),s=r(10067),o=r.n(s),i=r(52998),a=r(27571),c=r(50161),l=r(22352),u=r(53269),d=r(94987),p=r(125);const h=o()("jetpack-ai-assistant:extensions:get-block-handler"),m={"core/heading":c.T,"core/paragraph":p.d,"core/list-item":d.g,"core/list":u.b,"jetpack/contact-form":l.p,...a.l.reduce((e,t)=>({...e,[t]:l.g}),{})},g=(0,n.createContext)({});function f(e,t){let r=m[e];r||(h(`No handler found for block type: ${e}. Using default handler.`),r=i.mt);const n=new r(t);return{onSuggestion:n.onSuggestion.bind(n),onDone:n.onDone.bind(n),getContent:n.getContent.bind(n),getExtensionInputPlaceholder:n.getExtensionInputPlaceholder.bind(n),behavior:n.behavior,isChildBlock:n.isChildBlock,feature:n.feature,adjustPosition:n.adjustPosition,startOpen:n.startOpen,hideOnBlockFocus:n.hideOnBlockFocus,supports:n.supports}}},50161(e,t,r){"use strict";r.d(t,{T:()=>s});var n=r(52998);class s extends n.mt{constructor(e){super(e,[])}onSuggestion(e){const t=this.getBlock();if(e.startsWith("#")||(e=`${"#".repeat(t?.attributes?.level||1)} ${e}`),e.match(/^#*\s*$/))return;const r=this.renderContent(e);this.replaceBlockContent(r)}}},8663(e,t,r){"use strict";r.d(t,{g:()=>o});var n=r(47143),s=r(52998);class o extends s.mt{jetpackFormBlockName="jetpack/contact-form";constructor(e){super(e,[]),this.behavior=this.handleBehavior,this.isChildBlock=!0,this.hideOnBlockFocus=!1}handleBehavior=({context:e})=>{const t=(0,n.dispatch)("core/block-editor"),{getBlockParentsByBlockName:r}=(0,n.select)("core/block-editor"),s=r(this.clientId,this.jetpackFormBlockName)?.[0];t.selectBlock(s),e?.[this.jetpackFormBlockName]?.handleAskAiAssistant?.()}}},22352(e,t,r){"use strict";r.d(t,{g:()=>l.g,p:()=>u});var n=r(74997),s=r(47143),o=r(27723),i=r(62514),a=r(96568),c=r(52998),l=r(8663);const __=o.__;class u extends c.mt{currentListOfValidBlocks=[];originalVariationName=null;constructor(e){super(e,[]),this.behavior="action",this.feature="jetpack-form-ai-extension",this.startOpen=!0,this.hideOnBlockFocus=!1,this.adjustPosition=!1,this.supports={file_upload_field:1}}setContent(e,t=!1){const{replaceInnerBlocks:r,updateBlockAttributes:o}=(0,s.dispatch)("core/block-editor"),c=(0,n.parse)(e).find(e=>"jetpack/contact-form"===e.name);c&&c.attributes?.variationName&&(this.originalVariationName=c.attributes.variationName);const l=e.replace(//g,""),u=(0,a.d)(l),d=(0,n.parse)(u).filter(e=>e.isValid&&!["core/freeform","core/missing","core/html"].includes(e.name));let p=!1;if(d.length0){const e=d[d.length-1],t=this.currentListOfValidBlocks[d.length-1];p=!(0,i.w)(e,t)}if(d.length>0&&(d.length!==this.currentListOfValidBlocks.length||p)&&(r(this.clientId,d),this.currentListOfValidBlocks=d),t){if(this.originalVariationName){const e=this.getBlock();e&&e.attributes.variationName!==this.originalVariationName&&o(this.clientId,{variationName:this.originalVariationName})}const e=e=>"jetpack/button"===e.name||"core/button"===e.name&&"button"===e.attributes?.tagName,t=d.filter(e),s=d.some(e=>"jetpack/form-step-navigation"===e.name);if(this.currentListOfValidBlocks=this.currentListOfValidBlocks||[],t.length>1){let n=0;this.currentListOfValidBlocks=this.currentListOfValidBlocks.filter(r=>!e(r)||(n++,n===t.length)),r(this.clientId,this.currentListOfValidBlocks)}else 0!==t.length||s||r(this.clientId,[...this.currentListOfValidBlocks,(0,n.createBlock)("core/button",{tagName:"button",type:"submit",text:__("Submit","jetpack"),lock:{remove:!0}})]);this.currentListOfValidBlocks=[]}}getExtensionInputPlaceholder(){if(!this.getContent()){const e=[__("Example: a contact form with name, email, and message fields","jetpack"),__("Example: a pizza ordering form with name, address, phone number and toppings","jetpack"),__("Example: a survey form with multiple choice questions","jetpack")];return e[Math.floor(Math.random()*e.length)]}const e=[__("Example: remove email field","jetpack"),__("Example: make email optional","jetpack"),__("Example: add message field and make it required","jetpack")];return e[Math.floor(Math.random()*e.length)]}getContent(){const e=this.getBlock();if(!e)return"";const{innerBlocks:t}=e;return t?.length?t.reduce((e,t)=>e+(0,n.serialize)(t)+"\n\n",""):""}onSuggestion(e){this.setContent(e)}onDone(e){this.setContent(e,!0)}}},71295(e,t,r){"use strict";r.d(t,{j:()=>o});var n=r(10821),s=r(27571);function o(e){return!!(0,n.Bi)()&&!!s.L.includes(e)}},94987(e,t,r){"use strict";r.d(t,{g:()=>s});var n=r(52998);class s extends n.mt{constructor(e){super(e,["listItem"]),this.isChildBlock=!0}}},53269(e,t,r){"use strict";r.d(t,{b:()=>s});var n=r(52998);class s extends n.mt{constructor(e){super(e,["list"])}}},125(e,t,r){"use strict";r.d(t,{d:()=>a});var n=r(96865),s=r(74997),o=r(52998);const i=new n.OO({fixes:["paragraph"]});class a extends o.mt{constructor(e){super(e,["paragraph"])}getContent(){const e=this.getBlock();return t=(0,s.getBlockContent)(e),i.render({content:t});var t}}},50797(e,t,r){"use strict";var n=r(96865),s=r(85985),o=r(94715),i=r(29491),a=r(47143),c=r(86087),l=r(52619),u=r(13022),d=r(10067),p=r.n(d),h=r(32735),m=r(35317),g=r(4e4),f=r(96306),b=r(37931),v=r(21785),y=r(71295),k=r(10790);const _=p()("jetpack-ai-assistant:extensions:with-ai-extension"),x={"core/heading":"heading","core/paragraph":"paragraph","core/list-item":"list-item","core/list":"list","jetpack/contact-form":"form-ai"},w={group:"block"},j=(0,i.createHigherOrderComponent)(e=>{function t(t){const{clientId:r,isSelected:i,name:d,isSelectionEnabled:p}=t,m=(0,c.useRef)(null),y=(0,c.useRef)(0),j=(0,c.useRef)(null),A=(0,c.useRef)(""),C=(0,c.useRef)(null),S=(0,c.useRef)(document),E=(0,c.useRef)([]),[T,N]=(0,c.useState)(""),[P,R]=(0,c.useState)(null),L=(0,c.useRef)(null),D=(0,c.useRef)(null),I=(0,c.useRef)(null),B=(0,c.useRef)(null),{undo:F}=(0,a.useDispatch)("core/editor"),{postId:M}=(0,a.useSelect)(e=>{const{getCurrentPostId:t}=e("core/editor");return{postId:t()}},[]),{id:U,className:O}=(0,o.useBlockProps)({className:(0,u.A)({[d?.replace?.("/","-")]:!0})}),{increaseRequestsCount:z,dequeueAsyncRequest:q,requireUpgrade:$}=(0,n.yM)(),{snapToBottom:H,enableAutoScroll:V,disableAutoScroll:G}=(0,h.A)({current:S?.current?.getElementById(U)},void 0,!0),W=(0,c.useCallback)(()=>{C.current?.focus()},[]),{tracks:Z}=(0,s.st)(),{onSuggestion:J,onDone:K,getContent:Y,getExtensionInputPlaceholder:Q,behavior:X,isChildBlock:ee,feature:te,adjustPosition:re,startOpen:ne,hideOnBlockFocus:se,supports:oe}=(0,c.useMemo)(()=>(0,v.Q)(d,r),[d,r]),ie=Q(),[ae,ce]=(0,c.useState)(ne),le=(0,c.useCallback)(()=>{ce(e=>!e)},[]),ue=(0,c.useCallback)(({promptType:e,options:t})=>{const r=Y(),n=x[d];return[...E.current,{role:"jetpack-ai",context:{type:(0,g.p$)(e,n),content:r,request:t?.userPrompt,tone:t?.tone,language:t?.language,is_follow_up:E.current.length>0,supports:oe}}]},[d,Y,oe]),de=(0,c.useCallback)(e=>{const t=e||S.current.getElementById(U);t&&m.current&&t.style.setProperty("padding-bottom",`calc(${y.current+16}px + ${A.current||"0px"} )`,"important")},[U]),pe=(0,c.useCallback)(e=>{J(e),re&&de(),H()},[J,re,H,de]),he=(0,c.useCallback)((e,t)=>{if(G(),K(e),z(),N(""),Z.recordEvent("jetpack_ai_assistant_toolbar_extension_generate",{prompt_type:L.current,model:t,generation_time:null!==B.current?window?.performance?.now?.()-B.current:null}),D.current?.message){const e={role:"assistant",content:Y()};if(E.current.push(D.current.message,e),E.current.length>20){E.current.splice(0,E.current.length-20);const e=E.current.findIndex(e=>"jetpack-ai"===e.role);-1!==e&&(E.current=E.current.slice(e),E.current[0].context={...E.current[0].context,is_follow_up:!1})}}D.current=null,setTimeout(()=>{re&&de(),W()},100),(0,l.doAction)("jetpack_ai_assistant_generation_complete",r,d)},[G,K,z,Y,re,W,de,Z,L,r,d]),me=(0,c.useCallback)(e=>{G(),N(""),_("Request error",e),e.code!==n.mA&&e.code!==n.Or&&z()},[G,z]),{request:ge,stopSuggestion:fe,requestingState:be,model:ve,error:ye,reset:ke}=(0,n.o2)({onSuggestion:pe,onDone:he,onError:me,askQuestionOptions:{postId:M,feature:te}});(0,c.useEffect)(()=>{I.current=be},[be]);const _e=(0,c.useCallback)((e,t)=>{if(ce(!0),$)return;L.current=e;const r=(0,n.MB)(e,t);r&&(N(r),R(r));const s=ue({promptType:e,options:t});_("Request suggestion",e,t);const o=s[s.length-1];D.current={promptType:e,options:t,humanText:r,message:o},q(),V(),B.current=window?.performance?.now?.()||null,ge(s)},[q,V,ue,ge,$]),xe=(0,c.useCallback)(e=>{const t={userPrompt:e};R(e),V(),_e("userPrompt",t)},[V,_e]),we=(0,c.useCallback)(()=>{G(),fe(),W()},[G,fe,W]),je=(0,c.useCallback)(()=>{D.current&&_e(D.current.promptType,D.current.options)},[D,_e]),Ae=(0,c.useCallback)(()=>{ce(!1),ke(),N(""),D.current=null,E.current=[]},[ke]),Ce=(0,c.useCallback)(async()=>{Z.recordEvent("jetpack_ai_assistant_toolbar_extension_undo",{prompt_type:L.current,model:ve}),await F(),Ae()},[F,Ae,Z,ve,L]);(0,c.useEffect)(()=>{i||Ae()},[i,Ae]),(0,c.useEffect)(()=>{C.current&&p&&(S.current=C.current.ownerDocument,W())},[ae,W,p]),(0,c.useEffect)(()=>{let e=S.current.getElementById(U);if(e&&re)return ae&&!j.current&&m.current?(A.current=e.style.paddingBottom,j.current=new ResizeObserver(([t])=>{if(e=S.current.getElementById(U),y.current=t.contentRect.height,e&&m.current&&y.current>0){de(e);const{marginBottom:t}=getComputedStyle(e),r=parseFloat(t);m.current.style.setProperty("margin-top",`-${y.current+r}px`,"important"),m.current.style.setProperty("margin-bottom",`${r+16}px`,"important")}}),j.current.observe(m.current)):j.current&&(e.style.paddingBottom=A.current,j.current.disconnect(),j.current=null,y.current=0),()=>{j.current&&j.current.disconnect()}},[de,re,r,j,U,ae]),(0,c.useEffect)(()=>{if(se&&ae){const e=S.current.getElementById(U),t=()=>{["requesting","suggesting"].includes(I.current)||(ce(!1),e?.removeEventListener("focusin",t))};return e?.addEventListener("focusin",t),()=>{e?.removeEventListener("focusin",t)}}},[se,ae,U]);const Se=(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(e,{...t}),ae&&(0,k.jsx)(f.A,{customPlaceholder:ie||null,className:O,requestingState:be,requestingError:ye,wrapperRef:m,inputRef:C,action:T,blockType:d,feature:te,request:xe,stopSuggestion:we,close:Ae,undo:Ce,tryAgain:je,lastAction:P}),(0,k.jsx)(o.BlockControls,{...w,children:(0,k.jsx)(b.A,{blockType:d,onAskAiAssistant:le,onRequestSuggestion:_e,behavior:X})})]});if(ee)return Se;const Ee={value:{[d]:{handleAskAiAssistant:le,handleRequestSuggestion:_e}}};return(0,k.jsx)(v.B.Provider,{...Ee,children:Se})}return r=>{const n=(0,m.A)(r.name);return r.clientId&&r.attributes&&n?(0,k.jsx)(t,{...r}):(0,k.jsx)(e,{...r})}},"blockEditWithAiComponents");(0,l.addFilter)("blocks.registerBlockType","jetpack/ai-assistant-support/with-ai-text-extension",function(e,t){return(0,y.j)(t)?{...e,edit:j(e.edit),supports:{...e.supports,"jetpack/ai":{assistant:!0}}}:e},100)},89872(e,t,r){"use strict";r.d(t,{Q:()=>s,X:()=>n});const n="images-alt-text",s="images-caption"},4393(e,t,r){"use strict";r.d(t,{A:()=>h});var n=r(96865),s=r(47143),o=r(86087),i=r(10067),a=r.n(i),c=r(62402),l=r(64425),u=r(16597),d=r(32735);const p=a()("jetpack-ai-assistant:error"),h=({attributes:e,clientId:t,content:r,tracks:i,userPrompt:a,onSuggestionDone:h,onUnclearPrompt:m,onModeration:g,requireUpgrade:f,initialRequestingState:b,contentRef:v,blockRef:y})=>{const[k,_]=(0,o.useState)(!1),[x,w]=(0,o.useState)(""),{updateBlockAttributes:j}=(0,s.useDispatch)("core/block-editor"),{dequeueAiAssistantFeatureAsyncRequest:A,setAiAssistantFeatureRequireUpgrade:C}=(0,s.useDispatch)("wordpress-com/plans"),{snapToBottom:S,enableAutoScroll:E,disableAutoScroll:T}=(0,d.A)(y,v),N=(0,s.useSelect)(e=>e("core/editor").getEditedPostAttribute("title")),P=(0,s.useSelect)(e=>e("core/editor").getCurrentPostId()),R=(0,o.useRef)([]),L=(0,o.useRef)(void 0),{request:D,stopSuggestion:I,handleErrorQuotaExceededError:B,requestingState:F,error:M}=(0,n.o2)({onSuggestion:e=>{j(t,{content:e?.replaceAll(l.uV,"")}),S()},onDone:e=>{const r=e.replaceAll(l.uV,""),n={role:"assistant",content:r};R.current.push(L.current,n),R.current.length>20&&R.current.splice(0,R.current.length-20),j(t,{content:r,messages:R.current}),S(),T(),h?.()},onStop:()=>{S(),T(),h?.()},onError:e=>{switch(e?.code){case n.cT:_(!1);break;case n.ud:_(!1),g?.();break;case n.mA:case n.AZ:_(!0);break;case n.Or:_(!1),C(!0);break;case n.L9:m?.()}},onAllErrors:e=>{p(e)},initialRequestingState:b,askQuestionOptions:{postId:P,feature:"ai-assistant",functions:{}}}),U=["requesting","suggesting"].includes(F),O=async(s,o={})=>{if(A(),f)return B(),void _(!1);if(o={retryRequest:!1,tone:c.US,...o},U)return;_(!1);let d=x;if(i.recordEvent("jetpack_ai_chat_completion",{post_id:P}),R.current=[...e.messages],L.current={},o.retryRequest)L.current=d[d.length-1];else{const i=e?.isLayoutBuldingModeEnable?(0,u.rJ)(t):(0,u.aB)();d=(0,l.jf)({generatedContent:r,allPostContent:i,postContentAbove:(0,u.b$)(t),currentPostTitle:N,options:o,userPrompt:o?.userPrompt||a,type:s,isGeneratingTitle:e.promptType===n.vE}),L.current=d.pop(),d=[...d,...R.current],d.push(L.current),w(d),e.promptType!==n.vE&&j(t,{promptType:s})}try{E(),await D(d)}catch(e){p(e),_(!0),T()}};return{setShowRetry:_,showRetry:k,postTitle:N,contentBefore:(0,u.b$)(t),wholeContent:(0,u.aB)(),requestingState:F,error:M,getSuggestionFromOpenAI:O,stopSuggestion:I,retryRequest:()=>O("",{retryRequest:!0})}}},44732(e,t,r){"use strict";r.d(t,{A:()=>i});var n=r(3924),s=r(97999),o=r(85985);function i(){const e=(0,o.Mm)()&&!(0,s.isSimpleSite)(),t=e?(0,s.getMyJetpackUrl)("#/jetpack-ai"):(0,n.A)("org-ai"),{autosaveAndRedirect:r,isRedirecting:i}=(0,o.ZR)(t);return{productPageUrl:t,autosaveAndRedirect:r,isRedirecting:i,isMyJetpackAvailable:e}}},75956(e,t,r){"use strict";r.d(t,{A:()=>a});var n=r(90372),s=r(86087);const o=window?.Jetpack_Editor_Initial_State?.tracksUserData||null,i=parseInt(window?.Jetpack_Editor_Initial_State?.wpcomBlogId)||0,a=()=>((0,s.useEffect)(()=>{o&&n.A.initialize(o?.userid,o?.username,i?{blog_id:i}:{})},[]),n.A)},32735(e,t,r){"use strict";r.d(t,{A:()=>i});var n=r(86087),s=r(10067);const o=r.n(s)()("jetpack-ai-assistant:use-auto-scroll"),i=(e,t,r=!1)=>{const s=(0,n.useRef)(null),i=(0,n.useRef)(null),a=(0,n.useRef)(!1),c=(0,n.useRef)(!1),l=(0,n.useRef)(!1),u=(0,n.useRef)(!1),d=(0,n.useRef)({scrollPadding:"",scrollMargin:""}),p=(0,n.useCallback)(()=>{o("enabling ignore scroll"),c.current=!0},[]),h=(0,n.useCallback)(()=>{a.current&&l.current&&!c.current&&p()},[p]),m=(0,n.useCallback)(()=>{a.current=!0,c.current=!1,l.current=!1,u.current=!1,s.current?.addEventListener("scroll",h),o("enabling auto scroll")},[h]),g=(0,n.useCallback)(()=>{a.current=!1,c.current=!1,l.current=!1,u.current=!1,s.current?.removeEventListener("scroll",h),i.current?.style&&(i.current.style.scrollPadding=d.current.scrollPadding,i.current.style.scrollMargin=d.current.scrollMargin),s.current=null,o("disabling auto scroll")},[h]),f=(0,n.useCallback)(()=>{if(!a.current||c.current)return;const n=r?e?.current:t?.current?.firstElementChild?.lastElementChild;n&&!u.current&&(l.current=!0,u.current=!0,s?.current?.removeEventListener?.("scroll",h),n?.scrollIntoView({block:"end",inline:"end"}),setTimeout(()=>{u.current=!1,s?.current?.addEventListener?.("scroll",h)},200))},[e,t,r,h]),b=(0,n.useCallback)(e=>{if(null==e)return null;if("BODY"===e?.nodeName)return e;if(e?.ownerDocument!==document)return e.ownerDocument;const{overflow:t}=window.getComputedStyle(e);return t.split(" ").every(e=>"auto"===e||"scroll"===e)?e:e?.parentElement?b(e?.parentElement):e},[]);return(0,n.useEffect)(()=>{const t=b(e?.current?.parentElement);!s.current&&t&&(s.current=t,i.current=t instanceof HTMLElement?t:t.documentElement,d.current={scrollPadding:i.current.style.scrollPadding,scrollMargin:i.current.style.scrollMargin},a.current&&(i.current.style.scrollPadding="80px",i.current.style.scrollMargin="10px"))},[e,b]),{snapToBottom:f,enableAutoScroll:m,disableAutoScroll:g}}},35317(e,t,r){"use strict";r.d(t,{A:()=>o});var n=r(85985);const s={"jetpack/contact-form":"contact-form"};function o(e){const t=s[e],{isModuleActive:r}=(0,n.q7)(t);return!t||r}},76695(e,t,r){"use strict";r.d(t,{A:()=>l,y:()=>c});var n=r(85985),s=r(47143),o=r(51609),i=r(16597),a=r(13802);function c(e){return`ai-assistant-block-${e}`}const l=()=>{const{replaceBlock:e,removeBlocks:t}=(0,s.useDispatch)("core/block-editor"),r=(0,s.useSelect)(e=>e("core/block-editor"),[]),{getSelectedBlockClientIds:l,getBlocksByClientId:u,getBlock:d,getBlockParents:p}=r,{tracks:h}=(0,n.st)();return{canTransformToAIAssistant:(0,o.useCallback)(({clientId:e,blockName:t})=>{if(!d(e))return!1;if(!a.y7.includes(t))return!1;const r=p(e);if(0===r.length)return!0;const n=d(r[r.length-1]);return!["core/list","core/list-item"].includes(n.name)},[d,p]),transformToAIAssistant:(0,o.useCallback)(({request:r}={})=>{const n=l(),s=u(n),o=(0,i.Sb)(s),[d]=s,[p,...m]=n,g={...d?.attributes||{},content:o,preTransformAction:r?.promptType},f=(0,a.rr)(d.name,g);if(r?.promptType){h.recordEvent("jetpack_editor_ai_assistant_extension_toolbar_button_click",{suggestion:r.promptType,block_type:d.name});const e={clientId:p,type:r.promptType,options:{...r.options,contentType:"generated",fromExtension:!0}};localStorage.setItem(c(f.clientId),JSON.stringify(e))}else h.recordEvent("jetpack_ai_assistant_prompt_show",{block_type:d.name});e(p,f),t(m)},[u,l,t,e,h]),getSelectedBlockClientIds:l}}},4e4(e,t,r){"use strict";r.d(t,{J1:()=>s,K6:()=>o,p$:()=>a});var n=r(96865);function s(e){return{role:"jetpack-ai",context:{type:"ai-assistant-initial-prompt",for:a(e)}}}function o({generatedContent:e,allPostContent:t,postContentAbove:r,currentPostTitle:s,options:o,type:a,userPrompt:c,isGeneratingTitle:l}){const u=[],d="generated"===o?.contentType;let p=null;switch(a){case n.im:p=s;break;case n.sn:case n.A4:case n.yy:p=r;break;case n.vE:p=t;break;case n.br:case n.fD:p=e;break;case n.eJ:case n.UA:case n.Gm:p=d?e:t;break;case n.d5:p=r;break;case n.pE:p=e||t}const h=function(e,t){return!e&&t&&t.length>0?{role:"jetpack-ai",context:{type:"ai-assistant-relevant-content",content:t}}:null}(a===n.pE?!!e?.length:d,p);return h&&u.push(h),u.push({role:"jetpack-ai",context:i({generatedContent:e,allPostContent:t,postContentAbove:r,currentPostTitle:s,options:o,type:a,userPrompt:c,isGeneratingTitle:l})}),u}function i({options:e,type:t,userPrompt:r,isGeneratingTitle:s}){const o=function(e,t,r){return e?"title":!t||r?"content":null}(s,"generated"===e?.contentType,e?.fromExtension||!1);return{type:a(t),...o?{subject:o}:{},...t===n.eJ&&e?.tone?{tone:e.tone}:{},...t===n.Gm&&e?.language?{language:e.language}:{},...t===n.pE&&r?{request:r}:{}}}function a(e,t){const r={[n.im]:"ai-assistant-summary-by-title",[n.sn]:"ai-assistant-continue-writing",[n.A4]:"ai-assistant-simplify",[n.yy]:"ai-assistant-correct-spelling",[n.vE]:"ai-assistant-generate-title",[n.br]:"ai-assistant-make-longer",[n.fD]:"ai-assistant-make-shorter",[n.eJ]:"ai-assistant-change-tone",[n.UA]:"ai-assistant-summarize",[n.Gm]:"ai-assistant-change-language",[n.pE]:"ai-assistant-user-prompt",[n.d5]:"ai-assistant-transform-list-to-table"};return"form-ai"===t?"form-ai-extension":t?`${r[e]}-${t}-extension`:r[e]}},64425(e,t,r){"use strict";r.d(t,{jf:()=>i,uV:()=>o});var n=r(96865),s=r(4e4);n.im,n.sn,n.A4,n.yy,n.vE,n.br,n.fD,n.eJ,n.UA,n.Gm,n.pE,n.z5,n.d5;const o="````";function i({generatedContent:e,allPostContent:t,postContentAbove:r,currentPostTitle:n,options:o,type:i,userPrompt:a,isGeneratingTitle:c}){return[(0,s.J1)(i),...(0,s.K6)({generatedContent:e,allPostContent:t,postContentAbove:r,currentPostTitle:n,options:o,type:i,userPrompt:a,isGeneratingTitle:c})]}},16597(e,t,r){"use strict";r.d(t,{Sb:()=>c,aB:()=>a,b$:()=>i,rJ:()=>l});var n=r(96865),s=r(74997),o=r(47143);function i(e){if(!e)return"";const t=(0,o.select)("core/block-editor"),r=t.getBlockIndex(e),i=t.getBlocks().slice(0,r)??[];return i?.length?(0,n.rh)({content:(0,s.serialize)(i)}):""}function a(){const e=(0,o.select)("core/block-editor").getBlocks();return e?.length?(0,n.rh)({content:(0,s.serialize)(e)}):""}function c(e){return e.filter(e=>null!=e).map(e=>(0,s.getBlockContent)(e)).join("\n\n")}function l(e){const t=(0,o.select)("core/block-editor").getBlock(e);return t?.innerBlocks?.length?c(t.innerBlocks):""}},62514(e,t,r){"use strict";r.d(t,{w:()=>o});const n=e=>{delete e.clientId;for(const t of e.innerBlocks??[])n(t);return e},s=e=>n((e=>JSON.parse(JSON.stringify(e)))(e));function o(e,t){const r=s(e),n=s(t);return JSON.stringify(r)===JSON.stringify(n)}},96568(e,t,r){"use strict";function n(e){const t=document.createElement("div");return t.innerHTML=e,t.innerHTML}r.d(t,{d:()=>n})},48499(e,t,r){"use strict";r.d(t,{C:()=>s});var n=r(85985);function s(e){return!0===(0,n.FB)(e).available}},13802(e,t,r){"use strict";r.d(t,{Ay:()=>l,rr:()=>c,y7:()=>i});var n=r(96865),s=r(74997),o=r(54681);const i=["core/heading","core/paragraph","core/list"],a=[];function c(e,t){const{content:r,...i}=t;let a=r;"core/heading"===e&&t?.level&&(a=a.replace(/<(\/?)h\d([^>]*)>/g,`<$1h${t.level}$2>`));const c=(0,n.rh)({content:a}),l=[];return l.push({role:"jetpack-ai",context:{type:"ai-assistant-relevant-content",content:c}}),(0,s.createBlock)(o.name,{...i,content:c,originalContent:c,messages:l,originalMessages:l})}for(const e of i)a.push({type:"block",blocks:[e],isMatch:()=>i.includes(e),transform:(t,r)=>{const n=(0,s.getSaveContent)(e,t,r);return c(e,{...t,content:n})}});const l={from:a}},60487(e,t,r){"use strict";r.d(t,{A:()=>p});var n=r(56427),s=r(86087),o=r(27723),i=r(13022),a=r(66087),c=r(10790);const __=o.__,l="09:00",u="17:00";class d extends s.Component{renderInterval=(e,t)=>{const{day:r}=this.props,{opening:o,closing:a}=e;return(0,c.jsxs)(s.Fragment,{children:[(0,c.jsxs)("div",{className:"business-hours__row",children:[(0,c.jsx)("div",{className:(0,i.A)(r.name,"business-hours__day"),children:0===t&&this.renderDayToggle()}),(0,c.jsxs)("div",{className:(0,i.A)(r.name,"business-hours__hours"),children:[(0,c.jsx)(n.TextControl,{__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,type:"time",label:__("Opening","jetpack"),value:o,className:"business-hours__open",placeholder:l,onChange:e=>{this.setHour(e,"opening",t)}}),(0,c.jsx)(n.TextControl,{__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,type:"time",label:__("Closing","jetpack"),value:a,className:"business-hours__close",placeholder:u,onChange:e=>{this.setHour(e,"closing",t)}})]}),(0,c.jsx)("div",{className:"business-hours__remove",children:r.hours.length>1&&(0,c.jsx)(n.Button,{isSmall:!0,variant:"link",icon:"trash",label:__("Remove Hours","jetpack"),onClick:()=>{this.removeInterval(t)}})})]}),t===r.hours.length-1&&(0,c.jsxs)("div",{className:"business-hours__row business-hours-row__add",children:[(0,c.jsx)("div",{className:(0,i.A)(r.name,"business-hours__day"),children:" "}),(0,c.jsx)("div",{className:(0,i.A)(r.name,"business-hours__hours"),children:(0,c.jsx)(n.Button,{variant:"link",label:__("Add Hours","jetpack"),onClick:this.addInterval,children:__("Add Hours","jetpack")})}),(0,c.jsx)("div",{className:"business-hours__remove",children:" "})]})]},t)};setHour=(e,t,r)=>{const{day:n,attributes:s,setAttributes:o}=this.props,{days:i}=s;o({days:i.map(s=>s.name===n.name?{...s,hours:s.hours.map((n,s)=>s===r?{...n,[t]:e}:n)}:s)})};toggleClosed=e=>{const{day:t,attributes:r,setAttributes:n}=this.props,{days:s}=r;n({days:s.map(r=>{if(r.name===t.name){const t=e?[{opening:l,closing:u}]:[];return{...r,hours:t}}return r})})};addInterval=()=>{const{day:e,attributes:t,setAttributes:r}=this.props,{days:n}=t;e.hours.push({opening:"",closing:""}),r({days:n.map(t=>t.name===e.name?{...t,hours:e.hours}:t)})};removeInterval=e=>{const{day:t,attributes:r,setAttributes:n}=this.props,{days:s}=r;n({days:s.map(r=>t.name===r.name?{...r,hours:r.hours.filter((t,r)=>e!==r)}:r)})};isClosed(){const{day:e}=this.props;return(0,a.isEmpty)(e.hours)}renderDayToggle(){const{day:e,localization:t}=this.props;return(0,c.jsxs)(s.Fragment,{children:[(0,c.jsx)("span",{className:"business-hours__day-name",children:t.days[e.name]}),(0,c.jsx)(n.ToggleControl,{__nextHasNoMarginBottom:!0,label:this.isClosed()?__("Closed","jetpack"):__("Open","jetpack"),checked:!this.isClosed(),onChange:this.toggleClosed})]})}renderClosed(){const{day:e}=this.props;return(0,c.jsxs)("div",{className:"business-hours__row business-hours-row__closed",children:[(0,c.jsx)("div",{className:(0,i.A)(e.name,"business-hours__day"),children:this.renderDayToggle()}),(0,c.jsx)("div",{className:(0,i.A)(e.name,"closed","business-hours__hours"),children:" "}),(0,c.jsx)("div",{className:"business-hours__remove",children:" "})]})}render(){const{day:e}=this.props;return this.isClosed()?this.renderClosed():e.hours.map(this.renderInterval)}}const p=d},39943(e,t,r){"use strict";r.d(t,{A:()=>u});var n=r(86087),s=r(27723),o=r(66087),i=r(10790);const _x=s._x,a="undefined"!=typeof window&&window.navigator?.language||"en",c=Intl?.DateTimeFormat?new Intl.DateTimeFormat(a,{hour:"numeric",minute:"numeric",hour12:!0}):null;class l extends n.Component{formatTime(e){const[t,r]=e.split(":");if(!t||!r)return!1;const n=new Date;return n.setHours(t),n.setMinutes(r),c?c.format(n):e}renderInterval=(e,t)=>{const{day:r}=this.props,n=r.hours;return(0,i.jsxs)("span",{children:[(0,s.sprintf)("%1$s - %2$s",this.formatTime(e.opening),this.formatTime(e.closing)),n.length>1+t&&(0,i.jsx)("span",{children:", "})]},t)};render(){const{day:e,localization:t}=this.props,r=e.hours.filter(e=>this.formatTime(e.opening)&&this.formatTime(e.closing));return(0,i.jsxs)("div",{className:"jetpack-business-hours__item",children:[(0,i.jsx)("dt",{className:e.name,children:t.days[e.name]}),(0,i.jsxs)("dd",{children:[(0,o.isEmpty)(r)?_x("Closed","business is closed on a full day","jetpack"):r.map(this.renderInterval),(0,i.jsx)("br",{})]})]})}}const u=l},39155(e,t,r){"use strict";r.d(t,{A:()=>b});var n=r(85985),s=r(1455),o=r.n(s),i=r(94715),a=r(56427),c=r(38443),l=r(86087),u=r(27723),d=r(9050),p=r(60487),h=r(39943),m=r(10790);const __=u.__,g=(0,n.sh)(d),f={days:{Sun:__("Sunday","jetpack"),Mon:__("Monday","jetpack"),Tue:__("Tuesday","jetpack"),Wed:__("Wednesday","jetpack"),Thu:__("Thursday","jetpack"),Fri:__("Friday","jetpack"),Sat:__("Saturday","jetpack")},startOfWeek:0},b=e=>{const{attributes:t,isSelected:r}=e,n=(0,i.useBlockProps)(),[s,u]=(0,l.useState)(f),[d,b]=(0,l.useState)(!1),{days:v}=t,{startOfWeek:y}=s,k=v.concat(v.slice(0,y)).slice(y);let _;if((0,l.useEffect)(()=>{o()({path:"/wpcom/v2/business-hours/localized-week"}).then(e=>{u(e),b(!0)},()=>{u(f),b(!0)})},[]),d)if(r)_=(0,m.jsx)("div",{className:"is-edit",children:k.map((t,r)=>(0,m.jsx)(p.A,{day:t,localization:s,...e},r))});else{const e=(0,c.getSettings)(),{formats:{time:t}}=e;_=(0,m.jsx)("dl",{className:"jetpack-business-hours",children:k.map((e,r)=>(0,m.jsx)(h.A,{day:e,localization:s,timeFormat:t},r))})}else _=(0,m.jsx)(a.Placeholder,{icon:g,label:__("Loading business hours","jetpack")});return(0,m.jsx)("div",{...n,children:_})}},71410(e,t,r){"use strict";var n=r(94375),s=r(9050),o=r(39155),i=(r(87495),r(1947),r(10790));(0,n.M)(s,{edit:e=>(0,i.jsx)(o.A,{...e}),save:()=>null})},28310(e,t,r){"use strict";r.d(t,{A:()=>s});var n=r(98329);const s={element:{type:"string",enum:["a","button","input"]},saveInPostContent:{type:"boolean",default:!1},uniqueId:{type:"string"},passthroughAttributes:{type:"object"},text:{type:"string",role:"content"},placeholder:{type:"string",role:"content"},url:{type:"string",role:"content"},textColor:{type:"string"},customTextColor:{type:"string",validator:n.A},backgroundColor:{type:"string"},customBackgroundColor:{type:"string",validator:n.A},gradient:{type:"string"},customGradient:{type:"string"},borderRadius:{type:"number"},width:{type:"string"},customVariant:{type:"string"},metaName:{type:"string"}}},12365(e,t,r){"use strict";r.d(t,{A:()=>c});var n=r(56427),s=r(86087),o=r(27723),i=r(8746),a=r(10790);const __=o.__;function c({borderRadius:e="",setAttributes:t}){const r=(0,s.useCallback)(e=>t({borderRadius:e}),[t]);return(0,a.jsx)(n.PanelBody,{title:__("Border Settings","jetpack"),children:(0,a.jsx)(n.RangeControl,{__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,allowReset:!0,initialPosition:i.hc,label:__("Border radius","jetpack"),max:i.Bs,min:i.rG,onChange:r,value:e})})}},10179(e,t,r){"use strict";r.d(t,{A:()=>i});var n=r(94715),s=r(27723),o=r(10790);const __=s.__;function i({isGradientAvailable:e,backgroundColor:t,fallbackBackgroundColor:r,fallbackTextColor:s,gradientValue:i,setBackgroundColor:a,setGradient:c,setTextColor:l,textColor:u}){const d=(0,o.jsx)(n.ContrastChecker,{backgroundColor:t.color,fallbackBackgroundColor:r,fallbackTextColor:s,isLargeText:!1,textColor:u.color});return e?(0,o.jsx)(n.__experimentalPanelColorGradientSettings,{settings:[{colorValue:u.color,label:__("Text Color","jetpack"),onColorChange:l},{colorValue:t.color,gradientValue:i,label:__("Background","jetpack"),onColorChange:a,onGradientChange:c}],title:__("Background & Text Color","jetpack"),children:d}):(0,o.jsx)(n.PanelColorSettings,{colorSettings:[{value:u.color,onChange:l,label:__("Text Color","jetpack")},{value:t.color,onChange:a,label:__("Background","jetpack")}],title:__("Background & Text Color","jetpack"),children:d})}},8746(e,t,r){"use strict";r.d(t,{Bs:()=>i,Uc:()=>s,hc:()=>o,rG:()=>a});var n=r(94715);const s=!!n.__experimentalUseGradient,o=5,i=50,a=0},2761(e,t,r){"use strict";r.d(t,{A:()=>c});var n=r(47143),s=r(38062),o=r(12365),i=r(10179),a=r(10790);function c({attributes:e,backgroundColor:t,clientId:r,context:c,fallbackBackgroundColor:l,fallbackTextColor:u,setAttributes:d,setBackgroundColor:p,setTextColor:h,textColor:m,gradientValue:g,setGradient:f,isGradientAvailable:b}){const{align:v,borderRadius:y}=e,k="jetpack/parentBlockWidth"in c,_=k?c["jetpack/parentBlockWidth"]:e.width,x=(0,n.useSelect)(e=>{const{getBlock:t,getBlockRootClientId:n}=e("core/block-editor");return t(n(r))}),{updateBlockAttributes:w}=(0,n.useDispatch)("core/block-editor");return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(i.A,{backgroundColor:t,fallbackBackgroundColor:l,fallbackTextColor:u,gradientValue:g,setBackgroundColor:p,setGradient:f,setTextColor:h,textColor:m,isGradientAvailable:b}),(0,a.jsx)(o.A,{borderRadius:y,setAttributes:d}),(0,a.jsx)(s.D,{align:v,width:_,onChange:e=>{k?w(x.clientId,{width:e}):d({width:e})}})]})}},55903(e,t,r){"use strict";r.d(t,{A:()=>m});var n=r(94715),s=r(29491),o=r(47143),i=r(86087),a=r(27723),c=r(13022),l=r(8746),u=r(2761),d=r(7528),p=r(81177),h=(r(55179),r(10790));const __=a.__;const m=(0,s.compose)((0,n.withColors)({backgroundColor:"background-color"},{textColor:"color"}))(function(e){const{attributes:t,backgroundColor:r,className:s,clientId:a,setAttributes:m,textColor:g}=e,{borderRadius:f,element:b,placeholder:v,text:y,width:k,fontSize:_,customVariant:x,metaName:w}=t;(0,p.A)({attributes:t,clientId:a,setAttributes:m});const{metadata:j}=(0,o.useSelect)(e=>{const{getBlockAttributes:t}=e(n.store);return{metadata:t(a)?.metadata}},[a]),{updateBlockAttributes:A,__unstableMarkNextChangeAsNotPersistent:C}=(0,o.useDispatch)("core/block-editor"),{gradientClass:S,gradientValue:E,setGradient:T}=l.Uc?(0,n.__experimentalUseGradient)({gradientAttribute:"gradient",customGradientAttribute:"customGradient"}):{},N=(0,n.useBlockProps)({className:(0,c.A)("wp-block-button",s),style:{width:k}}),[P,R]=(0,d.A)(),L=(0,n.__experimentalUseBorderProps)(t),D=(0,c.A)("wp-block-button__link",L.className,{"has-background":r.color||E,[r.class]:!E&&r.class,"has-text-color":g.color,[g.class]:g.class,[S]:S,"no-border-radius":0===f,[`has-${_}-font-size`]:!!_,"has-custom-font-size":!!_,[`is-${x}`]:!!x});(0,i.useEffect)(()=>{a&&w&&j?.name!==w&&(C(),A(a,{metadata:{...j,name:w}}))},[w,j,A,a,C]);const I={...!r.color&&E?{background:E}:{backgroundColor:r.color},fontSize:t.style?.typography?.fontSize,color:g.color,borderRadius:f?f+"px":void 0,...L.style};return(0,h.jsxs)("div",{...N,children:[(0,h.jsx)(n.RichText,{allowedFormats:"input"===b?[]:void 0,className:D,disableLineBreaks:"input"===b,onChange:e=>m({text:e}),placeholder:v||__("Add text…","jetpack"),ref:R,style:I,value:y,withoutInteractiveFormatting:!0}),(0,h.jsx)(n.InspectorControls,{children:(0,h.jsx)(u.A,{gradientValue:E,setGradient:T,isGradientAvailable:l.Uc,...P,...e})})]})})},45878(e,t,r){"use strict";var n=r(94375),s=r(5383);(0,n.A)(s.U,s.W)},36270(e,t,r){"use strict";r.d(t,{A:()=>o});var n=r(56427),s=r(10790);const o=(0,s.jsx)(n.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,s.jsx)(n.Path,{d:"M19 6.5H5c-1.1 0-2 .9-2 2v7c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-7c0-1.1-.9-2-2-2zm.5 9c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5v-7c0-.3.2-.5.5-.5h14c.3 0 .5.2.5.5v7zM8 13h8v-1.5H8V13z"})})},5383(e,t,r){"use strict";r.d(t,{U:()=>l,W:()=>u});var n=r(27723),s=r(97969),o=r(28310),i=r(55903),a=r(36270),c=r(85154);const __=n.__,l="button",u={apiVersion:3,title:__("Button","jetpack"),icon:a.A,category:(0,s.A)("design","layout"),keywords:[],supports:{html:!1,inserter:!1,align:["left","center","right"],typography:{fontSize:!0,__experimentalFontFamily:!0,__experimentalTextTransform:!0,__experimentalDefaultControls:{fontSize:!0}},__experimentalBorder:{color:!0,style:!0,width:!0,__experimentalSkipSerialization:!0,__experimentalDefaultControls:{color:!0,style:!0,width:!0}}},styles:[{name:"fill",label:__("Fill","jetpack"),isDefault:!0},{name:"outline",label:__("Outline","jetpack")}],selectors:{border:".wp-block-jetpack-button .wp-block-button__link"},attributes:o.A,edit:i.A,save:c.A,usesContext:["jetpack/parentBlockWidth"]}},85154(e,t,r){"use strict";r.d(t,{A:()=>a});var n=r(94715),s=r(13022),o=r(8746),i=r(10790);function a({attributes:e,blockName:t,uniqueId:r}){const{backgroundColor:a,borderRadius:c,className:l,customBackgroundColor:u,customGradient:d,customTextColor:p,gradient:h,saveInPostContent:m,text:g,textColor:f,url:b,width:v,fontSize:y}=e;if(!m)return null;const k=n.useBlockProps.save(),_=(0,n.__experimentalGetBorderClassesAndStyles)(e),x=(0,n.getColorClassName)("background-color",a),w=o.Uc?(0,n.__experimentalGetGradientClass)(h):void 0,j=(0,n.getColorClassName)("color",f),A=(0,s.A)("wp-block-button","jetpack-submit-button",l,k?.className,_.className,{[`wp-block-jetpack-${t}`]:t}),C=(0,s.A)("wp-block-button__link",{"has-text-color":f||p,[j]:j,"has-background":a||h||u||d,[x]:x,[w]:w,"no-border-radius":0===c,"has-custom-width":!!v,[`has-${y}-font-size`]:!!y,"has-custom-font-size":!!y}),S={background:d||void 0,backgroundColor:x||d||h?void 0:u,fontSize:e.style?.typography?.fontSize,color:j?void 0:p,borderRadius:c?c+"px":void 0,width:v,..._.style};return(0,i.jsx)("div",{...k,className:A,children:(0,i.jsx)(n.RichText.Content,{className:C,"data-id-attr":r||"placeholder",href:b,id:r,rel:"noopener noreferrer",role:"button",style:S,tagName:"a",target:"_blank",value:g})})}},7528(e,t,r){"use strict";r.d(t,{A:()=>o});var n=r(29491),s=r(86087);function o(){const[e,t]=(0,s.useState)(),r=(0,n.useRefEffect)(r=>{const n=()=>{const n=getComputedStyle(r),s=n.backgroundColor,o=n.color;s===e?.fallbackBackgroundColor&&o===e?.fallbackTextColor||t({fallbackBackgroundColor:s,fallbackTextColor:o})},s=new MutationObserver(n);return s.observe(r,{attributeFilter:["style","class"]}),n(),()=>{s.disconnect()}},[]);return[e,r]}},81177(e,t,r){"use strict";r.d(t,{A:()=>i});var n=r(47143),s=r(86087),o=r(66087);function i({attributes:e,clientId:t,setAttributes:r}){const{passthroughAttributes:i}=e,a=(0,n.useSelect)(r=>{const n=r("core/block-editor"),s=n.getBlockRootClientId(t),o=n.getBlockAttributes(s)||{};if(!s||!i)return{};let a=!1;const c={};return Object.entries(i).forEach(([t,r])=>{const n=o[r];n!==e[t]&&(a=!0,c[t]=n)}),a?c:{}},[t,i,e]);(0,s.useEffect)(()=>{(0,o.isEmpty)(a)||r(a)},[a,r])}},95816(e,t,r){"use strict";r.d(t,{a:()=>n});const n="https://calendly.com/wpcom/jetpack-block-example"},99723(e,t,r){"use strict";r.d(t,{Ay:()=>d});var n=r(97999),s=r(94715),o=r(56427),i=r(27723),a=r(5873),c=r(10790);const __=i.__,_x=i._x,l=({onEditClick:e})=>(0,c.jsx)(o.ToolbarGroup,{children:(0,c.jsx)(o.ToolbarButton,{onClick:()=>e(!0),children:__("Edit","jetpack")})}),u=e=>{const{attributes:{hideEventTypeDetails:t,url:r},defaultClassName:s,embedCode:i,parseEmbedCode:a,setAttributes:l,setEmbedCode:u}=e;let d=null;return r&&(d=(0,n.isWpcomPlatformSite)()?"https://wordpress.com/support/wordpress-editor/blocks/calendly-block/#customize-the-calendly-block":"https://jetpack.com/support/jetpack-blocks/calendly-block/#customizing-a-calendly-block"),(0,c.jsxs)(c.Fragment,{children:[(0,c.jsxs)(o.PanelBody,{PanelBody:!0,title:__("Calendar settings","jetpack"),initialOpen:!1,children:[(0,c.jsxs)("form",{onSubmit:a,className:`${s}-embed-form-sidebar`,children:[(0,c.jsx)("input",{type:"text",id:"embedCode",onChange:e=>u(e.target.value),placeholder:__("Calendly web address or embed code…","jetpack"),value:i||"",className:"components-placeholder__input"}),(0,c.jsx)("div",{children:(0,c.jsx)(o.Button,{variant:"secondary",type:"submit",children:_x("Embed","button label","jetpack")})})]}),(0,c.jsx)(o.ToggleControl,{__nextHasNoMarginBottom:!0,label:__("Hide event type details","jetpack"),checked:t,onChange:()=>l({hideEventTypeDetails:!t})})]}),d&&(0,c.jsx)(o.Notice,{className:`${s}-color-notice`,isDismissible:!1,children:(0,c.jsx)(o.ExternalLink,{href:d,children:__("Explore more customization options.","jetpack")})})]})},d=e=>{const{attributes:t,clientId:r,isEditingUrl:n,setAttributes:o,setIsEditingUrl:i}=e,{style:d,url:p}=t,h=[{value:"inline",label:__("Inline","jetpack")},{value:"link",label:__("Link","jetpack")}];return(0,c.jsxs)(c.Fragment,{children:[p&&!n&&(0,c.jsx)(s.BlockControls,{children:(0,c.jsx)(l,{onEditClick:i})}),p&&(0,c.jsx)(a.A,{clientId:r,styleOptions:h,onSelectStyle:o,activeStyle:d,attributes:t,viewportWidth:500}),(0,c.jsx)(s.InspectorControls,{children:(0,c.jsx)(u,{...e})})]})}},19493(e,t,r){"use strict";r.d(t,{A:()=>a});var n=r(74997),s=r(27723),o=r(98329),i=r(10790);const __=s.__,a={attributes:{backgroundColor:{type:"string",default:"ffffff",validator:o.A},submitButtonText:{type:"string",default:__("Schedule time with me","jetpack")},submitButtonTextColor:{type:"string"},submitButtonBackgroundColor:{type:"string"},submitButtonClasses:{type:"string"},hideEventTypeDetails:{type:"boolean",default:!1},primaryColor:{type:"string",default:"00A2FF",validator:o.A},textColor:{type:"string",default:"4D5055",validator:o.A},style:{type:"string",default:"inline",validValues:["inline","link"]},url:{type:"string",validator:e=>!e||e.startsWith("https://calendly.com/")},backgroundButtonColor:{type:"string"},textButtonColor:{type:"string"},customBackgroundButtonColor:{type:"string",validator:o.A},customTextButtonColor:{type:"string",validator:o.A}},migrate:e=>{const{submitButtonText:t,submitButtonTextColor:r,submitButtonBackgroundColor:s,submitButtonClasses:o,backgroundButtonColor:i,textButtonColor:a,customBackgroundButtonColor:c,customTextButtonColor:l,...u}=e,d={text:(p=e).submitButtonText||__("Schedule time with me","jetpack"),textColor:p.submitButtonTextColor||p.textButtonColor,customTextColor:p.customTextButtonColor,backgroundColor:p.submitButtonBackgroundColor||p.backgroundButtonColor,customBackgroundColor:p.customBackgroundButtonColor,url:p.url};var p;return[u,[(0,n.createBlock)("jetpack/button",{element:"a",uniqueId:"calendly-widget-id",...d})]]},save:({attributes:{url:e}})=>(0,i.jsx)("a",{href:e,children:e})}},52385(e,t,r){"use strict";r.d(t,{A:()=>x});var n=r(85985),s=r(94715),o=r(74997),i=r(56427),a=r(47143),c=r(86087),l=r(27723),u=r(13022),d=r(66087),p=r(78218),h=r(56145),m=r(13248),g=r(95816),f=r(99723),b=r(38028),v=(r(8221),r(98989),r(10790));const __=l.__,_x=l._x,y="jetpack/button",k={element:"a",text:__("Schedule time with me","jetpack"),uniqueId:"calendly-widget-id",url:g.a},_=(0,n.sh)(m);const x=(0,i.withNotices)(function(e){const{attributes:t,clientId:r,name:n,noticeOperations:l,noticeUI:x,setAttributes:w}=e,j=(0,o.getBlockDefaultClassName)(n),A=(0,p.y)(m.attributes,t);(0,d.isEqual)(A,t)||w(A);const{backgroundColor:C,hideEventTypeDetails:S,primaryColor:E,textColor:T,style:N,url:P}=A,[R,L]=(0,c.useState)(P),[D,I]=(0,c.useState)(!1),[B,F]=(0,c.useState)(!1),[M,U]=(0,c.useState)({}),O=(0,s.useBlockProps)(),z=()=>{l.removeAllNotices(),l.createErrorNotice(__("Your calendar couldn't be embedded. Please double check your URL or code.","jetpack"))};(0,c.useEffect)(()=>{P&&g.a!==P&&"link"!==N&&(0,h.A)(P,F).catch(()=>{w({url:void 0}),z()})},[]);const q=e=>{if(!e)return void z();e.preventDefault();const t=(0,b.a9)(R);if(t){if(t.buttonAttributes&&"link"===t.style){const e=(0,a.select)("core/editor").getBlocksByClientId(r);e.length&&e[0].innerBlocks.forEach(e=>{(0,a.dispatch)("core/editor").updateBlockAttributes(e.clientId,t.buttonAttributes)}),U(t.buttonAttributes)}(0,h.A)(t.url,F).then(()=>{const e=(0,p.y)(m.attributes,t);w(e),I(!1),l.removeAllNotices()}).catch(()=>{w({url:void 0}),z()})}else z()},$=(0,v.jsxs)("div",{className:"wp-block-embed is-loading",children:[(0,v.jsx)(i.Spinner,{}),(0,v.jsx)("p",{children:__("Embedding…","jetpack")})]}),H=(0,v.jsxs)(i.Placeholder,{label:__("Calendly","jetpack"),instructions:__("Enter your Calendly web address or embed code below.","jetpack"),icon:_,notices:x,children:[(0,v.jsxs)("form",{onSubmit:q,children:[(0,v.jsx)("input",{type:"text",id:"embedCode",onChange:e=>L(e.target.value),placeholder:__("Calendly web address or embed code…","jetpack"),value:R||"",className:"components-placeholder__input"}),(0,v.jsx)("div",{children:(0,v.jsx)(i.Button,{variant:"secondary",type:"submit",children:_x("Embed","button label","jetpack")})})]}),(0,v.jsx)("div",{className:`${j}-learn-more`,children:(0,v.jsx)(i.ExternalLink,{href:"https://help.calendly.com/hc/en-us/articles/223147027-Embed-options-overview",children:__("Need help finding your embed code?","jetpack")})})]}),V=(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{className:`${j}-overlay`}),(0,v.jsx)("iframe",{src:(()=>{const e=new URLSearchParams({embed_domain:"wordpress.com",embed_type:"Inline",hide_event_type_details:S?1:0,background_color:C,primary_color:E,text_color:T});return`${P}?${e}`})(),width:"100%",height:"100%",frameBorder:"0","data-origwidth":"100%","data-origheight":"100%",title:"Calendly"})]}),G=(0,v.jsx)(s.InnerBlocks,{template:[[y,{...k,...M,passthroughAttributes:{url:"url"}}]],templateLock:"all"});return B?$:(0,v.jsxs)("div",{...O,className:(0,u.A)(O.className,{[`calendly-style-${N}`]:P&&!D}),children:[(0,v.jsx)(f.Ay,{...e,defaultClassName:j,embedCode:R,isEditingUrl:D,parseEmbedCode:q,setEmbedCode:L,setIsEditingUrl:I}),P&&!D?(W=N,"inline"===W?V:G):H]});var W})},60312(e,t,r){"use strict";var n=r(74997),s=r(94375),o=r(13248),i=r(19493),a=r(52385),c=r(2668),l=r(38028);r(8221);(0,s.M)(o,{edit:a.A,save:c.A,transforms:{from:[{type:"raw",isMatch:e=>"P"===e.nodeName&&l.QL.test(e.textContent),transform:e=>{const t=(0,l.a9)(e.textContent);return(0,n.createBlock)("jetpack/calendly",t)}}]},deprecated:[i.A]})},2668(e,t,r){"use strict";r.d(t,{A:()=>o});var n=r(94715),s=r(10790);function o(){const e=n.useBlockProps.save();return(0,s.jsx)("div",{...e,children:(0,s.jsx)(n.InnerBlocks.Content,{})})}},38028(e,t,r){"use strict";r.d(t,{QL:()=>n,a9:()=>s});const n=/(^|\/\/)(calendly\.com[^"']*)/i,s=e=>{if(!e)return;const t=(e=>{const t=e.match(n);if(t)return"https://"+t[2]})(e);if(!t)return;const r=(e=>{const t={},r=new URL(e);if(t.url=r.origin+r.pathname,!r.search)return t;const n=new URLSearchParams(r.search),s=n.get("background_color"),o=n.get("primary_color"),i=n.get("text_color"),a=/^[A-Za-z0-9]{6}$/;return n.get("hide_event_type_details")&&(t.hideEventTypeDetails=n.get("hide_event_type_details")),s&&s.match(a)&&(t.backgroundColor=s),o&&o.match(a)&&(t.primaryColor=o),i&&i.match(a)&&(t.textColor=i),t})(t),s=(e=>e.indexOf("data-url")>0?"inline":e.indexOf("initPopupWidget")>0||e.indexOf("initBadgeWidget")>0?"link":void 0)(e);if(s&&(r.style=s),"link"===s){r.buttonAttributes={};const t=(e=>{let t=e.match(/false;">([^<]+)<\//);return t?t[1]:(t=e.match(/text: '([^']*?)'/),t?t[1]:void 0)})(e);t&&(r.buttonAttributes.text=t);const n=(e=>{const t=e.match(/textColor: '([^']*?)'/);if(t)return t[1]})(e);n&&(r.buttonAttributes.textColor=void 0,r.buttonAttributes.customTextColor=n);const s=(e=>{const t=e.match(/color: '([^']*?)'/);if(t)return t[1]})(e);s&&(r.buttonAttributes.backgroundColor=void 0,r.buttonAttributes.customBackgroundColor=s)}return r}},98091(e,t,r){"use strict";r.d(t,{A:()=>u});var n=r(94715),s=r(56427),o=r(86087),i=r(27723),a=r(13022),c=r(81942),l=r(10790);const __=i.__,u=e=>{const{attributes:{address:t,addressLine2:r,addressLine3:i,city:u,region:d,postal:p,country:h,linkToGoogleMaps:m},isSelected:g,setAttributes:f}=e,b=[t,r,i,u,d,p,h].some(e=>""!==e),v=(0,a.A)({"jetpack-address-block":!0,"is-selected":g}),y=(0,o.useCallback)(e=>{"Enter"===e.key&&e.preventDefault()},[]),k=(0,n.useBlockProps)({className:v}),_=(0,l.jsx)(s.ToggleControl,{__nextHasNoMarginBottom:!0,label:__("Link address to Google Maps","jetpack"),checked:m,onChange:e=>f({linkToGoogleMaps:e})});return(0,l.jsxs)("div",{...k,children:[!g&&b&&(0,c.A)(e),(g||!b)&&(0,l.jsxs)(o.Fragment,{children:[(0,l.jsx)(n.PlainText,{value:t,placeholder:__("Street Address","jetpack"),"aria-label":__("Street Address","jetpack"),onChange:e=>f({address:e}),onKeyDown:y}),(0,l.jsx)(n.PlainText,{value:r,placeholder:__("Address Line 2","jetpack"),"aria-label":__("Address Line 2","jetpack"),onChange:e=>f({addressLine2:e}),onKeyDown:y}),(0,l.jsx)(n.PlainText,{value:i,placeholder:__("Address Line 3","jetpack"),"aria-label":__("Address Line 3","jetpack"),onChange:e=>f({addressLine3:e}),onKeyDown:y}),(0,l.jsx)(n.PlainText,{value:u,placeholder:__("City","jetpack"),"aria-label":__("City","jetpack"),onChange:e=>f({city:e}),onKeyDown:y}),(0,l.jsx)(n.PlainText,{value:d,placeholder:__("State/Province/Region","jetpack"),"aria-label":__("State/Province/Region","jetpack"),onChange:e=>f({region:e}),onKeyDown:y}),(0,l.jsx)(n.PlainText,{value:p,placeholder:__("Postal/Zip Code","jetpack"),"aria-label":__("Postal/Zip Code","jetpack"),onChange:e=>f({postal:e}),onKeyDown:y}),(0,l.jsx)(n.PlainText,{value:h,placeholder:__("Country","jetpack"),"aria-label":__("Country","jetpack"),onChange:e=>f({country:e}),onKeyDown:y}),_]})]})}},39563(e,t,r){"use strict";r.d(t,{U:()=>u,W:()=>d});var n=r(56427),s=r(86087),o=r(27723),i=r(62289),a=r(98091),c=r(81942),l=r(10790);const __=o.__,_x=o._x,u="address",d={apiVersion:3,title:__("Address","jetpack"),description:__("Lets you add a physical address with Schema markup.","jetpack"),keywords:[_x("location","block search term","jetpack"),_x("direction","block search term","jetpack"),_x("place","block search term","jetpack")],icon:(0,i.A)((0,l.jsxs)(s.Fragment,{children:[(0,l.jsx)(n.Path,{d:"M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zM7 9c0-2.76 2.24-5 5-5s5 2.24 5 5c0 2.88-2.88 7.19-5 9.88C9.92 16.21 7 11.85 7 9z"}),(0,l.jsx)(n.Circle,{cx:"12",cy:"9",r:"2.5"})]})),category:"grow",attributes:{address:{type:"string",default:""},addressLine2:{type:"string",default:""},addressLine3:{type:"string",default:""},city:{type:"string",default:""},region:{type:"string",default:""},postal:{type:"string",default:""},country:{type:"string",default:""},linkToGoogleMaps:{type:"boolean",default:!1}},parent:["jetpack/contact-info"],edit:a.A,save:c.A}},81942(e,t,r){"use strict";r.d(t,{A:()=>l});var n=r(94715),s=r(86087),o=r(27723),i=r(10790);const __=o.__,a=({attributes:{address:e,addressLine2:t,addressLine3:r,city:n,region:o,postal:a,country:c}})=>(0,i.jsxs)(s.Fragment,{children:[e&&(0,i.jsx)("div",{className:"jetpack-address__address jetpack-address__address1",children:e}),t&&(0,i.jsx)("div",{className:"jetpack-address__address jetpack-address__address2",children:t}),r&&(0,i.jsx)("div",{className:"jetpack-address__address jetpack-address__address3",children:r}),n&&!(o||a)&&(0,i.jsx)("div",{className:"jetpack-address__city",children:n}),n&&(o||a)&&(0,i.jsxs)("div",{children:[(0,i.jsx)("span",{className:"jetpack-address__city",children:n}),", ",(0,i.jsx)("span",{className:"jetpack-address__region",children:o})," ",(0,i.jsx)("span",{className:"jetpack-address__postal",children:a})]}),!n&&(o||a)&&(0,i.jsxs)("div",{children:[(0,i.jsx)("span",{className:"jetpack-address__region",children:o})," ",(0,i.jsx)("span",{className:"jetpack-address__postal",children:a})]}),c&&(0,i.jsx)("div",{className:"jetpack-address__country",children:c})]}),c=({attributes:{address:e,addressLine2:t,addressLine3:r,city:n,region:s,postal:o,country:i}})=>{let a=s?`+${s},`:"";a=o?`${a}+${o}`:a;return`https://www.google.com/maps/search/${e?`${e},`:""}${t?`${t},`:""}${r?`${r},`:""}${n?`+${n},`:""}${a}${i?`+${i}`:""}`.replace(" ","+")},l=e=>{if(!(({address:e,addressLine2:t,addressLine3:r,city:n,region:s,postal:o,country:i})=>[e,t,r,n,s,o,i].some(e=>""!==e))(e.attributes))return null;const t=n.useBlockProps.save();return(0,i.jsxs)("div",{...t,children:[e.attributes.linkToGoogleMaps&&(0,i.jsx)("a",{href:c(e),target:"_blank",rel:"noopener noreferrer",title:__("Open address in Google Maps","jetpack"),children:(0,i.jsx)(a,{...e})}),!e.attributes.linkToGoogleMaps&&(0,i.jsx)(a,{...e})]})}},44246(e,t,r){"use strict";r.d(t,{A:()=>c});var n=r(94715),s=r(13022),o=r(10790);const i=["jetpack/markdown","jetpack/address","jetpack/email","jetpack/phone","jetpack/map","jetpack/business-hours","core/paragraph","core/image","core/heading","core/gallery","core/list","core/quote","core/shortcode","core/audio","core/code","core/cover","core/html","core/separator","core/spacer","core/subhead","core/video"],a=[["jetpack/email"],["jetpack/phone"],["jetpack/address"]],c=e=>{const{className:t,isSelected:r}=e,c=(0,n.useBlockProps)({className:(0,s.A)(t,{"jetpack-contact-info-block":!0,"is-selected":r})});return(0,o.jsx)("div",{...c,children:(0,o.jsx)(n.InnerBlocks,{allowedBlocks:i,templateLock:!1,template:a})})}},25907(e,t,r){"use strict";var n=r(74997),s=r(94375),o=r(39563),i=r(75173),a=r(44246),c=r(90951),l=r(70063),u=r(36611);r(47698),r(83572);(0,s.M)(i,{edit:a.A,save:u.A,transforms:{from:[{type:"block",blocks:["core/legacy-widget"],isMatch:({idBase:e,instance:t})=>!!t?.raw&&"widget_contact_info"===e,transform:({instance:e})=>{let t=[(0,n.createBlock)("core/heading",{content:e.raw.title}),(0,n.createBlock)("jetpack/email",{email:e.raw.email}),(0,n.createBlock)("jetpack/phone",{phone:e.raw.phone}),(0,n.createBlock)("jetpack/address",{address:e.raw.address})];return e.raw.hours&&(t=[...t,(0,n.createBlock)("core/paragraph",{content:e.raw.hours})]),e.raw.showmap&&e.raw.address&&(t=[...t,(0,n.createBlock)("jetpack/map",{address:e.raw.address})]),(0,n.createBlock)("jetpack/contact-info",{},t)}}]}},[{name:o.U,settings:o.W},{name:c.U,settings:c.W},{name:l.U,settings:l.W}])},43167(e,t,r){"use strict";r.d(t,{A:()=>a});var n=r(94715),s=r(27723),o=r(64882),i=r(27266);const __=s.__,a=e=>{const t=(0,n.useBlockProps)(),{setAttributes:r}=e;return(0,o.A)("email",e,__("Email","jetpack"),i.A,e=>r({email:e}),t)}},90951(e,t,r){"use strict";r.d(t,{U:()=>l,W:()=>u});var n=r(56427),s=r(27723),o=r(62289),i=r(43167),a=r(27266),c=r(10790);const __=s.__,_x=s._x,l="email",u={apiVersion:3,title:__("Email Address","jetpack"),description:__("Lets you add an email address with an automatically generated click-to-email link.","jetpack"),keywords:["e-mail","email",_x("message","block search term","jetpack")],icon:(0,o.A)((0,c.jsx)(n.Path,{d:"M22 6c0-1.1-.9-2-2-2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6zm-2 0l-8 5-8-5h16zm0 12H4V8l8 5 8-5v10z"})),category:"grow",attributes:{email:{type:"string",default:""}},edit:i.A,save:a.A,parent:["jetpack/contact-info"]}},27266(e,t,r){"use strict";r.d(t,{A:()=>a});var n=r(94715),s=r(86087),o=r(39904),i=r(10790);const a=({attributes:{email:e}})=>{if(!e)return null;const t=n.useBlockProps.save();return(0,i.jsx)("div",{...t,children:(r=e,r.split(/(\s+)/).map((e,t)=>{const r=e.replace(/([.,/#!$%^&*;:{}=\-_`~()\][])+$/g,"");return e.indexOf("@")&&(0,o.t)(r)?e===r?(0,i.jsx)("a",{href:`mailto:${e}`,children:e},t):(0,i.jsxs)(s.Fragment,{children:[(0,i.jsx)("a",{href:`mailto:${e}`,children:r},t),(0,i.jsx)(s.Fragment,{children:e.slice(-(e.length-r.length))})]},t):(0,i.jsx)(s.Fragment,{children:e},t)}))});var r}},42711(e,t,r){"use strict";r.d(t,{A:()=>a});var n=r(94715),s=r(27723),o=r(64882),i=r(84330);const __=s.__,a=e=>{const t=(0,n.useBlockProps)(),{setAttributes:r}=e;return(0,o.A)("phone",e,__("Phone number","jetpack"),i.A,e=>r({phone:e}),t)}},70063(e,t,r){"use strict";r.d(t,{U:()=>l,W:()=>u});var n=r(56427),s=r(27723),o=r(62289),i=r(42711),a=r(84330),c=r(10790);const __=s.__,_x=s._x,l="phone",u={apiVersion:3,title:__("Phone Number","jetpack"),description:__("Lets you add a phone number with an automatically generated click-to-call link.","jetpack"),keywords:[_x("mobile","block search term","jetpack"),_x("telephone","block search term","jetpack"),_x("cell","block search term","jetpack")],icon:(0,o.A)((0,c.jsx)(n.Path,{d:"M6.54 5c.06.89.21 1.76.45 2.59l-1.2 1.2c-.41-1.2-.67-2.47-.76-3.79h1.51m9.86 12.02c.85.24 1.72.39 2.6.45v1.49c-1.32-.09-2.59-.35-3.8-.75l1.2-1.19M7.5 3H4c-.55 0-1 .45-1 1 0 9.39 7.61 17 17 17 .55 0 1-.45 1-1v-3.49c0-.55-.45-1-1-1-1.24 0-2.45-.2-3.57-.57-.1-.04-.21-.05-.31-.05-.26 0-.51.1-.71.29l-2.2 2.2c-2.83-1.45-5.15-3.76-6.59-6.59l2.2-2.2c.28-.28.36-.67.25-1.02C8.7 6.45 8.5 5.25 8.5 4c0-.55-.45-1-1-1z"})),category:"grow",attributes:{phone:{type:"string",default:""}},parent:["jetpack/contact-info"],edit:i.A,save:a.A}},84330(e,t,r){"use strict";r.d(t,{A:()=>i});var n=r(94715),s=r(10790);function o(e){const t=e.match(/\d+\.\d+|\d+\b|\d+(?=\w)/g);if(!t)return e;const r=e.indexOf(t[0]);let n=r?e.substring(r-1):e,o=r?e.substring(0,r):"",i=n.replace(/\D/g,"");/[0-9/+/(]/.test(n[0])?(o=o.slice(0,-1),"+"===n[0]&&(i="+"+i)):n=n.substring(1);return[o.trim()?(0,s.jsx)("span",{className:"phone-prefix",children:o},"phonePrefix"):null,(0,s.jsx)("a",{href:`tel:${i}`,children:n},"phoneNumber")]}const i=({attributes:{phone:e}})=>{if(!e)return null;const t=n.useBlockProps.save();return(0,s.jsx)("div",{...t,children:o(e)})}},36611(e,t,r){"use strict";r.d(t,{A:()=>o});var n=r(94715),s=r(10790);const o=()=>{const e=n.useBlockProps.save();return(0,s.jsx)("div",{...e,children:(0,s.jsx)(n.InnerBlocks.Content,{})})}},75800(e,t,r){"use strict";r.d(t,{A:()=>u});var n=r(4567),s=r(3975),o=r(94715),i=r(86087),a=r(13022),c=r(72730),l=r(10790);const u=({className:e=null,currency:t=null,defaultValue:r=null,disabled:u=!1,label:d="",onChange:p=null,value:h=""})=>{const[m,g]=(0,i.useState)((0,n.Ay)(h,t,{symbol:""})),[f,b]=(0,i.useState)(!1),[v,y]=(0,i.useState)(!1),k=(0,i.useRef)(null),_=(0,i.useCallback)((e,r)=>{g(n=>{if(e!==n){const n=(0,c.C_)(e,t);n&&n>=(0,c.dv)(t)?(y(!1),r&&p?.(n)):y(!0)}return e})},[t,p]),x=()=>{k.current&&(k.current.focus(),b(!0))};return(0,i.useEffect)(()=>{if(!k.current)return;const e=k.current,s=()=>{b(!1),m||_((0,n.Ay)(r,t,{symbol:""}))};return e.addEventListener("blur",s),()=>{e.removeEventListener("blur",s)}},[t,r,m,k,_]),(0,i.useEffect)(()=>{f||v||g((0,n.Ay)(h,t,{symbol:""}))},[t,f,v,h]),(0,i.useEffect)(()=>{_((0,n.Ay)(h,t,{symbol:""}))},[t,h]),(0,l.jsxs)("div",{className:(0,a.A)("donations__amount",e,{"has-focus":f,"has-error":v}),role:"button",tabIndex:0,onClick:x,onKeyDown:x,children:[s.y[t].symbol,u?(0,l.jsx)("div",{className:"donations__amount-value",children:(0,n.Ay)(h||r,t,{symbol:""})}):(0,l.jsx)(o.RichText,{allowedFormats:[],"aria-label":d,onChange:e=>_(e,!0),placeholder:(0,n.Ay)(r,t,{symbol:""}),ref:k,value:m,withoutInteractiveFormatting:!0})]})}},57018(e,t,r){"use strict";r.d(t,{A:()=>d});var n=r(3975),s=r(85985),o=r(94715),i=r(56427),a=r(27723),c=r(48558),l=r(72730),u=r(10790);const __=a.__,d=e=>{const{attributes:t,setAttributes:r}=e,{currency:a,oneTimeDonation:d,monthlyDonation:p,annualDonation:h,showCustomAmount:m}=t,g=(e,n)=>{const s={"1 month":"monthlyDonation","1 year":"annualDonation"}[e],o=t[s];r({[s]:{...o,show:n}})};return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(o.BlockControls,{children:(0,u.jsx)(i.ToolbarGroup,{children:(0,u.jsx)(i.ToolbarItem,{children:()=>(0,u.jsx)(i.Dropdown,{contentClassName:"jetpack-donations__currency-popover",renderToggle:({onToggle:e,isOpen:t})=>(0,u.jsx)(i.ToolbarButton,{className:"jetpack-donations__currency-toggle",icon:(0,u.jsxs)(u.Fragment,{children:[a+" - "+n.y[a].symbol,(0,u.jsx)(i.Dashicon,{icon:"arrow-down"})]}),label:__("Change currency","jetpack"),onClick:e,onKeyDown:r=>{t||r.keyCode!==c.DOWN||(r.preventDefault(),r.stopPropagation(),e())}}),renderContent:({onClose:e})=>(0,u.jsx)(i.MenuGroup,{children:Object.keys(l.VK).map(t=>(0,u.jsx)(i.MenuItem,{isSelected:t===a,icon:t===a?"yes":"",onClick:()=>{(e=>{const t=(0,l.Xj)(e);r({currency:e,oneTimeDonation:{...d,amounts:t},monthlyDonation:{...p,amounts:t},annualDonation:{...h,amounts:t}})})(t),e()},children:t+" - "+n.y[t].symbol},`jetpack-donations-currency-${t}`))})})})})}),(0,u.jsx)(o.InspectorControls,{children:(0,u.jsxs)(i.PanelBody,{title:__("Settings","jetpack"),children:[(0,u.jsx)(i.ToggleControl,{checked:p.show,onChange:e=>g("1 month",e),label:__("Show monthly donations","jetpack"),__nextHasNoMarginBottom:!0}),(0,u.jsx)(i.ToggleControl,{checked:h.show,onChange:e=>g("1 year",e),label:__("Show annual donations","jetpack"),__nextHasNoMarginBottom:!0}),(0,u.jsx)(i.ToggleControl,{checked:m,onChange:e=>r({showCustomAmount:e}),label:__("Show custom amount option","jetpack"),__nextHasNoMarginBottom:!0}),(0,u.jsx)(i.ExternalLink,{href:`https://wordpress.com/earn/payments/${(0,s.GE)()}`,children:__("View donation earnings","jetpack")})]})})]})}},27718(e,t,r){"use strict";r.d(t,{A:()=>l});var n=r(4567),s=r(3975),o=r(94715),i=r(27723),a=r(72730),c=r(10790);const __=i.__,l={attributes:{currency:{type:"string",default:"USD"},oneTimeDonation:{type:"object",default:{show:!0,planId:null,amounts:[5,15,100],heading:__("Make a one-time donation","jetpack"),extraText:__("Your contribution is appreciated.","jetpack"),buttonText:__("Donate","jetpack")}},monthlyDonation:{type:"object",default:{show:!0,planId:null,amounts:[5,15,100],heading:__("Make a monthly donation","jetpack"),extraText:__("Your contribution is appreciated.","jetpack"),buttonText:__("Donate monthly","jetpack")}},annualDonation:{type:"object",default:{show:!0,planId:null,amounts:[5,15,100],heading:__("Make a yearly donation","jetpack"),extraText:__("Your contribution is appreciated.","jetpack"),buttonText:__("Donate yearly","jetpack")}},showCustomAmount:{type:"boolean",default:!0},chooseAmountText:{type:"string",default:__("Choose an amount","jetpack")},customAmountText:{type:"string",default:__("Or enter a custom amount","jetpack")}},supports:{html:!1},save:({attributes:e})=>{const{currency:t,oneTimeDonation:r,monthlyDonation:i,annualDonation:l,showCustomAmount:u,chooseAmountText:d,customAmountText:p}=e;if(!r||!r.show||-1===r.planId)return null;const h={"one-time":{title:__("One-Time","jetpack")},...i.show&&{"1 month":{title:__("Monthly","jetpack")}},...l.show&&{"1 year":{title:__("Yearly","jetpack")}}};return(0,c.jsx)("div",{children:(0,c.jsxs)("div",{className:"donations__container",children:[Object.keys(h).length>1&&(0,c.jsx)("div",{className:"donations__nav",children:Object.entries(h).map(([e,{title:t}])=>(0,c.jsx)("div",{role:"button",tabIndex:0,className:"donations__nav-item","data-interval":e,children:t},`jetpack-donations-nav-item-${e} `))}),(0,c.jsx)("div",{className:"donations__content",children:(0,c.jsxs)("div",{className:"donations__tab",children:[(0,c.jsx)(o.RichText.Content,{tagName:"h4",className:"donations__one-time-item",value:r.heading}),i.show&&(0,c.jsx)(o.RichText.Content,{tagName:"h4",className:"donations__monthly-item",value:i.heading}),l.show&&(0,c.jsx)(o.RichText.Content,{tagName:"h4",className:"donations__annual-item",value:l.heading}),(0,c.jsx)(o.RichText.Content,{tagName:"p",value:d}),(0,c.jsx)("div",{className:"donations__amounts donations__one-time-item",children:r.amounts.map(e=>(0,c.jsx)("div",{className:"donations__amount","data-amount":e,children:(0,n.Ay)(e,t)},e))}),i.show&&(0,c.jsx)("div",{className:"donations__amounts donations__monthly-item",children:i.amounts.map(e=>(0,c.jsx)("div",{className:"donations__amount","data-amount":e,children:(0,n.Ay)(e,t)},e))}),l.show&&(0,c.jsx)("div",{className:"donations__amounts donations__annual-item",children:l.amounts.map(e=>(0,c.jsx)("div",{className:"donations__amount","data-amount":e,children:(0,n.Ay)(e,t)},e))}),u&&(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(o.RichText.Content,{tagName:"p",value:p}),(0,c.jsxs)("div",{className:"donations__amount donations__custom-amount",children:[s.y[t].symbol,(0,c.jsx)("div",{className:"donations__amount-value","data-currency":t,"data-empty-text":(0,n.Ay)(100*(0,a.dv)(t),t,{symbol:""})})]})]}),(0,c.jsx)("div",{className:"donations__separator",children:"——"}),(0,c.jsx)(o.RichText.Content,{tagName:"p",className:"donations__one-time-item",value:r.extraText}),i.show&&(0,c.jsx)(o.RichText.Content,{tagName:"p",className:"donations__monthly-item",value:i.extraText}),l.show&&(0,c.jsx)(o.RichText.Content,{tagName:"p",className:"donations__annual-item",value:l.extraText}),(0,c.jsx)("div",{className:"wp-block-button donations__donate-button-wrapper donations__one-time-item",children:(0,c.jsx)(o.RichText.Content,{tagName:"a",className:"wp-block-button__link donations__donate-button donations__one-time-item",value:r.buttonText})}),i.show&&(0,c.jsx)("div",{className:"wp-block-button donations__donate-button-wrapper donations__monthly-item",children:(0,c.jsx)(o.RichText.Content,{tagName:"a",className:"wp-block-button__link donations__donate-button donations__monthly-item",value:i.buttonText})}),l.show&&(0,c.jsx)("div",{className:"wp-block-button donations__donate-button-wrapper donations__annual-item",children:(0,c.jsx)(o.RichText.Content,{tagName:"a",className:"wp-block-button__link donations__donate-button donations__annual-item",value:l.buttonText})})]})})]})})}}},31152(e,t,r){"use strict";r.d(t,{A:()=>_});var n=r(94715),s=r(56427),o=r(47143),i=r(86087),a=r(27723),c=r(2274),l=r(53796),u=r(72730),d=r(27574),p=r(26247),h=r(16521),m=r(3696),g=r(70975),f=r(93033),b=r(56848),v=(r(3749),r(79085)),y=r(36580),k=r(10790);const __=a.__,_=e=>{const{attributes:t,setAttributes:r}=e,{currency:a}=t,_=(0,n.useBlockProps)(),[x,w]=(0,i.useState)(""),[j,A]=(0,i.useState)([]),[C,S]=(0,i.useState)(!1),E=(0,p.A)(),{lockPostSaving:T,unlockPostSaving:N}=(0,o.useDispatch)("core/editor"),{getEntityRecord:P,getCurrentUser:R}=(0,o.useSelect)("core"),{editEntityRecord:L,saveEditedEntityRecord:D}=(0,o.useDispatch)("core"),I=(0,o.useSelect)(e=>e("core/editor").getCurrentPost(),[]),B=(0,o.useSelect)(e=>e("core/editor").isPostSavingLocked(),[]),F=(0,o.useSelect)(e=>e(h.M).getConnectUrl()||"",[]),{setConnectUrl:M,setConnectedAccountDefaultCurrency:U}=(0,o.useDispatch)(m.EF),O=(0,o.useSelect)(e=>e(m.EF).getConnectedAccountDefaultCurrency());(0,i.useEffect)(()=>{if(!a&&O&&!B){const e=O.toUpperCase(),t=!!u.VK[e];r(t?{currency:e}:{currency:"USD"})}},[a,O,B,r]);const z=e=>{w(e)},q=R();(0,i.useEffect)(()=>{q?.id&&P("root","user",q.id)},[q?.id,P]);const $=q?.meta?.jetpack_donation_warning_dismissed||!1;let H;(0,i.useEffect)(()=>{q?.id&&!1===$&&S(!0)},[q,$]),(0,i.useEffect)(()=>{T("donations");const e=e=>e.reduce((e,{id:t,currency:r,type:n,interval:s})=>(r===a&&"donation"===n&&(e[s]=t),e),{});(0,f.A)("donation").then(t=>{if(!t&&"object"!=typeof t||t.errors)return N("donations"),void w(__("Could not load data from WordPress.com.","jetpack"));M((0,d.A)(I.id,t.connect_url)),U(t?.connected_account_default_currency?.toUpperCase());const r=e(t.products);return(e=>{const t=Object.keys(e);return t.includes("one-time")&&t.includes("1 month")&&t.includes("1 year")})(r)?(A(r),void N("donations")):t.connect_url?(A({"one-time":-1,"1 month":-1,"1 year":-1}),void N("donations")):(a&&(0,g.A)(a).then(t=>{A(e(t)),N("donations")},z),void N("donations"))},z)},[T,a,I.id,M,U,N]),H=E?x?(0,k.jsx)(v.A,{error:x}):F?(0,k.jsx)(l.V,{blockName:"donations"}):a?(0,k.jsx)(y.A,{...e,products:j}):(0,k.jsx)(s.Spinner,{}):(0,k.jsx)(c.A,{block:"Donations Form",explanation:__("Connect your WordPress.com account to enable donations.","jetpack")});return(0,k.jsxs)("div",{..._,children:[H,C&&(0,k.jsx)(b.A,{onClose:async()=>{if(S(!1),q?.id)try{await L("root","user",q.id,{meta:{jetpack_donation_warning_dismissed:!0}}),await D("root","user",q.id)}catch(e){console.error("Failed to update user meta:",e)}else console.error("Cannot update user meta: User not loaded")}})]})}},46197(e,t,r){"use strict";var n=r(94375),s=r(87325),o=r(27718),i=r(31152),a=r(47693);r(46236);(0,n.M)(s,{edit:i.A,save:a.A,deprecated:[o.A]})},70975(e,t,r){"use strict";r.d(t,{A:()=>o});var n=r(1455),s=r.n(n);const o=async e=>{try{return await s()({path:"/wpcom/v2/memberships/products",method:"POST",data:{type:"donation",currency:e,is_editable:!1}})}catch(e){return Promise.reject(e.message)}}},93033(e,t,r){"use strict";r.d(t,{A:()=>i});var n=r(1455),s=r.n(n),o=r(93832);const i=async(e=null)=>{const t=new URLSearchParams(window.location.search),r=(0,o.addQueryArgs)("/wpcom/v2/memberships/status",{source:"https://wordpress.com"===t.get("origin")?"gutenberg-wpcom":"gutenberg",...e&&{type:e},is_editable:!1});try{return await s()({path:r,method:"GET"})}catch(e){return Promise.reject(e.message)}}},56848(e,t,r){"use strict";r.d(t,{A:()=>l});var n=r(3924),s=r(97999),o=r(56427),i=r(86087),a=r(27723),c=r(10790);const __=a.__,l=({onClose:e})=>{const t=(0,s.isWpcomPlatformSite)()?"wpcom-support-donation-block":"jetpack-support-donation-block";return(0,c.jsx)(o.Modal,{className:"jetpack-donations-first-time-modal",onRequestClose:e,title:__("Accept Donations with Stripe","jetpack"),children:(0,c.jsxs)("div",{className:"jetpack-donations-first-time-modal__content",children:[(0,c.jsx)("p",{children:(0,i.createInterpolateElement)(__("To accept donations on your site, you'll need to connect your Stripe account. Here's what you need to do: Learn more about donations.","jetpack"),{docLink:(0,c.jsx)(o.ExternalLink,{href:(0,n.A)(t)})})}),(0,c.jsxs)("ol",{children:[(0,c.jsx)("li",{children:__("Connect your Stripe account to your WordPress.com account","jetpack")}),(0,c.jsx)("li",{children:__("Set up your business information in Stripe","jetpack")}),(0,c.jsx)("li",{children:__("Configure your payment settings and supported currencies","jetpack")})]}),(0,c.jsx)("p",{children:__("Once connected, you can customize your donation form and start accepting payments.","jetpack")}),(0,c.jsx)("p",{children:(0,i.createInterpolateElement)(__("Please note that accepting donations has additional requirements from Stripe. Learn more about requirements for accepting donations.","jetpack"),{requirementsLink:(0,c.jsx)(o.ExternalLink,{href:(0,n.A)("jetpack-support-donation-block-stripe-reqs")})})}),(0,c.jsx)("div",{className:"jetpack-donations-first-time-modal__actions",children:(0,c.jsx)(o.Button,{variant:"primary",onClick:e,children:__("Got it","jetpack")})})]})})}},79085(e,t,r){"use strict";r.d(t,{A:()=>i});var n=r(56427),s=r(27723),o=r(10790);const __=s.__,i=({error:e})=>(0,o.jsx)(n.Placeholder,{icon:"lock",label:__("Donations","jetpack"),instructions:e})},47693(e,t,r){"use strict";r.d(t,{A:()=>a});var n=r(94715),s=r(75703),o=r(10790);const i=(0,s.O)(),a=({attributes:e})=>{const{fallbackLinkUrl:t,oneTimeDonation:r,monthlyDonation:s,annualDonation:a}=e;if(!r||!r.show||!r.planId||-1===r.planId)return null;const c=n.useBlockProps.save();return(0,o.jsxs)("div",{...c,children:[(0,o.jsx)(n.RichText.Content,{tagName:"h4",value:i.oneTimeDonation?.heading}),(0,o.jsx)(n.RichText.Content,{tagName:"p",value:r.extraText??i.extraText}),(0,o.jsx)(n.RichText.Content,{tagName:"a",className:"jetpack-donations-fallback-link",href:t,rel:"noopener noreferrer noamphtml",target:"_blank",value:i.oneTimeDonation?.buttonText}),s.show&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("hr",{className:"donations__separator"}),(0,o.jsx)(n.RichText.Content,{tagName:"h4",value:i.monthlyDonation?.heading}),(0,o.jsx)(n.RichText.Content,{tagName:"p",value:s.extraText??i.extraText}),(0,o.jsx)(n.RichText.Content,{tagName:"a",className:"jetpack-donations-fallback-link",href:t,rel:"noopener noreferrer noamphtml",target:"_blank",value:i.monthlyDonation?.buttonText})]}),a.show&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("hr",{className:"donations__separator"}),(0,o.jsx)(n.RichText.Content,{tagName:"h4",value:i.annualDonation?.heading}),(0,o.jsx)(n.RichText.Content,{tagName:"p",value:a.extraText??i.extraText}),(0,o.jsx)(n.RichText.Content,{tagName:"a",className:"jetpack-donations-fallback-link",href:t,rel:"noopener noreferrer noamphtml",target:"_blank",value:i.annualDonation?.buttonText})]})]})}},62225(e,t,r){"use strict";r.d(t,{A:()=>d});var n=r(94715),s=r(47143),o=r(27723),i=r(72730),a=r(75800),c=r(75703),l=r(10790);const __=o.__,u=(0,c.O)(),d=({activeTab:e,attributes:t,setAttributes:r})=>{const{currency:c,oneTimeDonation:d,monthlyDonation:p,annualDonation:h,showCustomAmount:m,chooseAmountText:g=u.chooseAmountText,customAmountText:f=u.customAmountText}=t,b={"one-time":"oneTimeDonation","1 month":"monthlyDonation","1 year":"annualDonation"}[e],v=e=>t[b][e],y=(e,n)=>{const s=t[b];r({[b]:{...s,[e]:n}})},k=(0,i.Xj)(c),_=v("amounts"),x=(0,s.useSelect)(e=>e("core/rich-text").getFormatTypes(),[]).map(e=>e.name).filter(e=>"core/link"!==e);return(0,l.jsxs)("div",{className:"donations__tab",children:[(0,l.jsx)(n.RichText,{tagName:"h4",placeholder:__("Write a message…","jetpack"),value:v("heading")||u[b]?.heading,onChange:e=>y("heading",e)}),(0,l.jsx)(n.RichText,{tagName:"p",placeholder:__("Write a message…","jetpack"),value:g,onChange:e=>r({chooseAmountText:e})}),(0,l.jsx)("div",{className:"donations__amounts",children:_.map((e,t)=>(0,l.jsx)(a.A,{currency:c,defaultValue:k[t],label:(0,o.sprintf)( // translators: %d: Tier level e.g: "1", "2", "3" __("Tier %d","jetpack"),t+1),onChange:e=>((e,t)=>{const r=[..._];r[t]=e,y("amounts",r)})(e,t),value:e},`jetpack-donations-amount-${t}`))}),m&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(n.RichText,{tagName:"p",placeholder:__("Write a message…","jetpack"),value:f,onChange:e=>r({customAmountText:e})}),(0,l.jsx)(a.A,{currency:c,label:__("Custom amount","jetpack"),defaultValue:100*(0,i.dv)(c),className:"donations__custom-amount",disabled:!0})]}),(0,l.jsx)("hr",{className:"donations__separator"}),(0,l.jsx)(n.RichText,{tagName:"p",placeholder:__("Write a message…","jetpack"),value:v("extraText")??u.extraText,onChange:e=>y("extraText",e)}),(0,l.jsx)("div",{className:"wp-block-button donations__donate-button-wrapper",children:(0,l.jsx)(n.RichText,{className:"wp-block-button__link donations__donate-button",placeholder:__("Write a message…","jetpack"),value:v("buttonText")||u[b]?.buttonText,onChange:e=>{return t=e,void r({oneTimeDonation:{...d,buttonText:t},monthlyDonation:{...p,buttonText:t},annualDonation:{...h,buttonText:t}});var t},allowedFormats:x})})]})}},36580(e,t,r){"use strict";r.d(t,{A:()=>l});var n=r(86087),s=r(27723),o=r(13022),i=r(57018),a=r(62225),c=r(10790);const __=s.__,l=e=>{const{attributes:t,products:r,setAttributes:s}=e,{oneTimeDonation:l,monthlyDonation:u,annualDonation:d}=t,[p,h]=(0,n.useState)("one-time"),m=(0,n.useCallback)(e=>p===e,[p]),g={"one-time":{title:__("One-Time","jetpack")},...u.show&&{"1 month":{title:__("Monthly","jetpack")}},...d.show&&{"1 year":{title:__("Yearly","jetpack")}}};return(0,n.useEffect)(()=>{l.planId===r["one-time"]&&u.planId===r["1 month"]&&d.planId===r["1 year"]||s({...r["one-time"]&&{oneTimeDonation:{...l,planId:r["one-time"]}},...r["1 month"]&&{monthlyDonation:{...u,planId:r["1 month"]}},...r["1 year"]&&{annualDonation:{...d,planId:r["1 year"]}}})},[l,u,d,s,r]),(0,n.useEffect)(()=>{!u.show&&m("1 month")&&h("one-time"),!d.show&&m("1 year")&&h("one-time")},[u,d,h,m]),(0,c.jsxs)(c.Fragment,{children:[(0,c.jsxs)("div",{className:"donations__container",children:[Object.keys(g).length>1&&(0,c.jsx)("div",{className:"donations__nav",children:Object.entries(g).map(([e,{title:t}])=>(0,c.jsx)("div",{role:"button",tabIndex:0,className:(0,o.A)("donations__nav-item",{"is-active":m(e)}),onClick:()=>h(e),onKeyDown:()=>h(e),children:t},`jetpack-donations-nav-item-${e} `))}),(0,c.jsx)("div",{className:"donations__content",children:(0,c.jsx)(a.A,{activeTab:p,attributes:t,setAttributes:s})})]}),(0,c.jsx)(i.A,{...e})]})}},75703(e,t,r){"use strict";function n(){if("undefined"==typeof window)return{};const e=window.Jetpack_DonationsBlock?.defaultTexts;return"object"!=typeof e?{}:e}r.d(t,{O:()=>n})},36850(e,t,r){"use strict";r.d(t,{GY:()=>s,_t:()=>n,gQ:()=>o});const n=/^\s*https?:\/\/(?:www\.)?(?:eventbrite\.[a-z.]+)\/e\/[^/]*?(\d+)\/?(?:\?[^/]*)?\s*$/i,s=/^\s*https?:\/\/(?:.+\.)?(?:eventbrite\.[a-z.]+)\/?(?:\?[^/]*)?\s*$/i,o="https://www.eventbrite.com/e/test-event-tickets-123456789"},38449(e,t,r){"use strict";r.d(t,{o:()=>l,s:()=>u});var n=r(56427),s=r(27723),o=r(5873),i=r(72660),a=r(10790);const __=s.__,_x=s._x,c=[{value:"inline",label:__("In-page Embed","jetpack"),preview:(0,a.jsx)("div",{className:"block-editor-block-preview__container",children:(0,a.jsx)("img",{src:i,alt:__("In page Eventbrite checkout example","jetpack")})})},{value:"modal",label:__("Button & Modal","jetpack")}],l=({setEditingUrl:e})=>(0,a.jsx)(n.ToolbarGroup,{children:(0,a.jsx)(n.ToolbarButton,{className:"components-toolbar__control",label:__("Edit URL","jetpack"),icon:"edit",onClick:()=>e(!0)})}),u=({attributes:e,clientId:t,setAttributes:r})=>(0,a.jsx)(o.A,{title:_x("Embed Type","option for how the embed displays on a page, e.g. inline or as a modal","jetpack"),clientId:t,styleOptions:c,onSelectStyle:r,activeStyle:e.style,attributes:e,viewportWidth:130})},77629(e,t,r){"use strict";r.d(t,{A:()=>n});const n=[r(87879).A]},87879(e,t,r){"use strict";r.d(t,{A:()=>u});var n=r(94715),s=r(74997),o=r(27723),i=r(13022),a=r(66087),c=r(10790);const _x=o._x,l=["text","backgroundColor","textColor","customBackgroundColor","customTextColor","borderRadius"];const u={attributes:{url:{type:"string",validator:e=>!e||e.startsWith("http")},eventId:{type:"number"},useModal:{type:"boolean"},style:{type:"string"},text:{type:"string",default:_x("Register","verb: e.g. register for an event.","jetpack")},backgroundColor:{type:"string"},textColor:{type:"string"},customBackgroundColor:{type:"string"},customTextColor:{type:"string"},borderRadius:{type:"number"}},migrate:e=>{const{className:t,style:r}=e;let n=r;n||(n=e.useModal?"modal":"inline");const o={...Object.fromEntries(Object.entries(e).filter(([e])=>"useModal"!==e&&!l.includes(e))),className:t&&t.replace("is-style-outline",""),style:n},i=(0,a.pick)(e,l);return[o,[(0,s.createBlock)("jetpack/button",{element:"a",text:i.text||_x("Register","verb: e.g. register for an event.","jetpack"),...i,uniqueId:"eventbrite-widget-id",className:t&&-1!==t.indexOf("is-style-outline")?"is-style-outline":""})]]},save:function({attributes:e}){const{eventId:t,useModal:r,url:s,style:o}=e;if(t)return r||"modal"===o?function(e){const{backgroundColor:t,borderRadius:r,customBackgroundColor:s,customTextColor:o,eventId:a,text:l,textColor:u,url:d}=e,p=(0,n.getColorClassName)("color",u),h=(0,n.getColorClassName)("background-color",t),m=(0,i.A)("wp-block-button__link",{"has-text-color":u||o,[p]:p,"has-background":t||s,[h]:h,"no-border-radius":0===r}),g={backgroundColor:h?void 0:s,color:p?void 0:o,borderRadius:r?r+"px":void 0};return(0,c.jsx)("div",{className:"wp-block-button",children:(0,c.jsx)(n.RichText.Content,{className:m,href:d,id:`eventbrite-widget-${a}`,rel:"noopener noreferrer",role:"button",style:g,tagName:"a",target:"_blank",value:l})})}(e):s&&(0,c.jsx)("a",{className:"eventbrite__direct-link",href:s,children:s})},isEligible:(e,t)=>("modal"===e.style||e.useModal)&&((0,a.isEmpty)(t)||Object.entries(e).some(([e,t])=>t&&l.includes(e)))}},56311(e,t,r){"use strict";r.d(t,{A:()=>v});var n=r(94715),s=r(56427),o=r(86087),i=r(27723),a=r(78218),c=r(56145),l=r(82306),u=r(36850),d=r(38449),p=r(50013),h=r(68332),m=r(72055),g=r(12074),f=(r(81699),r(10790));const __=i.__,_x=i._x,b={name:"jetpack/button",attributes:{element:"a",text:_x("Register","verb: e.g. register for an event.","jetpack"),uniqueId:"eventbrite-widget-id"}},v=(0,s.withNotices)(e=>{const{attributes:t,noticeOperations:r,onReplace:i,setAttributes:v}=e,{url:y,style:k}=t,_=(0,n.useBlockProps)(),[x,w]=(0,o.useState)(!1),[j,A]=(0,o.useState)(t.url||""),[C,S]=(0,o.useState)(!1),E=!C&&y&&!u._t.test(y),T=(0,o.useCallback)(()=>{r.removeAllNotices(),r.createErrorNotice((0,f.jsxs)(f.Fragment,{children:[__("Sorry, this content could not be embedded.","jetpack")," ",(0,f.jsx)(s.Button,{variant:"link",onClick:()=>(0,g.pG)(j,i),children:_x("Convert block to link","button label","jetpack")})]}))},[r,i,j]),N=(0,o.useCallback)(e=>{if(!e||u.gQ===e||"modal"===k)return;const t=(0,g.HE)(e);if(t){const n={eventId:t,url:e};(0,c.A)(n.url,S).then(e=>{const t=(0,a.y)(l.attributes,{...n,url:e});v(t),A(e),r.removeAllNotices()}).catch(()=>{v({eventId:void 0,url:void 0}),T()})}else T()},[k,r,T,v,A,S]);let P;return(0,o.useEffect)(()=>{N(y)},[y,N]),P=C?(0,f.jsx)(h.A,{}):x||!y||E?(0,f.jsx)(p.A,{...e,editedUrl:j,onChange:e=>A(e.target.value),onSubmit:e=>{e&&e.preventDefault(),N((0,g.pJ)(j)),w(!1)}}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(d.s,{...e}),(0,f.jsx)(n.BlockControls,{children:(0,f.jsx)(d.o,{setEditingUrl:w})}),"modal"===k?(0,f.jsx)(n.InnerBlocks,{template:[[b.name,b.attributes]],templateLock:"all"}):(0,f.jsx)(m.A,{...e})]}),(0,f.jsx)("div",{..._,children:P})})},34590(e,t,r){"use strict";var n=r(74997),s=r(94375),o=r(82306),i=r(36850),a=r(77629),c=r(56311),l=r(52074);(0,s.M)(o,{edit:c.A,save:l.A,transforms:{from:[{type:"raw",isMatch:e=>"P"===e.nodeName&&(i._t.test(e.textContent)||i.GY.test(e.textContent)),transform:e=>(0,n.createBlock)("jetpack/eventbrite",{url:e.textContent.trim()})}]},deprecated:a.A})},50013(e,t,r){"use strict";r.d(t,{A:()=>u});var n=r(97999),s=r(85985),o=r(56427),i=r(27723),a=r(82306),c=(r(12074),r(10790));const __=i.__,_x=i._x,l=(0,s.sh)(a),u=({className:e,noticeUI:t,editedUrl:r,onChange:s,onSubmit:i})=>{const a=(0,n.isWpcomPlatformSite)()?"http://support.wordpress.com/wordpress-editor/blocks/eventbrite-block/":"https://jetpack.com/support/jetpack-blocks/eventbrite-block/";return(0,c.jsx)("div",{className:e,children:(0,c.jsxs)(o.Placeholder,{label:__("Eventbrite Checkout","jetpack"),instructions:__("Paste a link to an Eventbrite event to embed ticket checkout.","jetpack"),icon:l,notices:t,children:[(0,c.jsxs)("form",{onSubmit:i,children:[(0,c.jsx)("input",{type:"url",value:r,className:"components-placeholder__input","aria-label":__("Eventbrite URL","jetpack"),placeholder:__("Enter an event URL to embed here…","jetpack"),onChange:s}),(0,c.jsx)(o.Button,{variant:"secondary",type:"submit",children:_x("Embed","submit button label","jetpack")})]}),(0,c.jsx)("div",{className:"components-placeholder__learn-more",children:(0,c.jsx)(o.ExternalLink,{href:a,children:__("Learn more about Eventbrite embeds","jetpack")})})]})})}},68332(e,t,r){"use strict";r.d(t,{A:()=>i});var n=r(56427),s=r(27723),o=r(10790);const __=s.__,i=()=>(0,o.jsxs)("div",{className:"wp-block-embed is-loading",children:[(0,o.jsx)(n.Spinner,{}),(0,o.jsx)("p",{children:__("Embedding…","jetpack")})]})},72055(e,t,r){"use strict";r.d(t,{A:()=>o});var n=r(56427),s=r(10790);const o=({className:e,attributes:t})=>{const{eventId:r}=t;if(!r)return;const o=`eventbrite-widget-${r}`,i=`\n\t\t\t