File "ai-generator.js"
Full Path: /home/timepamn/dailynetworth.org/wp-content/plugins/wordpress-seo/js/dist/ai-generator.js
File size: 98.6 KB
MIME-type: text/plain
Charset: utf-8
(()=>{var e={4184:(e,t)=>{var s;!function(){"use strict";var r={}.hasOwnProperty;function i(){for(var e=[],t=0;t<arguments.length;t++){var s=arguments[t];if(s){var o=typeof s;if("string"===o||"number"===o)e.push(s);else if(Array.isArray(s)){if(s.length){var a=i.apply(null,s);a&&e.push(a)}}else if("object"===o){if(s.toString!==Object.prototype.toString&&!s.toString.toString().includes("[native code]")){e.push(s.toString());continue}for(var n in s)r.call(s,n)&&s[n]&&e.push(n)}}}return e.join(" ")}e.exports?(i.default=i,e.exports=i):void 0===(s=function(){return i}.apply(t,[]))||(e.exports=s)}()}},t={};function s(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,s),o.exports}s.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return s.d(t,{a:t}),t},s.d=(e,t)=>{for(var r in t)s.o(t,r)&&!s.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";const e=window.wp.components,t=window.wp.data,r=window.wp.hooks,i=window.yoast.uiLibrary,o=window.lodash,a=window.yoast.reduxJsToolkit,n="adminUrl",l=(0,a.createSlice)({name:n,initialState:"",reducers:{setAdminUrl:(e,{payload:t})=>t}}),c=(l.getInitialState,{selectAdminUrl:e=>(0,o.get)(e,n,"")});c.selectAdminLink=(0,a.createSelector)([c.selectAdminUrl,(e,t)=>t],((e,t="")=>{try{return new URL(t,e).href}catch(t){return e}})),l.actions,l.reducer;const d=window.wp.apiFetch;var u=s.n(d);const p="hasConsent",m=`${p}/storeConsent`,h=(0,a.createSlice)({name:p,initialState:{hasConsent:!1,endpoint:"yoast/v1/ai_generator/consent"},reducers:{giveAiGeneratorConsent:(e,{payload:t})=>{e.hasConsent=t},setAiGeneratorConsentEndpoint:(e,{payload:t})=>{e.endpoint=t}}}),g=h.getInitialState,y={selectHasAiGeneratorConsent:e=>(0,o.get)(e,[p,"hasConsent"],h.getInitialState().hasConsent),selectAiGeneratorConsentEndpoint:e=>(0,o.get)(e,[p,"endpoint"],h.getInitialState().endpoint)},x={...h.actions,storeAiGeneratorConsent:function*(e,t){try{yield{type:m,payload:{consent:e,endpoint:t}}}catch(e){return!1}return yield{type:`${p}/giveAiGeneratorConsent`,payload:e},!0}},w={[m]:async({payload:e})=>await u()({path:e.endpoint,method:"POST",data:{consent:e.consent},parse:!1})},f=h.reducer,v=window.wp.url,b="linkParams",S=(0,a.createSlice)({name:b,initialState:{},reducers:{setLinkParams:(e,{payload:t})=>t}}),k=(S.getInitialState,{selectLinkParam:(e,t,s={})=>(0,o.get)(e,`${b}.${t}`,s),selectLinkParams:e=>(0,o.get)(e,b,{})});k.selectLink=(0,a.createSelector)([k.selectLinkParams,(e,t)=>t,(e,t,s={})=>s],((e,t,s)=>(0,v.addQueryArgs)(t,{...e,...s}))),S.actions,S.reducer;const _=(0,a.createSlice)({name:"notifications",initialState:{},reducers:{addNotification:{reducer:(e,{payload:t})=>{e[t.id]={id:t.id,variant:t.variant,size:t.size,title:t.title,description:t.description}},prepare:({id:e,variant:t="info",size:s="default",title:r,description:i})=>({payload:{id:e||(0,a.nanoid)(),variant:t,size:s,title:r||"",description:i}})},removeNotification:(e,{payload:t})=>(0,o.omit)(e,t)}}),j=(_.getInitialState,_.actions,_.reducer,"pluginUrl"),C=(0,a.createSlice)({name:j,initialState:"",reducers:{setPluginUrl:(e,{payload:t})=>t}}),E=(C.getInitialState,{selectPluginUrl:e=>(0,o.get)(e,j,"")});E.selectImageLink=(0,a.createSelector)([E.selectPluginUrl,(e,t,s="images")=>s,(e,t)=>t],((e,t,s)=>[(0,o.trimEnd)(e,"/"),(0,o.trim)(t,"/"),(0,o.trimStart)(s,"/")].join("/"))),C.actions,C.reducer;const R="request",I="success",L="error",T="idle",P="loading",N="success",M="error",A="showPlay",$="askPermission",F="isPlaying",q="wistiaEmbedPermission",U=(0,a.createSlice)({name:q,initialState:{value:!1,status:T,error:{}},reducers:{setWistiaEmbedPermissionValue:(e,{payload:t})=>{e.value=Boolean(t)}},extraReducers:e=>{e.addCase(`${q}/${R}`,(e=>{e.status=P})),e.addCase(`${q}/${I}`,((e,{payload:t})=>{e.status=N,e.value=Boolean(t&&t.value)})),e.addCase(`${q}/${L}`,((e,{payload:t})=>{e.status=M,e.value=Boolean(t&&t.value),e.error={code:(0,o.get)(t,"error.code",500),message:(0,o.get)(t,"error.message","Unknown")}}))}});var O;U.getInitialState,U.actions,U.reducer;const W=(0,a.createSlice)({name:"documentTitle",initialState:(0,o.defaultTo)(null===(O=document)||void 0===O?void 0:O.title,""),reducers:{setDocumentTitle:(e,{payload:t})=>t}}),B=(W.getInitialState,W.actions,W.reducer,window.React);var G=s.n(B);const D=B.forwardRef((function(e,t){return B.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",ref:t},e),B.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-3a1 1 0 00-.867.5 1 1 0 11-1.731-1A3 3 0 0113 8a3.001 3.001 0 01-2 2.83V11a1 1 0 11-2 0v-1a1 1 0 011-1 1 1 0 100-2zm0 8a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"}))})),H=window.wp.element,z=window.wp.i18n,V=window.yoast.aiFrontend,Y=window.yoast.propTypes;var K=s.n(Y);const Z="yoast-seo/ai-generator",X="yoast-seo/editor",J="google",Q="social",ee="twitter",te="title",se="description",re="post",ie="term",oe={post:"title",term:"term_title"},ae=(0,o.mapValues)(oe,(e=>`%%${e}%%`)),ne={mobile:"mobile",desktop:"desktop"},le={idle:"idle",loading:"loading",success:"success",error:"error"},ce="success",de="error",ue="abort",pe=window.yoast.analysis,me=(window.wp.sanitize,window.yoast.helpers),he=(e,t)=>{try{return(0,H.createInterpolateElement)(e,t)}catch(t){return console.error("Error in translation for:",e,t),e}},ge=window.ReactJSXRuntime,{stripHTMLTags:ye}=me.strings;let xe,we=!1;const fe=["_formal","_informal","_ao90"],ve=e=>{for(const t of fe)if(e.endsWith(t))return e.slice(0,-t.length);return e},be="\\–\\-\\(\\)_\\[\\]’‘“”〝〞〟‟„\"'.?!:;,¿¡«»‹›—×+&۔؟،؛。。!‼?⁇⁉⁈‥…・ー、〃〄〆〇〈〉《》「」『』【】〒〓〔〕〖〗〘〙〚〛〜〝〞〟〠〶〼〽{}|~⦅⦆「」、[]・¥$%@&'()*/:;<>\\\<>";be.split(""),new RegExp("^["+be+"]+"),new RegExp("["+be+"]+$");const Se=new RegExp("["+be+"#$%&*+/=@^`{|}~ -¿–-⁊ -₠-⃀]","g"),ke=e=>0===e.replace(Se,"").trim().length,_e=e=>{const t={...e};return""!==e.value||["title","excerpt","excerpt_only"].includes(e.name)||(t.value="%%"+e.name+"%%"),t.badge=`<badge>${e.label}</badge>`,t},je=()=>{const e=(0,t.useSelect)((e=>e(X).getReplaceVars()),[]),s=(0,H.useMemo)((()=>e.map(_e)),[e]);return(0,H.useCallback)(((e,{key:t="value",overrides:r={},applyPluggable:i=!0,editType:a=te,contentType:n=re}={})=>{for(const i of s)e=e.replace(new RegExp("%%"+(0,o.escapeRegExp)(i.name)+"%%","g"),(0,o.get)(r,i.name,i[t]));return n===ie&&(e=e.replace(" Archives","")),i?((e,t=te)=>{const s=function(e){const t=(0,o.get)(window,["YoastSEO","app","pluggable"],!1);if(!t||!(0,o.get)(window,["YoastSEO","app","pluggable","loaded"],!1))return function(e){const t=(0,o.get)(window,["YoastSEO","wp","replaceVarsPlugin","replaceVariables"],o.identity);return{url:e.url,title:ye(t(e.title)),description:ye(t(e.description)),filteredSEOTitle:e.filteredSEOTitle?ye(t(e.filteredSEOTitle)):""}}(e);const s=t._applyModifications.bind(t);return{url:e.url,title:ye(s("data_page_title",e.title)),description:ye(s("data_meta_desc",e.description)),filteredSEOTitle:e.filteredSEOTitle?ye(s("data_page_title",e.filteredSEOTitle)):""}}({title:"",description:"",[t]:pe.languageProcessing.stripSpaces(e)});return(0,o.get)(s,t,e)})(e,a):e}),[s])},Ce={editType:te,previewType:J,postType:"post",contentType:re},Ee=(0,H.createContext)(Ce),Re=Ee.Provider,Ie=()=>(0,H.useContext)(Ee),Le=window.yoast.externals.contexts,Te=()=>(0,H.useContext)(Le.LocationContext),Pe=e=>{const t=(0,H.useRef)(null);return(0,H.useCallback)((s=>{(0,o.attempt)((()=>t.current&&t.current.disconnect())),null!==s&&(t.current=new ResizeObserver((t=>{(0,o.forEach)(t,(t=>e(t)))})),t.current.observe(s))}),[e])},Ne=(0,a.createSlice)({name:"suggestions",initialState:{status:le.loading,error:{code:200,message:""},entities:[],selected:""},reducers:{setLoading:e=>{e.status=le.loading},setSuccess:(e,{payload:t})=>{e.status=le.success,e.selected=t[0],e.entities.push(...t)},setError:(e,{payload:t})=>{e.status=le.error,e.error=t},setSelected:(e,{payload:t})=>{e.selected=t}}}),Me=e=>{switch(e){case Q:return"Facebook";case ee:return"Twitter";default:return"Google"}},Ae=window.yoast.searchMetadataPreviews,$e="usageCount",Fe="fetchUsageCount",qe=`${Fe}/${I}`,Ue=`${Fe}/${L}`,Oe={errorCode:null,errorIdentifier:null,errorMessage:null},We=(0,a.createSlice)({name:$e,initialState:{status:T,count:0,limit:10,endpoint:"yoast/v1/ai_generator/get_usage",error:Oe},reducers:{addUsageCount:(e,{payload:t=1})=>{e.count+=t},setUsageCount:(e,{payload:t})=>{e.count=t},setUsageCountEndpoint:(e,{payload:t})=>{e.endpoint=t},setUsageCountLimit:(e,{payload:t})=>{e.limit=t}},extraReducers:e=>{e.addCase(`${Fe}/${R}`,(e=>{e.status=P,e.error=Oe})),e.addCase(qe,((e,{payload:t})=>{e.status=N,e.count=t.count,e.limit=t.limit,e.error=Oe})),e.addCase(`${Fe}/${L}`,((e,{payload:t})=>{e.status=M,e.error={errorCode:502,...t}}))}}),Be=We.getInitialState,Ge={selectUsageCountStatus:e=>(0,o.get)(e,[$e,"status"],We.getInitialState()),selectUsageCount:e=>(0,o.get)(e,[$e,"count"],We.getInitialState().count),selectUsageCountLimit:e=>(0,o.get)(e,[$e,"limit"],We.getInitialState().limit),selectUsageCountEndpoint:e=>(0,o.get)(e,[$e,"endpoint"],We.getInitialState().endpoint),selectUsageCountError:e=>(0,o.get)(e,[$e,"error"],We.getInitialState().error)};Ge.selectUsageCountRemaining=(0,a.createSelector)([Ge.selectUsageCount,Ge.selectUsageCountLimit],((e,t)=>Math.max(t-e,0))),Ge.isUsageCountLimitReached=(0,a.createSelector)([Ge.selectUsageCount,Ge.selectUsageCountLimit,Ge.selectUsageCountError],((e,t,s)=>429===s.errorCode||e>=t));const De={...We.actions,fetchUsageCount:function*({endpoint:e,isWooProductEntity:t}){yield{type:`${Fe}/${R}`};try{const s=(e=>{const t=(0,o.get)(e,"totalUsed.license",null),s=(0,o.get)(e,"totalUsed.limit",null);if(!(0,o.isNumber)(t)||t<0)throw new Error("Invalid usage count: must be a number of zero or higher.");if(!(0,o.isNumber)(s)||s<-1||0===s)throw new Error("Invalid usage count limit: must be a number of -1 or higher than 1");return{count:t,limit:s}})(yield{type:Fe,payload:{endpoint:e,isWooProductEntity:t}});return{type:`${Fe}/${I}`,payload:s}}catch(e){return{type:`${Fe}/${L}`,payload:e}}}},He={[Fe]:async({payload:e})=>u()({method:"POST",path:e.endpoint,data:{is_woo_product_entity:e.isWooProductEntity}})},ze=We.reducer;K().string.isRequired;const Ve=B.forwardRef((function(e,t){return B.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:t},e),B.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 11V7a4 4 0 118 0m-4 8v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2z"}))})),Ye=B.forwardRef((function(e,t){return B.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",ref:t},e),B.createElement("path",{fillRule:"evenodd",d:"M12.293 5.293a1 1 0 011.414 0l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414-1.414L14.586 11H3a1 1 0 110-2h11.586l-2.293-2.293a1 1 0 010-1.414z",clipRule:"evenodd"}))}));K().string.isRequired,K().string.isRequired,K().shape({src:K().string.isRequired,width:K().string,height:K().string}).isRequired,K().shape({value:K().bool.isRequired,status:K().string.isRequired,set:K().func.isRequired}).isRequired,K().string,K().string,K().string;const Ke=({handleRefreshClick:e,supportLink:t})=>(0,ge.jsxs)("div",{className:"yst-flex yst-gap-2",children:[(0,ge.jsx)(i.Button,{onClick:e,children:(0,z.__)("Refresh this page","wordpress-seo")}),(0,ge.jsx)(i.Button,{variant:"secondary",as:"a",href:t,target:"_blank",rel:"noopener",children:(0,z.__)("Contact support","wordpress-seo")})]});Ke.propTypes={handleRefreshClick:K().func.isRequired,supportLink:K().string.isRequired};const Ze=({handleRefreshClick:e,supportLink:t})=>(0,ge.jsxs)("div",{className:"yst-grid yst-grid-cols-1 yst-gap-y-2",children:[(0,ge.jsx)(i.Button,{className:"yst-order-last",onClick:e,children:(0,z.__)("Refresh this page","wordpress-seo")}),(0,ge.jsx)(i.Button,{variant:"secondary",as:"a",href:t,target:"_blank",rel:"noopener",children:(0,z.__)("Contact support","wordpress-seo")})]});Ze.propTypes={handleRefreshClick:K().func.isRequired,supportLink:K().string.isRequired};const Xe=({error:e,children:t=null})=>(0,ge.jsxs)("div",{role:"alert",className:"yst-max-w-screen-sm yst-p-8 yst-space-y-4",children:[(0,ge.jsx)(i.Title,{children:(0,z.__)("Something went wrong. An unexpected error occurred.","wordpress-seo")}),(0,ge.jsx)("p",{children:(0,z.__)("We're very sorry, but it seems like the following error has interrupted our application:","wordpress-seo")}),(0,ge.jsx)(i.Alert,{variant:"error",children:(null==e?void 0:e.message)||(0,z.__)("Undefined error message.","wordpress-seo")}),(0,ge.jsx)("p",{children:(0,z.__)("Unfortunately, this means that any unsaved changes in this section will be lost. You can try and refresh this page to resolve the problem. If this error still occurs, please get in touch with our support team, and we'll get you all the help you need!","wordpress-seo")}),t]});Xe.propTypes={error:K().object.isRequired,children:K().node},Xe.VerticalButtons=Ze,Xe.HorizontalButtons=Ke;K().string,K().node.isRequired,K().node.isRequired,K().node,K().oneOf(Object.keys({lg:{grid:"yst-grid lg:yst-grid-cols-3 lg:yst-gap-12",col1:"yst-col-span-1",col2:"lg:yst-mt-0 lg:yst-col-span-2"},xl:{grid:"yst-grid xl:yst-grid-cols-3 xl:yst-gap-12",col1:"yst-col-span-1",col2:"xl:yst-mt-0 xl:yst-col-span-2"},"2xl":{grid:"yst-grid 2xl:yst-grid-cols-3 2xl:yst-gap-12",col1:"yst-col-span-1",col2:"2xl:yst-mt-0 2xl:yst-col-span-2"}}));const Je=window.ReactDOM;var Qe,et,tt;(et=Qe||(Qe={})).Pop="POP",et.Push="PUSH",et.Replace="REPLACE",function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"}(tt||(tt={})),new Set(["lazy","caseSensitive","path","id","index","children"]),Error;const st=["post","put","patch","delete"],rt=(new Set(st),["get",...st]);new Set(rt),new Set([301,302,303,307,308]),new Set([307,308]),Symbol("deferred"),B.Component,B.startTransition,new Promise((()=>{})),B.Component,new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);try{window.__reactRouterVersion="6"}catch(e){}var it,ot,at,nt;new Map,B.startTransition,Je.flushSync,B.useId,"undefined"!=typeof window&&void 0!==window.document&&window.document.createElement,(nt=it||(it={})).UseScrollRestoration="useScrollRestoration",nt.UseSubmit="useSubmit",nt.UseSubmitFetcher="useSubmitFetcher",nt.UseFetcher="useFetcher",nt.useViewTransitionState="useViewTransitionState",(at=ot||(ot={})).UseFetcher="useFetcher",at.UseFetchers="useFetchers",at.UseScrollRestoration="useScrollRestoration",K().string.isRequired,K().string;const lt=({href:e,children:t=null,...s})=>(0,ge.jsxs)(i.Link,{target:"_blank",rel:"noopener noreferrer",...s,href:e,children:[t,(0,ge.jsx)("span",{className:"yst-sr-only",children:/* translators: Hidden accessibility text. */
(0,z.__)("(Opens in a new browser tab)","wordpress-seo")})]});lt.propTypes={href:K().string.isRequired,children:K().node};B.forwardRef((function(e,t){return B.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:t},e),B.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17 8l4 4m0 0l-4 4m4-4H3"}))})),(0,z.__)("AI tools included","wordpress-seo"),(0,z.sprintf)(/* translators: %1$s expands to "Yoast SEO academy". */
(0,z.__)("%1$s access","wordpress-seo"),"Yoast SEO academy"),(0,z.__)("24/7 support","wordpress-seo"),(0,z.__)("Generate SEO optimized metadata in seconds with AI","wordpress-seo"),(0,z.__)("Make your articles visible, be seen in Google News","wordpress-seo"),(0,z.__)("Built to get found by search, AI, and real users","wordpress-seo"),(0,z.__)("Easy Local SEO. Show up in Google Maps results","wordpress-seo"),(0,z.__)("Internal links and redirect management, easy","wordpress-seo"),(0,z.__)("Access to friendly help when you need it, day or night","wordpress-seo");B.forwardRef((function(e,t){return B.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",ref:t},e),B.createElement("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"}))}));var ct=s(4184),dt=s.n(ct);K().string.isRequired,K().object.isRequired,K().func.isRequired,K().string.isRequired,K().object,K().func.isRequired,K().bool.isRequired,K().string.isRequired,K().object.isRequired,K().string.isRequired,K().func.isRequired,K().bool.isRequired,B.forwardRef((function(e,t){return B.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:t},e),B.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"}))})),K().bool.isRequired,K().func,K().func,K().string.isRequired,K().string.isRequired,K().string.isRequired,K().string.isRequired;const ut=window.yoast.reactHelmet,pt=({videoId:e,thumbnail:t,wistiaEmbedPermission:s})=>{const[r,o]=(0,H.useState)(s.value?F:A),a=(0,H.useCallback)((()=>o(F)),[o]),n=(0,H.useCallback)((()=>{s.value?a():o($)}),[s.value,a,o]),l=(0,H.useCallback)((()=>o(A)),[o]),c=(0,H.useCallback)((()=>{s.set(!0),a()}),[s.set,a]);return(0,ge.jsxs)(ge.Fragment,{children:[s.value&&(0,ge.jsx)(ut.Helmet,{children:(0,ge.jsx)("script",{src:"https://fast.wistia.com/assets/external/E-v1.js",async:!0})}),(0,ge.jsxs)("div",{className:"yst-relative yst-w-full yst-h-0 yst-pt-[56.25%] yst-overflow-hidden yst-rounded-md yst-drop-shadow-md yst-bg-white",children:[r===A&&(0,ge.jsx)("button",{type:"button",className:"yst-absolute yst-inset-0 yst-button yst-p-0 yst-border-none yst-bg-white yst-transition-opacity yst-duration-1000 yst-opacity-100",onClick:n,children:(0,ge.jsx)("img",{className:"yst-w-full yst-h-auto",alt:"",loading:"lazy",decoding:"async",...t})}),r===$&&(0,ge.jsxs)("div",{className:"yst-absolute yst-inset-0 yst-flex yst-flex-col yst-items-center yst-justify-center yst-bg-white",children:[(0,ge.jsxs)("p",{className:"yst-max-w-xs yst-mx-auto yst-text-center",children:[s.status===P&&(0,ge.jsx)(i.Spinner,{}),s.status!==P&&(0,z.sprintf)(/* translators: %1$s expands to Yoast SEO. %2$s expands to Wistia. */
(0,z.__)("To see this video, you need to allow %1$s to load embedded videos from %2$s.","wordpress-seo"),"Yoast SEO","Wistia")]}),(0,ge.jsxs)("div",{className:"yst-flex yst-mt-6 yst-gap-x-4",children:[(0,ge.jsx)(i.Button,{type:"button",variant:"secondary",onClick:l,disabled:s.status===P,children:(0,z.__)("Deny","wordpress-seo")}),(0,ge.jsx)(i.Button,{type:"button",variant:"primary",onClick:c,disabled:s.status===P,children:(0,z.__)("Allow","wordpress-seo")})]})]}),s.value&&r===F&&(0,ge.jsxs)("div",{className:"yst-absolute yst-w-full yst-h-full yst-top-0 yst-right-0",children:[null===e&&(0,ge.jsx)(i.Spinner,{className:"yst-h-full yst-mx-auto"}),null!==e&&(0,ge.jsx)("div",{className:`wistia_embed wistia_async_${e} videoFoam=true`})]})]})]})};pt.propTypes={videoId:K().string.isRequired,thumbnail:K().shape({src:K().string.isRequired,width:K().string,height:K().string}).isRequired,wistiaEmbedPermission:K().shape({value:K().bool.isRequired,status:K().string.isRequired,set:K().func.isRequired}).isRequired},B.forwardRef((function(e,t){return B.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",ref:t},e),B.createElement("path",{fillRule:"evenodd",d:"M10.293 5.293a1 1 0 011.414 0l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414-1.414L12.586 11H5a1 1 0 110-2h7.586l-2.293-2.293a1 1 0 010-1.414z",clipRule:"evenodd"}))})),K().bool.isRequired,K().func.isRequired,K().func,K().string;const mt=({onGiveConsent:e,learnMoreLink:t,privacyPolicyLink:s,termsOfServiceLink:r,imageLink:o})=>{const{onClose:a,initialFocus:n}=(0,i.useModalContext)(),[l,c]=(0,i.useToggleState)(!1),d=(0,H.useMemo)((()=>({src:o,width:"432",height:"244"})),[o]),u=he((0,z.sprintf)(/* translators: %1$s and %2$s are a set of anchor tags and %3$s and %4$s are a set of anchor tags. */
(0,z.__)("I approve the %1$sTerms of Service%2$s & %3$sPrivacy Policy%4$s of the Yoast AI service. This includes consenting to the collection and use of data to improve user experience.","wordpress-seo"),"<a1>","</a1>","<a2>","</a2>"),{a1:(0,ge.jsx)(lt,{href:r}),a2:(0,ge.jsx)(lt,{href:s})}),[p,m]=(0,i.useToggleState)(!1),h=(0,H.useCallback)((async()=>{m(),await e(),m()}),[e]);return(0,ge.jsxs)(ge.Fragment,{children:[(0,ge.jsx)("div",{className:"yst-px-10 yst-pt-10 yst-introduction-gradient yst-text-center",children:(0,ge.jsx)("div",{className:"yst-relative yst-w-full",children:(0,ge.jsx)("img",{className:"yst-w-full yst-h-auto yst-rounded-md yst-drop-shadow-md",alt:"",loading:"lazy",decoding:"async",...d})})}),(0,ge.jsxs)("div",{className:"yst-px-10 yst-pb-4 yst-flex yst-flex-col yst-items-center",children:[(0,ge.jsxs)("div",{className:"yst-mt-4 yst-mx-1.5 yst-text-center",children:[(0,ge.jsx)("h3",{className:"yst-text-slate-900 yst-text-lg yst-font-medium",children:(0,z.sprintf)(/* translators: %s expands to Yoast AI. */
(0,z.__)("Grant consent for %s","wordpress-seo"),"Yoast AI")}),(0,ge.jsx)("div",{className:"yst-mt-2 yst-text-slate-600 yst-text-sm",children:he((0,z.sprintf)(/* translators: %1$s is a break tag; %2$s and %3$s are anchor tag; %4$s is the arrow icon. */
(0,z.__)("Enable AI-powered SEO! Use all Yoast AI features to boost your efficiency. Just give us the green light. %1$s%2$sLearn more%3$s%4$s","wordpress-seo"),"<br/>","<a>","<ArrowNarrowRightIcon />","</a>"),{a:(0,ge.jsx)(lt,{href:t,className:"yst-inline-flex yst-items-center yst-gap-1 yst-no-underline yst-font-medium",variant:"primary"}),ArrowNarrowRightIcon:(0,ge.jsx)(Ye,{className:"yst-w-4 yst-h-4 rtl:yst-rotate-180"}),br:(0,ge.jsx)("br",{})})})]}),(0,ge.jsx)("div",{className:"yst-flex yst-w-full yst-mt-6",children:(0,ge.jsx)("hr",{className:"yst-w-full yst-text-gray-200"})}),(0,ge.jsxs)("div",{className:"yst-flex yst-items-start yst-mt-4",children:[(0,ge.jsx)("input",{type:"checkbox",id:"yst-ai-consent-checkbox",name:"yst-ai-consent-checkbox",checked:l,value:l?"true":"false",onChange:c,className:"yst-checkbox__input",ref:n}),(0,ge.jsx)("label",{htmlFor:"yst-ai-consent-checkbox",className:"yst-label yst-checkbox__label yst-text-xs yst-font-normal yst-text-slate-500",children:u})]}),(0,ge.jsx)("div",{className:"yst-w-full yst-flex yst-mt-4",children:(0,ge.jsxs)(i.Button,{as:"button",className:"yst-grow",size:"large",disabled:!l,onClick:h,children:[p&&(0,ge.jsx)(i.Spinner,{className:"yst-me-2"}),(0,z.__)("Grant consent","wordpress-seo")]})}),(0,ge.jsx)(i.Button,{as:"button",className:"yst-mt-4",variant:"tertiary",onClick:a,children:(0,z.__)("Close","wordpress-seo")})]})]})};mt.propTypes={onGiveConsent:K().func.isRequired,learnMoreLink:K().string.isRequired,privacyPolicyLink:K().string.isRequired,termsOfServiceLink:K().string.isRequired,imageLink:K().string.isRequired};const ht=()=>{const e=(0,t.useSelect)((e=>e(X).selectLink("https://yoa.st/ai-common-errors")),[]),s=(0,t.useSelect)((e=>e(X).selectAdminLink("?page=wpseo_page_support")),[]);return(0,ge.jsxs)(i.Alert,{variant:"error",children:[(0,ge.jsx)("span",{className:"yst-block yst-font-medium",children:(0,z.__)("Something went wrong","wordpress-seo")}),(0,ge.jsx)("p",{className:"yst-mt-2",children:he((0,z.sprintf)(/* translators: %1$s and %3$s expand to an opening tag. %2$s and %4$s expand to a closing tag. */
(0,z.__)("Please try again later. If this issue persists, you can learn more about possible reasons for this error on our page about %1$scommon AI feature problems and errors%2$s. In case you need further help, please %3$scontact our support team%4$s.","wordpress-seo"),"<a1>","</a1>","<a2>","</a2>"),{a1:(0,ge.jsx)(lt,{variant:"error",href:e}),a2:(0,ge.jsx)(lt,{variant:"error",href:s})})})]})},gt=()=>{const e=(0,t.useSelect)((e=>e(X).selectLink("https://yoa.st/ai-common-errors")),[]),s=(0,t.useSelect)((e=>e(X).selectAdminLink("?page=wpseo_page_support")),[]);return(0,ge.jsxs)(i.Alert,{variant:"error",children:[(0,ge.jsx)("span",{className:"yst-block yst-font-medium",children:(0,z.__)("Not enough content","wordpress-seo")}),(0,ge.jsx)("p",{className:"yst-mt-2",children:he((0,z.sprintf)(/* translators: %1$s and %3$s expand to an opening tag. %2$s and %4$s expand to a closing tag. */
(0,z.__)("Please add more content to ensure a valuable AI suggestion. Learn more on our page about %1$scommon AI feature problems and errors%2$s. In case you need further help, please %3$scontact our support team%4$s.","wordpress-seo"),"<a1>","</a1>","<a2>","</a2>"),{a1:(0,ge.jsx)(lt,{variant:"error",href:e}),a2:(0,ge.jsx)(lt,{variant:"error",href:s})})})]})},yt=()=>{const e=(0,t.useSelect)((e=>e(X).selectAdminLink("?page=wpseo_page_settings#/site-features#card-wpseo-keyword_analysis_active")),[]),s=(0,H.useCallback)((()=>{window.location.reload()}),[]),{onClose:r}=(0,i.useModalContext)();return(0,ge.jsxs)(ge.Fragment,{children:[(0,ge.jsxs)(i.Alert,{variant:"error",children:[(0,ge.jsx)("span",{className:"yst-block yst-font-medium",children:(0,z.__)("SEO analysis required","wordpress-seo")}),(0,ge.jsx)("p",{className:"yst-mt-2",children:he((0,z.sprintf)(
/**
* translators:
* %1$s expands to Yoast SEO.
* %2$s and %3$s expand to an opening and closing anchor tag, respectively, that links to the settings page.
* %4$s expands to Yoast AI.
*/
(0,z.__)("%4$s requires the SEO analysis to be enabled. To enable it, please navigate to %2$sSite features%3$s in %1$s, turn on the SEO analysis, and click 'Save changes'. If it's disabled in your WordPress user profile, access your profile and enable it there. Please contact your administrator if you don't have access to these settings.","wordpress-seo"),"Yoast SEO","<a>","</a>","Yoast AI"),{a:(0,ge.jsx)(lt,{variant:"error",href:e})})})]}),(0,ge.jsxs)("div",{className:"yst-mt-6 yst-mb-1 yst-flex yst-space-x-3 rtl:yst-space-x-reverse yst-place-content-end",children:[(0,ge.jsx)(i.Button,{variant:"secondary",onClick:r,children:(0,z.__)("Close","wordpress-seo")}),(0,ge.jsx)(i.Button,{className:"yst-revoke-button",variant:"primary",onClick:s,children:(0,z.__)("Refresh page","wordpress-seo")})]})]})},xt=()=>{const e=(0,t.useSelect)((e=>e(X).selectLink("https://yoa.st/ai-generator-rate-limit-help")),[]);return(0,ge.jsxs)(i.Alert,{variant:"error",children:[(0,ge.jsx)("span",{className:"yst-block yst-font-medium",children:(0,z.__)("You've reached the Yoast AI rate limit","wordpress-seo")}),(0,ge.jsx)("p",{className:"yst-mt-2",children:he((0,z.sprintf)(/* translators: %1$s expands to an opening tag. %2$s expands to a closing tag. */
(0,z.__)("You might have reached your Yoast AI rate limit for a specific time frame or your sparks limit for this month. If you have reached your rate limit, please reduce the frequency of your requests to continue using Yoast AI features. Our %1$shelp article%2$s provides guidance on effectively planning and pacing your requests for an optimized workflow.","wordpress-seo"),"<a>","</a>"),{a:(0,ge.jsx)(lt,{variant:"error",href:e})})})]})},wt=({invalidSubscriptions:e=[]})=>{const{newYoastWooLink:s,activateYoastWooLink:r,newPremiumLink:o,activatePremiumLink:a}=(0,t.useSelect)((e=>{const t=e(X);return{newYoastWooLink:t.selectLink("https://yoa.st/ai-generator-new-yoast-woocommerce"),activateYoastWooLink:t.selectLink("https://yoa.st/ai-generator-activate-yoast-woocommerce"),newPremiumLink:t.selectLink("https://yoa.st/ai-generator-new-premium"),activatePremiumLink:t.selectLink("https://yoa.st/ai-generator-activate-premium")}}),[]),{onClose:n}=(0,i.useModalContext)(),l=(0,H.useCallback)((async()=>{try{await u()({path:"yoast/v1/ai_generator/bust_subscription_cache",method:"POST",parse:!1})}catch(e){console.error(e)}window.location.reload()}),[]);let c,d,p;return e.includes("Yoast WooCommerce SEO")?(c="Yoast WooCommerce SEO",d=r,p=s):e.includes("Yoast SEO Premium")&&(c="Yoast SEO Premium",d=a,p=o),(0,ge.jsxs)(H.Fragment,{children:[(0,ge.jsxs)(i.Alert,{variant:"error",children:[(0,ge.jsx)("span",{className:"yst-block yst-font-medium",children:(0,z.__)("Subscription required","wordpress-seo")}),(0,ge.jsx)("p",{className:"yst-mt-2",children:he((0,z.sprintf)(
/**
* translators:
* %1$s expands to Yoast SEO Premium or Yoast WooCommerce SEO.
* %2$s expands to MyYoast.
* %3$s and %4$s expand to an opening and closing anchor tag, respectively, to activate your subscription.
* %5$s and %6$s expand to an opening and closing anchor tag, respectively, to get a new subscription.
**/
(0,z.__)("To access this feature, you need an active %1$s subscription. Please %3$sactivate your subscription in %2$s%4$s or %5$sget a new %1$s subscription%6$s. Afterward, refresh this page. It may take up to 30 seconds for the feature to function correctly.","wordpress-seo"),c,"MyYoast","<Activate>","</Activate>","<New>","</New>"),{Activate:(0,ge.jsx)(lt,{variant:"error",href:d}),New:(0,ge.jsx)(lt,{variant:"error",href:p})})})]}),(0,ge.jsxs)("div",{className:"yst-mt-6 yst-mb-1 yst-flex yst-space-x-3 rtl:yst-space-x-reverse yst-place-content-end",children:[(0,ge.jsx)(i.Button,{variant:"secondary",onClick:n,children:(0,z.__)("Close","wordpress-seo")}),(0,ge.jsx)(i.Button,{variant:"primary",onClick:l,children:(0,z.__)("Refresh page","wordpress-seo")})]})]})};wt.propTypes={invalidSubscriptions:K().arrayOf(K().string)};const ft=()=>{const e=(0,t.useSelect)((e=>e(X).selectLink("https://yoa.st/ai-common-errors")),[]),s=(0,t.useSelect)((e=>e(X).selectAdminLink("?page=wpseo_page_support")),[]);return(0,ge.jsxs)(i.Alert,{variant:"error",children:[(0,ge.jsx)("span",{className:"yst-block yst-font-medium",children:(0,z.__)("Connection timeout","wordpress-seo")}),(0,ge.jsx)("p",{className:"yst-mt-2",children:he((0,z.sprintf)(/* translators: %1$s and %3$s expand to an opening tag. %2$s and %4$s expand to a closing tag. */
(0,z.__)("It seems that a connection timeout has occurred. Please check your internet connection and try again later. Learn more on our page about %1$scommon AI feature problems and errors%2$s. In case you need further help, please %3$scontact our support team%4$s.","wordpress-seo"),"<a1>","</a1>","<a2>","</a2>"),{a1:(0,ge.jsx)(lt,{variant:"error",href:e}),a2:(0,ge.jsx)(lt,{variant:"error",href:s})})})]})},vt=()=>{const e=(0,t.useSelect)((e=>e(X).selectAdminLink("?page=wpseo_page_support")),[]);return(0,ge.jsxs)(i.Alert,{variant:"error",children:[(0,ge.jsx)("span",{className:"yst-block yst-font-medium",children:(0,z.__)("Usage policy violation","wordpress-seo")}),(0,ge.jsx)("p",{className:"yst-mt-2",children:he((0,z.sprintf)(
/* translators: %1$s, %2$s, %3$s, %4$s are anchor tags.
* %5$s expands to OpenAI.
*/
(0,z.__)("Due to %5$s's strict ethical guidelines and %1$susage policies%2$s, we cannot generate suggestions for the content on this page. If you intend to use AI, kindly avoid the use of explicit, violent, copyrighted, or sexually explicit content. In case you need further help, please %3$scontact our support team%4$s.","wordpress-seo"),"<a1>","</a1>","<a2>","</a2>","OpenAI"),{a1:(0,ge.jsx)(lt,{variant:"error",href:"https://openai.com/policies/usage-policies"}),a2:(0,ge.jsx)(lt,{variant:"error",href:e})})})]})},bt=({errorMessage:e=""})=>{const s=(0,t.useSelect)((e=>e(X).selectAdminLink("?page=wpseo_page_support")),[]);return(0,ge.jsxs)(i.Alert,{variant:"error",children:[(0,ge.jsx)("span",{className:"yst-block yst-font-medium",children:(0,z.__)("Something went wrong","wordpress-seo")}),(0,ge.jsx)("p",{className:"yst-mt-2",children:(0,z.sprintf)(/* translators: %s is the error response of the request. */
(0,z.__)("The request came back with the following error: '%s'.","wordpress-seo"),e)}),(0,ge.jsx)("p",{className:"yst-mt-2",children:he((0,z.sprintf)(/* translators: %1$s expands to an opening tag. %2$s expands to a closing tag. */
(0,z.__)("Please try again later. If the issue persists, please %1$scontact our support team%2$s.","wordpress-seo"),"<a>","</a>"),{a:(0,ge.jsx)(lt,{variant:"error",href:s})})})]})};bt.propTypes={errorMessage:K().string};const St=()=>{const e=(0,t.useSelect)((e=>e(X).selectAdminLink("plugins.php")),[]);return(0,ge.jsxs)(i.Alert,{variant:"error",children:[(0,ge.jsx)("span",{className:"yst-block yst-font-medium",children:(0,z.__)("Something went wrong","wordpress-seo")}),(0,ge.jsx)("p",{className:"yst-mt-2",children:he((0,z.sprintf)(/* translators: %1$s expands to Yoast SEO Premium. %2$s expands to an opening link tag. %3$s expands to a closing link tag. */
(0,z.__)("The version of %1$s is outdated. Please upgrade %1$s %2$shere%3$s!","wordpress-seo"),"Yoast SEO Premium","<a>","</a>"),{a:(0,ge.jsx)(lt,{variant:"error",href:e})})})]})},kt=()=>{const e=(0,t.useSelect)((e=>e(X).selectLink("https://yoa.st/ai-common-errors")),[]),s=(0,t.useSelect)((e=>e(X).selectAdminLink("?page=wpseo_page_support")),[]);return(0,ge.jsxs)(i.Alert,{variant:"error",children:[(0,ge.jsx)("span",{className:"yst-block yst-font-medium",children:(0,z.__)("Yoast AI cannot reach your site","wordpress-seo")}),(0,ge.jsx)("p",{className:"yst-mt-2",children:he((0,z.sprintf)(/* translators: %1$s and %3$s expand to an opening tag. %2$s and %4$s expand to a closing tag. */
(0,z.__)("To use this feature, your site must be publicly accessible. This applies to both test sites and instances where your REST API is password-protected. Please ensure your site is accessible to the public and try again. Learn more on our page about %1$scommon AI feature problems and errors%2$s. In case you need further help, please %3$scontact our support team%4$s.","wordpress-seo"),"<a1>","</a1>","<a2>","</a2>"),{a1:(0,ge.jsx)(lt,{variant:"error",href:e}),a2:(0,ge.jsx)(lt,{variant:"error",href:s})})})]})},_t=({errorCode:e,errorIdentifier:t="",errorMessage:s=""})=>{switch(e){case 400:switch(t){case"SITE_UNREACHABLE":return(0,ge.jsx)(kt,{});case"WP_HTTP_REQUEST_ERROR":return(0,ge.jsx)(bt,{errorMessage:s});default:return(0,ge.jsx)(ht,{})}case 429:return(0,ge.jsx)(xt,{});default:return(0,ge.jsx)(ht,{})}};_t.propTypes={errorCode:K().number.isRequired,errorIdentifier:K().string,errorMessage:K().string};const jt=({currentSubscriptions:e,isSeoAnalysisActive:s=!0})=>{const{isPremium:r,usageCountStatus:i,usageCountError:o,isWooProductEntity:a,isWooSeoActive:n}=(0,t.useSelect)((e=>{const t=e(X);return{isPremium:t.getIsPremium(),usageCountStatus:e(Z).selectUsageCountStatus(),usageCountError:e(Z).selectUsageCountError(),isWooProductEntity:t.getIsWooProductEntity(),isWooSeoActive:t.getIsWooSeoActive()}}),[]),l=(0,H.useMemo)((()=>!e.wooCommerceSubscription&&a),[e.wooCommerceSubscription]),c=(0,H.useMemo)((()=>{const t=[];return!r&&!a||e.premiumSubscription||t.push("Yoast SEO Premium"),l&&n&&t.push("Yoast WooCommerce SEO"),t}),[r,e.premiumSubscription,l,n,a]);return c.length>0?(0,ge.jsx)(wt,{invalidSubscriptions:c}):s?i===le.error?(0,ge.jsx)(_t,{...o}):void 0:(0,ge.jsx)(yt,{})};jt.propTypes={currentSubscriptions:K().object.isRequired,isSeoAnalysisActive:K().bool};const Ct=({onStartGenerating:e})=>{const{termsOfServiceLink:s,privacyPolicyLink:r,learnMoreLink:i,imageLink:o,consentEndpoint:a}=(0,t.useSelect)((e=>({termsOfServiceLink:e(X).selectLink("https://yoa.st/ai-generator-terms-of-service"),privacyPolicyLink:e(X).selectLink("https://yoa.st/ai-generator-privacy-policy"),learnMoreLink:e(X).selectLink("https://yoa.st/ai-generator-learn-more"),imageLink:e(X).selectImageLink("ai-consent.png"),consentEndpoint:e(Z).selectAiGeneratorConsentEndpoint()})),[]),{storeAiGeneratorConsent:n}=(0,t.useDispatch)(Z),l=(0,H.useCallback)((async()=>{await n(!0,a),e()}),[n,e,a]);return(0,ge.jsx)(mt,{termsOfServiceLink:s,privacyPolicyLink:r,learnMoreLink:i,imageLink:o,onGiveConsent:l})};Ct.propTypes={onStartGenerating:K().func.isRequired};const Et=B.forwardRef((function(e,t){return B.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:t},e),B.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"}))})),Rt=B.forwardRef((function(e,t){return B.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:t},e),B.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"}))})),It=/(?<start><\/badge>|^(?!<badge>))(?<wrap>[\s\S]+?)(?<end><badge>|$)/g,Lt=({total:e,current:t,onNavigate:s,disabled:r=!1,...o})=>(0,ge.jsxs)("div",{className:"yst-flex yst-justify-between yst-gap-x-2 yst-items-start",children:[(0,ge.jsx)("p",{className:"yst-text-slate-500 yst-text-xxs yst-mt-1",children:(0,z.__)("Text generated by AI may be offensive or inaccurate.","wordpress-seo")}),e>1&&(0,ge.jsx)(i.Pagination,{className:"yst-shrink-0",current:t,total:e,onNavigate:s,disabled:r,variant:"text"
/* translators: Hidden accessibility text. */,screenReaderTextPrevious:(0,z.__)("Previous","wordpress-seo")
/* translators: Hidden accessibility text. */,screenReaderTextNext:(0,z.__)("Next","wordpress-seo"),...o})]}),Tt=({height:e})=>{const[s,r]=(0,H.useState)(""),{onClose:a}=(0,i.useModalContext)(),{editType:n,previewType:l,contentType:c}=Ie(),d=(()=>{const{editType:e,previewType:t}=Ie();let s="SEO";switch(t){case Q:s="social";break;case ee:s="X"}switch(e){case te:return(0,z.sprintf)(/* translators: %s is the type of title. */
(0,z.__)("Generated %s titles","wordpress-seo"),s);case se:return t===J&&(s="meta"),(0,z.sprintf)(/* translators: %s is the type of description. */
(0,z.__)("Generated %s descriptions","wordpress-seo"),s)}})(),p=(()=>{const{editType:e,previewType:t}=Ie();let s="SEO";switch(t){case Q:s="social";break;case ee:s="X"}switch(e){case te:return(0,z.sprintf)(/* translators: %s is the type of title. */
(0,z.__)("Apply %s title","wordpress-seo"),s);case se:return t===J&&(s="meta"),(0,z.sprintf)(/* translators: %s is the type of description. */
(0,z.__)("Apply %s description","wordpress-seo"),s)}})(),m=Te(),{suggestions:h,fetchSuggestions:g,setSelectedSuggestion:y}=(()=>{const[e,s]=(0,H.useReducer)(Ne.reducer,Ne.getInitialState()),{editType:r,previewType:i,postType:a,contentType:n}=Ie(),l=(0,t.useSelect)((e=>e(Z).selectPromptContent()),[]),{contentLocale:c,focusKeyphrase:d,isWooCommerceActive:p,isGutenberg:m,isElementor:h}=(0,t.useSelect)((e=>({contentLocale:e(X).getContentLocale(),focusKeyphrase:e(X).getFocusKeyphrase(),isWooCommerceActive:e(X).getIsWooCommerceActive(),isGutenberg:e(X).getIsBlockEditor(),isElementor:e(X).getIsElementorEditor()})),[]);let g,y=pe.languageProcessing.helpers.processExactMatchRequest(d).keyphrase;y.length>191&&(y=y.slice(0,191)),g=h?"elementor":m?"gutenberg":"classic";const x=((e,t,s,r)=>{const i=e===se?"meta-description":"seo-title";let o=((e,t)=>{if(e)switch(t){case"product":return"product-";case"product_cat":case"product_tag":return"product-taxonomy-"}return""})(t,s);return o&&t||r!==ie||(o="taxonomy-"),`${o}${i}`})(r,p,a,n);return{suggestions:e,fetchSuggestions:(0,H.useCallback)((async(e=!0)=>{s(Ne.actions.setLoading());const{status:t,payload:r}=await(async({endpoint:e,data:t})=>{let s;const r=1e3*(0,o.get)(window,"wpseoAiGenerator.requestTimeout",30);try{xe&&xe.abort(),xe=new AbortController,we=!1,s=setTimeout((()=>{we=!0,xe.abort()}),r);const i=await u()({path:e,method:"POST",data:t,parse:!1,signal:xe.signal}),o=await i.json();return{status:ce,payload:o}}catch(e){if(e instanceof DOMException&&"AbortError"===e.name)return we?{status:de,payload:{message:"timeout",code:408}}:{status:ue};const{message:t,missingLicenses:s,errorIdentifier:r}=await(async e=>{try{const t=e.body.getReader(),{value:s}=await t.read(),r=new TextDecoder("utf-8").decode(s);return console.error(r),JSON.parse(r)}catch(e){return{message:"Unknown"}}})(e);return{status:de,payload:{message:t,code:e.status||500,missingLicenses:s,errorIdentifier:r}}}finally{clearTimeout(s)}})({endpoint:"yoast/v1/ai_generator/get_suggestions/",canAbort:e,data:{type:x,prompt_content:l,focus_keyphrase:y,platform:Me(i),language:ve(c).replace("_","-"),editor:g}});switch(t){case ue:break;case de:s(Ne.actions.setError(r));break;case ce:s(Ne.actions.setSuccess(r))}return t}),[s]),setSelectedSuggestion:(0,H.useCallback)((e=>s(Ne.actions.setSelected(e))),[s])}})(),x=(()=>{const{previewType:e}=Ie();switch(e){case Q:return Gt;case ee:return Xs;default:return Ft}})(),{addAppliedSuggestion:w,addUsageCount:f}=(0,t.useDispatch)(Z),{isUsageCountLimitReached:v,isWooProductEntity:b,hasValidPremiumSubscription:S,hasValidWooSubscription:k}=(0,t.useSelect)((e=>{const t=e(Z),s=e(X);return{isUsageCountLimitReached:t.isUsageCountLimitReached(),isPremium:s.getIsPremium(),isWooProductEntity:s.getIsWooProductEntity(),isWooSeoActive:s.getIsWooSeoActive(),hasValidPremiumSubscription:t.selectPremiumSubscription(),hasValidWooSubscription:t.selectWooCommerceSubscription()}}),[]),_=(0,H.useMemo)((()=>h.status===le.loading||!(k||!v||!b)||!(S||!v)),[S,v,h.status,b,k]),j=(0,i.usePrevious)(e),C=h.status===le.success?e:j,E=`calc(${0===C?"50%":C/2+"px"} - 40vh)`,[R,I]=(0,H.useState)(!1),L=(0,H.useCallback)((e=>{I(e.target.offsetHeight!==e.target.scrollHeight)}),[I]),T=Pe(L),P=(()=>{const{editType:e,previewType:s,contentType:r}=Ie(),i=(()=>{const{previewType:e}=Ie();return(0,H.useMemo)((()=>{switch(e){case J:return()=>(0,t.select)(X).getSnippetEditorData().title;case Q:return(0,t.select)(X).getFacebookTitleOrFallback;case ee:return(0,t.select)(X).getTwitterTitleOrFallback;default:return(0,o.constant)("")}}),[e])})(),a=(0,t.useSelect)((t=>t(Z).selectAppliedSuggestionFor({editType:e,previewType:s})),[e,s]);return(0,H.useMemo)((()=>{let t=i();return e===se?t:(a&&(t=t.replace(a,ae[r])),((e,t)=>e.includes(ae[t])?e:ae[t])(t,r))}),[e,i])})(),N=(()=>{const e=(()=>{const{previewType:e}=Ie();return(0,H.useMemo)((()=>{switch(e){case J:return()=>(0,t.select)(X).getSnippetEditorData().description;case Q:return(0,t.select)(X).getFacebookDescriptionOrFallback;case ee:return(0,t.select)(X).getTwitterDescriptionOrFallback;default:return(0,o.constant)("")}}),[e])})();return(0,H.useMemo)(e,[e])})(),M=je(),A=(0,H.useMemo)((()=>n===te?{[oe[c]]:h.selected}:{}),[n,c,h.selected]),$=(0,H.useMemo)((()=>M(P,{overrides:A,contentType:c})),[M,P,n,c,h.selected]),F=(0,H.useMemo)((()=>M(P,{overrides:{...A,sep:"",sitename:""},contentType:c})),[M,P,n,c,h.selected]),q=(0,H.useMemo)((()=>n===se?h.selected:M(N,{editType:se})),[M,N,n,h.selected]),U=(0,H.useCallback)((e=>M(P,{overrides:{[oe[c]]:e},key:"badge",applyPluggable:!1,contentType:c})),[M,P,c]),{currentPage:O,setCurrentPage:W,isOnLastPage:B,totalPages:G,getItemsOnCurrentPage:D}=(({totalItems:e=0,perPage:t=5})=>{const[s,r]=(0,H.useState)(1),i=(0,H.useMemo)((()=>Math.ceil(e/t)),[e,t]),a=(0,H.useMemo)((()=>s*t),[s,t]),n=(0,H.useMemo)((()=>a-t),[a,t]),l=(0,H.useMemo)((()=>1===s),[s]),c=(0,H.useMemo)((()=>s===i),[s,i]),d=(0,H.useCallback)((()=>{s>1&&r(s-1)}),[s,r]),u=(0,H.useCallback)((()=>{s<i&&r(s+1)}),[s,r,i]),p=(0,H.useCallback)((e=>(0,o.slice)(e,n,a)),[n,a]);return{currentPage:s,setCurrentPage:r,totalPages:i,isOnFirstPage:l,isOnLastPage:c,previousPage:d,nextPage:u,firstOnPage:n,lastOnPage:a,getItemsOnCurrentPage:p}})({totalItems:h.status===le.loading||h.status===le.error?h.entities.length+5:h.entities.length,perPage:5}),V=(0,H.useMemo)((()=>(0,o.map)(D(h.entities),(e=>{let t=e;return n===te&&(t=U(e),t=t.replace(It,((e,t,s,r,i,o,{start:a,wrap:n,end:l})=>{const c=n.trim();return 0===c.length?`${a}${n}${l}`:`${a}<span>${c}</span>${l}`})),t=he(t,{badge:(0,ge.jsx)(i.Badge,{className:"yst-me-2 last:yst-me-0",variant:"plain",children:" "}),span:(0,ge.jsx)("span",{className:"yst-flex yst-items-center yst-me-2 last:yst-me-0"})})),{value:e,label:t}}))),[h.entities,D,n,U]),Y=(0,H.useMemo)((()=>h.status!==le.error||h.status===le.error&&!B),[h.status,B]),K=(0,H.useMemo)((()=>h.status===le.loading&&B),[h.status,B]),re=(0,H.useMemo)((()=>h.status===le.error&&B),[h.status,B]),ne=(0,H.useCallback)((()=>{_||(W(h.status===le.error?G:G+1),g().then((e=>{e===ce&&f()})))}),[g,h.status,G,W,y,v]),me=(0,H.useCallback)((()=>r("")),[r]),ye=(()=>{const{editType:e}=Ie();switch(e){case te:return(()=>{const{previewType:e}=Ie(),{updateData:s,setFacebookPreviewTitle:r,setTwitterPreviewTitle:i}=(0,t.useDispatch)(X);return(0,H.useMemo)((()=>{switch(e){case J:return e=>s({title:e});case Q:return r;case ee:return i;default:return o.noop}}),[e,s,r,i])})();case se:return(()=>{const{previewType:e}=Ie(),{updateData:s,setFacebookPreviewDescription:r,setTwitterPreviewDescription:i}=(0,t.useDispatch)(X);return(0,H.useMemo)((()=>{switch(e){case J:return e=>s({description:e});case Q:return r;case ee:return i;default:return o.noop}}),[e,s,r,i])})();default:return o.noop}})(),fe=(0,H.useCallback)((()=>{const e=n===te?P.replace(new RegExp(ae[c]+"( Archives)?"),h.selected):h.selected;ye(e),w({editType:n,previewType:l,suggestion:h.selected}),a()}),[ye,n,l,h.selected,P,a,w]);return((e,t=[])=>{const s=(0,H.useRef)(!1);(0,H.useEffect)((()=>{s.current||(s.current=!0,e().finally((()=>{s.current=!1})))}),[e,t])})((()=>""===s?g().then((e=>{r(e),e===ce&&f()})):Promise.resolve()),[s,f,g]),s===de||h.status===le.error&&402===h.error.code?(0,ge.jsx)("div",{className:"yst-flex yst-flex-col yst-space-y-6 yst-mt-6",children:(0,ge.jsx)(Gs,{errorCode:h.error.code,errorIdentifier:h.error.errorIdentifier,invalidSubscriptions:h.error.missingLicenses,showActions:!0,onRetry:me,errorMessage:h.error.message})}):(0,ge.jsxs)(H.Fragment,{children:[(0,ge.jsxs)(i.Modal.Container.Content,{ref:T,className:"yst-flex yst-flex-col yst-py-6 yst-space-y-2",children:[(0,ge.jsx)(x,{title:$,description:q,status:h.status,titleForLength:F,showPreviewSkeleton:""===s,showLengthProgress:!K}),Y&&(K?(0,ge.jsx)(Ys,{idSuffix:m,suggestionClassNames:n===te?[["yst-h-3 yst-w-9/12"],["yst-h-3 yst-w-7/12"],["yst-h-3 yst-w-10/12"],["yst-h-3 yst-w-11/12"],["yst-h-3 yst-w-8/12"]]:void 0}):(0,ge.jsxs)(ge.Fragment,{children:[(0,ge.jsxs)("div",{className:"yst-flex yst-space-y-4",children:[(0,ge.jsx)(i.Label,{as:"span",className:"yst-flex-grow yst-cursor-default yst-mt-auto",children:d}),(0,ge.jsxs)(i.Button,{variant:"secondary",size:"small",onClick:h.status===le.loading?o.noop:ne,isLoading:h.status===le.loading,disabled:_,children:[h.status!==le.loading&&(0,ge.jsx)(Et,{className:"yst--ms-1 yst-me-2 yst-h-4 yst-w-4 yst-text-gray-400"}),(0,z.__)("Generate 5 more","wordpress-seo")]})]}),(0,ge.jsx)(zs,{idSuffix:m,suggestions:V,selected:h.selected,onChange:y}),(0,ge.jsx)(Lt,{current:O,total:G,onNavigate:W,disabled:h.status===le.loading||re})]})),h.status===le.error&&B&&(0,ge.jsxs)(ge.Fragment,{children:[(0,ge.jsx)("div",{className:"yst-mt-8"}),(0,ge.jsx)(Gs,{errorCode:h.error.code,errorIdentifier:h.error.errorIdentifier,invalidSubscriptions:h.error.missingLicenses,errorMessage:h.error.message}),(0,ge.jsx)(Lt,{current:O,total:G,onNavigate:W,disabled:h.status===le.loading})]})]}),(0,ge.jsxs)(i.Modal.Container.Footer,{children:[R&&(0,ge.jsx)("div",{className:"yst-absolute yst-inset-x-0 yst--mt-10 yst-me-[calc(2.5rem-1px)] yst-h-10 yst-pointer-events-none yst-bg-gradient-to-t yst-from-slate-50"}),(0,ge.jsx)("hr",{className:"yst-mb-6 yst--mx-6"}),(0,ge.jsxs)("div",{className:"sm:yst-flex sm:yst-justify-end sm:yst-space-x-2 sm:rtl:yst-space-x-reverse",children:[(0,ge.jsx)("div",{className:"yst-hidden sm:yst-inline",children:(0,ge.jsx)(i.Button,{variant:"secondary",onClick:a,children:(0,z.__)("Close","wordpress-seo")})}),(0,ge.jsx)("div",{className:"yst-block sm:yst-inline",children:(0,ge.jsxs)(i.Button,{className:"yst-w-full sm:yst-w-auto",variant:"primary",onClick:fe,disabled:""===h.selected||h.status===le.loading||re,children:[(0,ge.jsx)(Rt,{className:"yst--ms-1 yst-me-1 yst-h-4 yst-w-4 yst-text-white"}),p]})}),(0,ge.jsx)("div",{className:"yst-mt-3 sm:yst-hidden",children:(0,ge.jsx)(i.Button,{variant:"secondary",onClick:a,className:"yst-w-full sm:yst-w-auto",children:(0,z.__)("Close","wordpress-seo")})})]})]}),(0,ge.jsxs)(i.Notifications,{className:"yst-mx-[calc(50%-50vw)] yst-transition-all",style:{marginTop:E},position:"bottom-left",children:[h.status!==le.loading&&(0,ge.jsx)(ir,{className:"yst-mx-[calc(50%-50vw)] yst-transition-all"}),(h.status===le.success||h.status===le.loading)&&(0,ge.jsx)(Zs,{})]})]})};Tt.propTypes={height:K().number.isRequired};const Pt=({onActivateFreeSparks:e})=>{const{premiumUpsellLink:s,wooUpsellLink:r,isWooCommerceActive:o,isProductPost:a,learnMoreLink:n,imageLink:l,wistiaEmbedPermissionValue:c,wistiaEmbedPermissionStatus:d,isUsageCountLimitReached:u,activateFreeSparksEndpoint:p}=(0,t.useSelect)((e=>{const t=e(Z),s=e(X);return{premiumUpsellLink:s.selectLink("https://yoa.st/ai-generator-upsell"),wooUpsellLink:s.selectLink("https://yoa.st/ai-generator-upsell-woo-seo"),isWooCommerceActive:s.getIsWooCommerceActive(),isProductPost:s.getIsProduct(),learnMoreLink:s.selectLink("https://yoa.st/ai-generator-learn-more"),imageLink:s.selectImageLink("ai-generator-preview.png"),wistiaEmbedPermissionValue:s.selectWistiaEmbedPermissionValue(),wistiaEmbedPermissionStatus:s.selectWistiaEmbedPermissionStatus(),isUsageCountLimitReached:t.isUsageCountLimitReached(),activateFreeSparksEndpoint:t.selectFreeSparksActiveEndpoint()}}),[]),{onClose:m,initialFocus:h}=(0,i.useModalContext)(),{title:g,upsellLabel:y,upsellLink:x,ctbId:w,newToText:f}=(e=>{const{isWooProductEntity:s,isProductPost:r,hasValidWooSubscription:i}=(0,t.useSelect)((e=>{const t=e(X),s=e(Z);return{isWooProductEntity:t.getIsWooProductEntity(),isProductPost:t.getIsProduct(),hasValidWooSubscription:s.selectWooCommerceSubscription()}}),[]);return(0,H.useMemo)((()=>{const t={upsellLink:e.premium,upsellLabel:(0,z.sprintf)(/* translators: %1$s expands to Yoast SEO Premium. */
(0,z.__)("Unlock with %1$s","wordpress-seo"),"Yoast SEO Premium"),newToText:"Yoast SEO Premium",ctbId:"f6a84663-465f-4cb5-8ba5-f7a6d72224b2",title:(0,z.__)("Use AI to generate your titles & descriptions!","wordpress-seo")};return s&&(r&&(t.title=(0,z.__)("Generate product titles & descriptions with AI!","wordpress-seo")),i||(t.newToText="Yoast WooCommerce SEO",t.upsellLabel=(0,z.sprintf)(/* translators: %1$s expands to Yoast WooCommerce SEO. */
(0,z.__)("Unlock with %1$s","wordpress-seo"),"Yoast WooCommerce SEO"),t.upsellLink=e.woo,t.ctbId="5b32250e-e6f0-44ae-ad74-3cefc8e427f9")),t}),[s,r,e.premium,e.woo])})({premium:s,woo:r}),v=(0,H.useMemo)((()=>o&&a),[o,a]),b=(0,H.useMemo)((()=>({src:l,width:"432",height:"244"})),[l]),{setWistiaEmbedPermission:S}=(0,t.useDispatch)(X),{activateFreeSparks:k}=(0,t.useDispatch)(Z),_=(0,H.useMemo)((()=>({value:c,status:d,set:S})),[c,d,S]),j=(0,H.useCallback)((()=>{k({endpoint:p}),e()}),[k,p,m,e]),C={a:(0,ge.jsx)(lt,{href:n,className:"yst-inline-flex yst-items-center yst-gap-1 yst-no-underline yst-font-medium",variant:"primary"}),ArrowNarrowRightIcon:(0,ge.jsx)(Ye,{className:"yst-w-4 yst-h-4 rtl:yst-rotate-180"})};return(0,ge.jsxs)(ge.Fragment,{children:[(0,ge.jsxs)("div",{className:"yst-px-10 yst-pt-10 yst-introduction-gradient yst-text-center",children:[(0,ge.jsxs)("div",{className:"yst-relative yst-w-full",children:[(0,ge.jsx)(pt,{videoId:"vmrahpfjxp",thumbnail:b,wistiaEmbedPermission:_}),(0,ge.jsx)(i.Badge,{className:"yst-absolute yst--top-2 yst-end-4",variant:"info",children:"Beta"})]}),(0,ge.jsx)("div",{className:"yst-mt-6 yst-text-xs yst-font-medium yst-flex yst-flex-col yst-items-center",children:(0,ge.jsxs)("span",{className:"yst-introduction-modal-uppercase yst-flex yst-gap-2 yst-items-center",children:[(0,ge.jsx)("span",{className:"yst-logo-icon"}),f]})})]}),(0,ge.jsxs)("div",{className:"yst-px-10 yst-pb-4 yst-flex yst-flex-col yst-items-center",children:[(0,ge.jsxs)("div",{className:"yst-mt-4 yst-mx-1.5 yst-text-center",children:[(0,ge.jsx)("h3",{className:"yst-text-slate-900 yst-text-lg yst-font-medium",children:g}),(0,ge.jsx)("div",{className:"yst-mt-2 yst-text-slate-600 yst-text-sm",children:he(v?(0,z.sprintf)(/* translators: %1$s and %2$s are anchor tags; %3$s is the arrow icon. */
(0,z.__)("Let AI do some of the thinking for you and help you save time. Get high-quality suggestions for product titles and meta descriptions to make your content rank high and look good on social media. %1$sLearn more%2$s%3$s","wordpress-seo"),"<a>","<ArrowNarrowRightIcon />","</a>"):(0,z.sprintf)(/* translators: %1$s and %2$s are anchor tags; %3$s is the arrow icon. */
(0,z.__)("Let AI do some of the thinking for you and help you save time. Get high-quality suggestions for titles and meta descriptions to make your content rank high and look good on social media. %1$sLearn more%2$s%3$s","wordpress-seo"),"<a>","<ArrowNarrowRightIcon />","</a>"),C)})]}),u&&(0,ge.jsx)(i.Alert,{className:"yst-my-4",children:(0,z.sprintf)(/* translators: %s is for Yoast SEO Premium. */
(0,z.__)("Oh no! Its seems like you're out of free Sparks. Keep the momentum going, unlock unlimited sparks with %s!","wordpress-seo"),"Yoast SEO Premium")}),(0,ge.jsxs)("div",{className:dt()("yst-w-full yst-flex yst-flex-col",u?"yst-mt-0":"yst-mt-6"),children:[(0,ge.jsxs)(i.Button,{as:"a",className:"yst-grow",size:"extra-large",variant:"upsell",href:x,target:"_blank",ref:h,"data-action":"load-nfd-ctb","data-ctb-id":w,children:[(0,ge.jsx)(Ve,{className:"yst--ms-1 yst-me-2 yst-h-5 yst-w-5"}),y,(0,ge.jsx)("span",{className:"yst-sr-only",children:/* translators: Hidden accessibility text. */
(0,z.__)("(Opens in a new browser tab)","wordpress-seo")})]}),!u&&(0,ge.jsx)(V.GradientButton,{onClick:j,className:"yst-mt-2 yst-w-full yst-text-base yst-text-slate-800 yst-font-medium yst-h-11 hover:yst-bg-gradient-to-l hover:yst-from-indigo-100 hover:yst-to-primary-100",children:(0,z.__)("Try for free","wordpress-seo")})]}),(0,ge.jsx)(i.Button,{as:"a",className:"yst-mt-4",variant:"tertiary",onClick:m,children:(0,z.__)("Close","wordpress-seo")})]})]})},Nt=({isOpen:e,onClose:t,closeButtonScreenReaderText:s,panelRef:r,title:o,aiModalHelperLink:a,children:n})=>{const l=(0,i.useSvgAria)();return(0,ge.jsx)(i.Modal,{className:"yst-ai-modal",isOpen:e,onClose:t,children:(0,ge.jsx)(i.Modal.Panel,{ref:r,className:"yst-max-w-3xl yst-relative",closeButtonScreenReaderText:s,children:(0,ge.jsxs)(i.Modal.Container,{children:[(0,ge.jsxs)(i.Modal.Container.Header,{children:[(0,ge.jsxs)("div",{className:"yst-flex yst-items-center",children:[(0,ge.jsx)("span",{className:"yst-logo-icon yst-h-5 yst-w-5"}),(0,ge.jsx)(i.Modal.Title,{className:"yst-ms-3 yst-me-1.5",as:"h1",size:"2",children:o}),(0,ge.jsx)(i.Link,{id:"ai-modal-learn-more",href:a,variant:"primary",className:"yst-no-underline yst-me-2",target:"_blank",rel:"noopener"
/* translators: Hidden accessibility text. */,"aria-label":(0,z.__)("Learn more about AI (Opens in a new browser tab)","wordpress-seo"),children:(0,ge.jsx)(D,{...l,className:"yst-w-4 yst-h-4 yst-text-slate-500 yst-shrink-0"})}),(0,ge.jsx)(i.Badge,{variant:"info",children:(0,z.__)("Beta","wordpress-seo")})]}),(0,ge.jsx)("hr",{className:"yst-mt-6 yst--mx-6"})]}),n]})})})},Mt=({isOpen:e,onClose:t,closeButtonScreenReaderText:s,children:r})=>(0,ge.jsx)(i.Modal,{className:"yst-introduction-modal",isOpen:e,onClose:t,children:(0,ge.jsx)(i.Modal.Panel,{className:"yst-max-w-lg yst-p-0 yst-rounded-3xl",closeButtonScreenReaderText:s,children:r})}),At={inactive:"inactive",askConsent:"askConsent",upsell:"upsell",error:"error",generate:"generate"},$t=({onUseAi:e})=>{const[s,r]=(0,H.useState)(At.inactive),{editType:o,previewType:a}=Ie(),n=Te(),l=(()=>{const{editType:e,previewType:t}=Ie();switch(t){case Q:return e===se?(0,z.__)("AI social description generator","wordpress-seo"):(0,z.__)("AI social title generator","wordpress-seo");case ee:return e===se?(0,z.__)("AI X description generator","wordpress-seo"):(0,z.__)("AI X title generator","wordpress-seo");default:return e===se?(0,z.__)("AI description generator","wordpress-seo"):(0,z.__)("AI title generator","wordpress-seo")}})(),{hasConsent:c,promptContentInitialized:d,currentSubscriptions:u,usageCountStatus:p,usageCount:m,usageCountLimit:h,usageCountEndpoint:g,hasValidPremiumSubscription:y,hasValidWooSubscription:x,focusKeyphrase:w,isPremium:f,isSeoAnalysisActive:v,aiModalHelperLink:b,isWooProductEntity:S,isFreeSparksActive:k,isWooSeoActive:_}=(0,t.useSelect)((e=>{const t=e(Z),s=e(X);return{hasConsent:t.selectHasAiGeneratorConsent(),promptContentInitialized:t.selectPromptContentInitialized(),currentSubscriptions:t.selectProductSubscriptions(),usageCountStatus:t.selectUsageCountStatus(),usageCount:t.selectUsageCount(),usageCountLimit:t.selectUsageCountLimit(),usageCountEndpoint:t.selectUsageCountEndpoint(),hasValidPremiumSubscription:t.selectPremiumSubscription(),hasValidWooSubscription:t.selectWooCommerceSubscription(),focusKeyphrase:s.getFocusKeyphrase(),isPremium:s.getIsPremium(),isWooSeoActive:s.getIsWooSeoActive(),isSeoAnalysisActive:s.getPreference("isKeywordAnalysisActive",!0),aiModalHelperLink:s.selectLink("https://yoa.st/ai-generator-help-button-modal"),isWooProductEntity:s.getIsWooProductEntity(),isFreeSparksActive:e(Z).selectIsFreeSparksActive()}}),[]),{fetchUsageCount:j}=(0,t.useDispatch)(Z),{closeEditorModal:C}=(0,t.useDispatch)(X),E=(0,z.__)("Close modal","wordpress-seo"),[R,I]=(0,H.useState)(!1),[L,T]=(0,H.useState)(0),N=(0,H.useCallback)((e=>T(e.borderBoxSize[0].blockSize)),[T]),M=Pe(N),A={onClose:(0,H.useCallback)((()=>{r(At.inactive)}),[]),closeButtonScreenReaderText:E},$=(0,H.useCallback)((()=>!ke(w)),[w]),F=(0,H.useCallback)((()=>{C(),setTimeout((()=>(e=>{const t=`focus-keyword-input-${"modal"===e?"sidebar":e}`;if("metabox"===e){const e=document.getElementById("wpseo-meta-tab-content");e&&e.click()}const s=document.getElementById(t);s&&s.focus()})(n)),0)}),[C,n]),q=(0,H.useCallback)((()=>S?x&&y:y),[y,x,S]),U=(0,H.useCallback)((async()=>{if(e(),!v)return void r(At.error);if(!$())return r(At.inactive),void F();const t=q();if(!t&&f&&_&&S)return void r(At.error);if(!t&&f&&!S)return void r(At.error);if(!c&&(k||t))return void r(At.askConsent);I(!0);const{type:s,payload:i}=await j({endpoint:g,isWooProductEntity:S}),o=429===(null==i?void 0:i.errorCode)&&!(null!=i&&i.errorIdentifier)&&0===(null==i?void 0:i.missingLicenses.length),a=429===(null==i?void 0:i.errorCode)&&"USAGE_LIMIT_REACHED"===(null==i?void 0:i.errorIdentifier)||i.count>=i.limit;I(!1),o?r(At.error):403!==(null==i?void 0:i.errorCode)||!k&&!t?s!==Ue||429===(null==i?void 0:i.errorCode)||403===(null==i?void 0:i.errorCode)?s===Ue&&429===(null==i?void 0:i.errorCode)&&t?r(At.error):!t&&!k||!t&&a?r(At.upsell):(t&&c&&r(At.generate),!t&&k&&!a&&c&&r(At.generate)):r(At.error):r(At.askConsent)}),[e,f,k,c,v,$,F,g,j,_,S,R]),O=(0,H.useCallback)((async()=>{const{type:e,payload:t}=await j({endpoint:g,isWooProductEntity:S}),s=429===(null==t?void 0:t.errorCode)||t.count>=t.limit,i=q();r(!s||i?e!==Ue?At.generate:At.error:At.upsell)}),[r,g,j,q,S]),W=(0,H.useCallback)((()=>{r(c?At.generate:At.askConsent)}),[r,c]),B=(0,H.useMemo)((()=>"google"===a?"title"===o?(0,z.__)("Generate SEO title","wordpress-seo"):(0,z.__)("Generate meta description","wordpress-seo"):"social"===a||"twitter"===a?"title"===o?(0,z.__)("Generate social title","wordpress-seo"):(0,z.__)("Generate social description","wordpress-seo"):void 0),[a,o]);return(0,ge.jsxs)(ge.Fragment,{children:[(0,ge.jsx)(V.GradientButton,{type:"button",id:`yst-replacevar__use-ai-button__${o}__${n}`,className:"yst-replacevar__use-ai-button",onClick:U,disabled:p===P||!d,isLoading:R&&p===P,children:B}),(0,ge.jsxs)(Mt,{...A,isOpen:[At.askConsent,At.upsell].includes(s),children:[s===At.askConsent&&(0,ge.jsx)(Ct,{onStartGenerating:O}),s===At.upsell&&(0,ge.jsx)(Pt,{onActivateFreeSparks:W})]}),(0,ge.jsxs)(Nt,{...A,isOpen:[At.error,At.generate].includes(s),aiModalHelperLink:b,panelRef:M,title:l,children:[s===At.error&&(0,ge.jsx)(i.Modal.Container.Content,{className:"yst-pt-6",children:(0,ge.jsx)(jt,{currentSubscriptions:u,isSeoAnalysisActive:v})}),s===At.generate&&(0,ge.jsxs)(ge.Fragment,{children:[(0,ge.jsx)(V.UsageCounter,{limit:h,requests:m,isSkeleton:!1,className:"yst-absolute yst-top-[-11px] yst-end-12 sm:yst-end-16",mentionBetaInTooltip:f,mentionResetInTooltip:f}),(0,ge.jsx)(Tt,{height:L})]})]})]})};$t.propTypes={onUseAi:K().func.isRequired};const Ft=({title:e,description:s,status:r,titleForLength:o,showPreviewSkeleton:a,showLengthProgress:n})=>{const l=(0,t.useSelect)((e=>e(X).getSnippetEditorMode()),[]),[c,d]=(0,H.useState)(l),{editType:u}=Ie(),p=Te(),m=(({editType:e,title:s,description:r})=>{const i=(0,t.useSelect)((e=>e(X).getDateFromSettings()),[]),o=(0,t.useSelect)((e=>e(X).getContentLocale()),[]),a=(0,t.useSelect)((e=>e(X).isCornerstoneContent()),[]),n=(0,t.useSelect)((e=>e(X).getIsTerm()),[]);return(0,H.useMemo)((()=>e===se?(0,Ae.getDescriptionProgress)(r,i,a,n,o):(0,Ae.getTitleProgress)(s)),[e,s,r,i,a,n,o])})({editType:u,title:o,description:s});return(0,ge.jsxs)(ge.Fragment,{children:[(0,ge.jsxs)("div",{className:"yst-mb-2 lg:yst-flex",children:[(0,ge.jsx)(i.Label,{as:"span",className:"yst-flex-grow yst-cursor-default",children:(0,z.__)("Google preview","wordpress-seo")}),(0,ge.jsx)(Bt,{mode:c,idSuffix:p,onChange:d,disabled:r===le.loading})]}),a?(0,ge.jsx)(Ot,{}):(0,ge.jsx)(Ut,{mode:c,title:e,description:s}),(0,ge.jsxs)("div",{className:"yst-pt-4",children:[(0,ge.jsx)(i.Label,{as:"span",className:"yst-flex-grow yst-cursor-default",children:u===te?(0,z.__)("SEO title width","wordpress-seo"):(0,z.__)("Meta description length","wordpress-seo")}),(0,ge.jsx)(Wt,{className:"yst-mt-2",progress:n?m.actual:0,min:0,max:m.max,score:m.score})]})]})};Ft.propTypes={title:K().string.isRequired,description:K().string.isRequired,status:K().oneOf(Object.keys(le)).isRequired,titleForLength:K().string.isRequired,showPreviewSkeleton:K().bool.isRequired,showLengthProgress:K().bool.isRequired};const qt=/mobi/i,Ut=({mode:e,title:s,description:r})=>{var i,a;const n=(0,t.useSelect)((e=>e(X).getBaseUrlFromSettings()),[]),l=(0,t.useSelect)((e=>e(X).getSnippetEditorData().slug||""),[]),c=(0,t.useSelect)((e=>e(X).getDateFromSettings()),[]),d=(0,t.useSelect)((e=>e(X).getFocusKeyphrase()),[]),u=(0,t.useSelect)((e=>e(X).getSnippetEditorPreviewImageUrl()),[]),p=(0,t.useSelect)((e=>e(X).getSiteIconUrlFromSettings()),[]),m=(0,t.useSelect)((e=>e(X).getShoppingData()),[]),h=(0,t.useSelect)((e=>e(X).getSnippetEditorWordsToHighlight()),[]),g=(0,t.useSelect)((e=>e(X).getSiteName()),[]),y=(0,t.useSelect)((e=>e(X).getContentLocale()),[]),x=(0,H.useMemo)((()=>n+l),[n,l]),w=(0,H.useMemo)((()=>{var e,t;return qt.test(null===(e=window)||void 0===e||null===(t=e.navigator)||void 0===t?void 0:t.userAgent)}),[null===(i=window)||void 0===i||null===(a=i.navigator)||void 0===a?void 0:a.userAgent]);return(0,ge.jsx)("div",{className:`yst-bg-slate-200 yst--mx-6 ${e}${w?" yst-user-agent__mobile":""}`,children:(0,ge.jsx)(Ae.SnippetPreview,{title:s,description:r,mode:e,url:x,keyword:d,date:c,faviconSrc:p,mobileImageSrc:u,wordsToHighlight:h,siteName:g,locale:y,shoppingData:m,onMouseUp:o.noop})})};Ut.propTypes={mode:K().oneOf(Object.keys(ne)).isRequired,title:K().string.isRequired,description:K().string.isRequired};const Ot=()=>(0,ge.jsxs)("div",{className:"yst-max-w-[400px] yst-py-4 yst-px-3 yst-border yst-rounded-lg yst-w-full yst-mx-auto",children:[(0,ge.jsxs)("div",{className:"yst-flex yst-gap-x-3",children:[(0,ge.jsx)(i.SkeletonLoader,{className:"yst-flex-shrink-0 yst-h-7 yst-w-7 yst-rounded-full"}),(0,ge.jsxs)("div",{className:"yst-flex yst-flex-col yst-w-full yst-gap-y-1",children:[(0,ge.jsx)(i.SkeletonLoader,{className:"yst-h-3 yst-w-1/3"}),(0,ge.jsx)(i.SkeletonLoader,{className:"yst-h-2.5 yst-w-10/12"})]})]}),(0,ge.jsx)(i.SkeletonLoader,{className:"yst-h-4 yst-w-full yst-mt-6 yst-mb-4"}),(0,ge.jsx)(i.SkeletonLoader,{className:"yst-h-3 yst-w-full"}),(0,ge.jsx)(i.SkeletonLoader,{className:"yst-h-3 yst-w-10/12 yst-mt-2.5"})]}),Wt=({className:e="",progress:t,max:s,score:r})=>{const o=(0,H.useMemo)((()=>(e=>e>=7?"yst-score-good":e>=5?"yst-score-ok":"yst-score-bad")(r)),[r]);return(0,ge.jsx)(i.ProgressBar,{className:dt()("yst-length-progress-bar",o,e),progress:t,min:0,max:s})};Wt.propTypes={className:K().string,progress:K().number.isRequired,max:K().number.isRequired,score:K().number.isRequired};const Bt=({idSuffix:e,mode:t,onChange:s,disabled:r})=>{const o=(0,H.useCallback)((({target:e})=>e.checked&&s(e.value)),[s]);return(0,ge.jsxs)(i.RadioGroup,{id:`yst-ai-mode__${e}`,className:"yst-ai-mode yst-pt-2 lg:yst-pt-0",disabled:r,children:[(0,ge.jsx)(i.RadioGroup.Radio,{id:`yst-ai-mode__mobile__${e}`,name:`yst-ai-mode__${e}`,label:(0,z.__)("Mobile result","wordpress-seo"),value:ne.mobile,checked:t===ne.mobile,onChange:o,disabled:r}),(0,ge.jsx)(i.RadioGroup.Radio,{id:`yst-ai-mode__desktop__${e}`,name:`yst-ai-mode__${e}`,label:(0,z.__)("Desktop result","wordpress-seo"),value:ne.desktop,checked:t===ne.desktop,onChange:o,disabled:r})]})};Bt.propTypes={idSuffix:K().string.isRequired,mode:K().oneOf(Object.keys(ne)).isRequired,onChange:K().func.isRequired,disabled:K().bool.isRequired};const Gt=({title:e,description:t,showPreviewSkeleton:s})=>(0,ge.jsxs)("div",{children:[(0,ge.jsx)("div",{className:"yst-flex yst-mb-6",children:(0,ge.jsx)(i.Label,{as:"span",className:"yst-flex-grow yst-cursor-default",children:(0,z.__)("Social preview","wordpress-seo")})}),s?(0,ge.jsx)(Ws,{}):(0,ge.jsx)(Os,{title:e,description:t})]});Gt.propTypes={title:K().string.isRequired,description:K().string.isRequired,showPreviewSkeleton:K().bool.isRequired};const Dt=window.yoast.styledComponents;var Ht=s.n(Dt);const zt=Ht().p`
color: #606770;
flex-shrink: 0;
font-size: 12px;
line-height: 16px;
overflow: hidden;
padding: 0;
text-overflow: ellipsis;
text-transform: uppercase;
white-space: nowrap;
margin: 0;
position: ${e=>"landscape"===e.mode?"relative":"static"};
`,Vt=e=>{const{siteUrl:t}=e;return(0,ge.jsxs)(B.Fragment,{children:[(0,ge.jsx)("span",{className:"screen-reader-text",children:t}),(0,ge.jsx)(zt,{"aria-hidden":"true",children:(0,ge.jsx)("span",{children:t})})]})};Vt.propTypes={siteUrl:K().string.isRequired};const Yt=Vt,Kt=window.yoast.socialMetadataForms,Zt=window.yoast.styleGuide,Xt=Ht().img`
&& {
max-width: ${e=>e.width}px;
height: ${e=>e.height}px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
max-width: none;
}
`,Jt=Ht().img`
&& {
height: 100%;
position: absolute;
width: 100%;
object-fit: cover;
}
`,Qt=Ht().div`
padding-bottom: ${e=>e.aspectRatio}%;
`,es=({imageProps:e,width:t,height:s,imageMode:r="landscape"})=>"landscape"===r?(0,ge.jsx)(Qt,{aspectRatio:e.aspectRatio,children:(0,ge.jsx)(Jt,{src:e.src,alt:e.alt})}):(0,ge.jsx)(Xt,{src:e.src,alt:e.alt,width:t,height:s,imageProperties:e});function ts(e,t,s){return"landscape"===s?{widthRatio:t.width/e.landscapeWidth,heightRatio:t.height/e.landscapeHeight}:"portrait"===s?{widthRatio:t.width/e.portraitWidth,heightRatio:t.height/e.portraitHeight}:{widthRatio:t.width/e.squareWidth,heightRatio:t.height/e.squareHeight}}function ss(e,t){return t.widthRatio<=t.heightRatio?{width:Math.round(e.width/t.widthRatio),height:Math.round(e.height/t.widthRatio)}:{width:Math.round(e.width/t.heightRatio),height:Math.round(e.height/t.heightRatio)}}async function rs(e,t,s=!1){const r=await function(e){return new Promise(((t,s)=>{const r=new Image;r.onload=()=>{t({width:r.width,height:r.height})},r.onerror=s,r.src=e}))}(e);let i=s?"landscape":"square";"Facebook"===t&&(i=(0,Kt.determineFacebookImageMode)(r));const o=function(e){return"Twitter"===e?Kt.TWITTER_IMAGE_SIZES:Kt.FACEBOOK_IMAGE_SIZES}(t),a=function(e,t,s){return"square"===s&&t.width===t.height?{width:e.squareWidth,height:e.squareHeight}:ss(t,ts(e,t,s))}(o,r,i);return{mode:i,height:a.height,width:a.width}}async function is(e,t,s=!1){try{return{imageProperties:await rs(e,t,s),status:"loaded"}}catch(e){return{imageProperties:null,status:"errored"}}}es.propTypes={imageProps:K().shape({src:K().string.isRequired,alt:K().string.isRequired,aspectRatio:K().number.isRequired}).isRequired,width:K().number.isRequired,height:K().number.isRequired,imageMode:K().string};const os=Ht().div`
position: relative;
${e=>"landscape"===e.mode?`max-width: ${e.dimensions.width}`:`min-width: ${e.dimensions.width}; height: ${e.dimensions.height}`};
overflow: hidden;
background-color: ${Zt.colors.$color_white};
`,as=Ht().div`
box-sizing: border-box;
max-width: ${Kt.FACEBOOK_IMAGE_SIZES.landscapeWidth}px;
height: ${Kt.FACEBOOK_IMAGE_SIZES.landscapeHeight}px;
background-color: ${Zt.colors.$color_grey};
border-style: dashed;
border-width: 1px;
// We're not using standard colors to increase contrast for accessibility.
color: #006DAC;
// We're not using standard colors to increase contrast for accessibility.
background-color: #f1f1f1;
display: flex;
justify-content: center;
align-items: center;
text-decoration: underline;
font-size: 14px;
cursor: pointer;
`;class ns extends B.Component{constructor(e){super(e),this.state={imageProperties:null,status:"loading"},this.socialMedium="Facebook",this.handleFacebookImage=this.handleFacebookImage.bind(this),this.setState=this.setState.bind(this)}async handleFacebookImage(){try{const e=await is(this.props.src,this.socialMedium);this.setState(e),this.props.onImageLoaded(e.imageProperties.mode||"landscape")}catch(e){this.setState(e),this.props.onImageLoaded("landscape")}}componentDidUpdate(e){e.src!==this.props.src&&this.handleFacebookImage()}componentDidMount(){this.handleFacebookImage()}retrieveContainerDimensions(e){switch(e){case"square":return{height:Kt.FACEBOOK_IMAGE_SIZES.squareHeight+"px",width:Kt.FACEBOOK_IMAGE_SIZES.squareWidth+"px"};case"portrait":return{height:Kt.FACEBOOK_IMAGE_SIZES.portraitHeight+"px",width:Kt.FACEBOOK_IMAGE_SIZES.portraitWidth+"px"};case"landscape":return{height:Kt.FACEBOOK_IMAGE_SIZES.landscapeHeight+"px",width:Kt.FACEBOOK_IMAGE_SIZES.landscapeWidth+"px"}}}render(){const{imageProperties:e,status:t}=this.state;if("loading"===t||""===this.props.src||"errored"===t)return(0,ge.jsx)(as,{onClick:this.props.onImageClick,onMouseEnter:this.props.onMouseEnter,onMouseLeave:this.props.onMouseLeave,children:(0,z.__)("Select image","wordpress-seo")});const s=this.retrieveContainerDimensions(e.mode);return(0,ge.jsx)(os,{mode:e.mode,dimensions:s,onMouseEnter:this.props.onMouseEnter,onMouseLeave:this.props.onMouseLeave,onClick:this.props.onImageClick,children:(0,ge.jsx)(es,{imageProps:{src:this.props.src,alt:this.props.alt,aspectRatio:Kt.FACEBOOK_IMAGE_SIZES.aspectRatio},width:e.width,height:e.height,imageMode:e.mode})})}}ns.propTypes={src:K().string,alt:K().string,onImageLoaded:K().func,onImageClick:K().func,onMouseEnter:K().func,onMouseLeave:K().func},ns.defaultProps={src:"",alt:"",onImageLoaded:o.noop,onImageClick:o.noop,onMouseEnter:o.noop,onMouseLeave:o.noop};const ls=ns,cs=Ht().span`
line-height: ${20}px;
min-height : ${20}px;
color: #1d2129;
font-weight: 600;
overflow: hidden;
font-size: 16px;
margin: 3px 0 0;
letter-spacing: normal;
white-space: normal;
flex-shrink: 0;
cursor: pointer;
display: -webkit-box;
-webkit-line-clamp: ${e=>e.lineCount};
-webkit-box-orient: vertical;
overflow: hidden;
`,ds=Ht().p`
line-height: ${16}px;
min-height : ${16}px;
color: #606770;
font-size: 14px;
padding: 0;
text-overflow: ellipsis;
margin: 3px 0 0 0;
display: -webkit-box;
cursor: pointer;
-webkit-line-clamp: ${e=>e.lineCount};
-webkit-box-orient: vertical;
overflow: hidden;
@media all and ( max-width: ${e=>e.maxWidth} ) {
display: none;
}
`,us=e=>{switch(e){case"landscape":return"527px";case"square":case"portrait":return"369px";default:return"476px"}},ps=Ht().div`
box-sizing: border-box;
display: flex;
flex-direction: ${e=>"landscape"===e.mode?"column":"row"};
background-color: #f2f3f5;
max-width: 527px;
`,ms=Ht().div`
box-sizing: border-box;
background-color: #f2f3f5;
margin: 0;
padding: 10px 12px;
position: relative;
border-bottom: ${e=>"landscape"===e.mode?"":"1px solid #dddfe2"};
border-top: ${e=>"landscape"===e.mode?"":"1px solid #dddfe2"};
border-right: ${e=>"landscape"===e.mode?"":"1px solid #dddfe2"};
border: ${e=>"landscape"===e.mode?"1px solid #dddfe2":""};
display: flex;
flex-direction: column;
flex-grow: 1;
justify-content: ${e=>"landscape"===e.mode?"flex-start":"center"};
font-size: 12px;
overflow: hidden;
`;class hs extends B.Component{constructor(e){super(e),this.state={imageMode:null,maxLineCount:0,descriptionLineCount:0},this.facebookTitleRef=G().createRef(),this.onImageLoaded=this.onImageLoaded.bind(this),this.onImageEnter=this.props.onMouseHover.bind(this,"image"),this.onTitleEnter=this.props.onMouseHover.bind(this,"title"),this.onDescriptionEnter=this.props.onMouseHover.bind(this,"description"),this.onLeave=this.props.onMouseHover.bind(this,""),this.onSelectTitle=this.props.onSelect.bind(this,"title"),this.onSelectDescription=this.props.onSelect.bind(this,"description")}onImageLoaded(e){this.setState({imageMode:e})}getTitleLineCount(){return this.facebookTitleRef.current.offsetHeight/20}maybeSetMaxLineCount(){const{imageMode:e,maxLineCount:t}=this.state,s="landscape"===e?2:5;s!==t&&this.setState({maxLineCount:s})}maybeSetDescriptionLineCount(){const{descriptionLineCount:e,maxLineCount:t,imageMode:s}=this.state,r=this.getTitleLineCount();let i=t-r;"portrait"===s&&(i=5===r?0:4),i!==e&&this.setState({descriptionLineCount:i})}componentDidUpdate(){this.maybeSetMaxLineCount(),this.maybeSetDescriptionLineCount()}render(){const{imageMode:e,maxLineCount:t,descriptionLineCount:s}=this.state;return(0,ge.jsxs)(ps,{id:"facebookPreview",mode:e,children:[(0,ge.jsx)(ls,{src:this.props.imageUrl||this.props.imageFallbackUrl,alt:this.props.alt,onImageLoaded:this.onImageLoaded,onImageClick:this.props.onImageClick,onMouseEnter:this.onImageEnter,onMouseLeave:this.onLeave}),(0,ge.jsxs)(ms,{mode:e,children:[(0,ge.jsx)(Yt,{siteUrl:this.props.siteUrl,mode:e}),(0,ge.jsx)(cs,{ref:this.facebookTitleRef,onMouseEnter:this.onTitleEnter,onMouseLeave:this.onLeave,onClick:this.onSelectTitle,lineCount:t,children:this.props.title}),s>0&&(0,ge.jsx)(ds,{maxWidth:us(e),onMouseEnter:this.onDescriptionEnter,onMouseLeave:this.onLeave,onClick:this.onSelectDescription,lineCount:s,children:this.props.description})]})]})}}hs.propTypes={siteUrl:K().string.isRequired,title:K().string.isRequired,description:K().string,imageUrl:K().string,imageFallbackUrl:K().string,alt:K().string,onSelect:K().func,onImageClick:K().func,onMouseHover:K().func},hs.defaultProps={description:"",alt:"",imageUrl:"",imageFallbackUrl:"",onSelect:()=>{},onImageClick:()=>{},onMouseHover:()=>{}};const gs=hs,ys=Ht().div`
text-transform: lowercase;
color: rgb(83, 100, 113);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
margin: 0;
fill: currentcolor;
display: flex;
flex-direction: row;
align-items: flex-end;
`,xs=e=>(0,ge.jsx)(ys,{children:(0,ge.jsx)("span",{children:e.siteUrl})});xs.propTypes={siteUrl:K().string.isRequired};const ws=xs,fs=(e,t=!0)=>e?`\n\t\t\tmax-width: ${Kt.TWITTER_IMAGE_SIZES.landscapeWidth}px;\n\t\t\t${t?"border-bottom: 1px solid #E1E8ED;":""}\n\t\t\tborder-radius: 14px 14px 0 0;\n\t\t\t`:`\n\t\twidth: ${Kt.TWITTER_IMAGE_SIZES.squareWidth}px;\n\t\t${t?"border-right: 1px solid #E1E8ED;":""}\n\t\tborder-radius: 14px 0 0 14px;\n\t\t`,vs=Ht().div`
position: relative;
box-sizing: content-box;
overflow: hidden;
background-color: #e1e8ed;
flex-shrink: 0;
${e=>fs(e.isLarge)}
`,bs=Ht().div`
display: flex;
justify-content: center;
align-items: center;
box-sizing: border-box;
max-width: 100%;
margin: 0;
padding: 1em;
text-align: center;
font-size: 1rem;
${e=>fs(e.isLarge,!1)}
`,Ss=Ht()(bs)`
${e=>e.isLarge&&`height: ${Kt.TWITTER_IMAGE_SIZES.landscapeHeight}px;`}
border-top-left-radius: 14px;
${e=>e.isLarge?"border-top-right-radius":"border-bottom-left-radius"}: 14px;
border-style: dashed;
border-width: 1px;
// We're not using standard colors to increase contrast for accessibility.
color: #006DAC;
// We're not using standard colors to increase contrast for accessibility.
background-color: #f1f1f1;
text-decoration: underline;
font-size: 14px;
cursor: pointer;
`;class ks extends G().Component{constructor(e){super(e),this.state={status:"loading"},this.socialMedium="Twitter",this.handleTwitterImage=this.handleTwitterImage.bind(this),this.setState=this.setState.bind(this)}async handleTwitterImage(){if(null===this.props.src)return;const e=await is(this.props.src,this.socialMedium,this.props.isLarge);this.setState(e)}componentDidUpdate(e){e.src!==this.props.src&&this.handleTwitterImage()}componentDidMount(){this.handleTwitterImage()}render(){const{status:e,imageProperties:t}=this.state;return"loading"===e||""===this.props.src||"errored"===e?(0,ge.jsx)(Ss,{isLarge:this.props.isLarge,onClick:this.props.onImageClick,onMouseEnter:this.props.onMouseEnter,onMouseLeave:this.props.onMouseLeave,children:(0,z.__)("Select image","wordpress-seo")}):(0,ge.jsx)(vs,{isLarge:this.props.isLarge,onClick:this.props.onImageClick,onMouseEnter:this.props.onMouseEnter,onMouseLeave:this.props.onMouseLeave,children:(0,ge.jsx)(es,{imageProps:{src:this.props.src,alt:this.props.alt,aspectRatio:Kt.TWITTER_IMAGE_SIZES.aspectRatio},width:t.width,height:t.height,imageMode:t.mode})})}}ks.propTypes={isLarge:K().bool.isRequired,src:K().string,alt:K().string,onImageClick:K().func,onMouseEnter:K().func,onMouseLeave:K().func},ks.defaultProps={src:"",alt:"",onMouseEnter:o.noop,onImageClick:o.noop,onMouseLeave:o.noop};const _s=Ht().div`
display: flex;
flex-direction: column;
padding: 12px;
justify-content: center;
margin: 0;
box-sizing: border-box;
flex: auto;
min-width: 0px;
gap:2px;
> * {
line-height:20px;
min-height:20px;
font-size:15px;
}
`,js=e=>(0,ge.jsx)(_s,{children:e.children});js.propTypes={children:K().array.isRequired};const Cs=js,Es=Ht().p`
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
margin: 0;
color: rgb(15, 20, 25);
cursor: pointer;
`,Rs=Ht().p`
max-height: 55px;
overflow: hidden;
text-overflow: ellipsis;
margin: 0;
color: rgb(83, 100, 113);
display: -webkit-box;
cursor: pointer;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
@media all and ( max-width: ${Kt.TWITTER_IMAGE_SIZES.landscapeWidth}px ) {
display: none;
}
`,Is=Ht().div`
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", sans-serif;
font-size: 15px;
font-weight: 400;
line-height: 20px;
max-width: 507px;
border: 1px solid #E1E8ED;
box-sizing: border-box;
border-radius: 14px;
color: #292F33;
background: #FFFFFF;
text-overflow: ellipsis;
display: flex;
&:hover {
background: #f5f8fa;
border: 1px solid rgba(136,153,166,.5);
}
`,Ls=Ht()(Is)`
flex-direction: column;
max-height: 370px;
`,Ts=Ht()(Is)`
flex-direction: row;
height: 125px;
`;class Ps extends B.Component{constructor(e){super(e),this.onImageEnter=this.props.onMouseHover.bind(this,"image"),this.onTitleEnter=this.props.onMouseHover.bind(this,"title"),this.onDescriptionEnter=this.props.onMouseHover.bind(this,"description"),this.onLeave=this.props.onMouseHover.bind(this,""),this.onSelectTitle=this.props.onSelect.bind(this,"title"),this.onSelectDescription=this.props.onSelect.bind(this,"description")}render(){const{isLarge:e,imageUrl:t,imageFallbackUrl:s,alt:r,title:i,description:o,siteUrl:a}=this.props,n=e?Ls:Ts;return(0,ge.jsxs)(n,{id:"twitterPreview",children:[(0,ge.jsx)(ks,{src:t||s,alt:r,isLarge:e,onImageClick:this.props.onImageClick,onMouseEnter:this.onImageEnter,onMouseLeave:this.onLeave}),(0,ge.jsxs)(Cs,{children:[(0,ge.jsx)(ws,{siteUrl:a}),(0,ge.jsx)(Es,{onMouseEnter:this.onTitleEnter,onMouseLeave:this.onLeave,onClick:this.onSelectTitle,children:i}),(0,ge.jsx)(Rs,{onMouseEnter:this.onDescriptionEnter,onMouseLeave:this.onLeave,onClick:this.onSelectDescription,children:o})]})]})}}Ps.propTypes={siteUrl:K().string.isRequired,title:K().string.isRequired,description:K().string,isLarge:K().bool,imageUrl:K().string,imageFallbackUrl:K().string,alt:K().string,onSelect:K().func,onImageClick:K().func,onMouseHover:K().func},Ps.defaultProps={description:"",alt:"",imageUrl:"",imageFallbackUrl:"",onSelect:()=>{},onImageClick:()=>{},onMouseHover:()=>{},isLarge:!0};const Ns=Ps,Ms=window.yoast.componentsNew,As=window.yoast.replacementVariableEditor;class $s extends B.Component{constructor(e){super(e),this.state={activeField:"",hoveredField:""},this.SocialPreview="Social"===e.socialMediumName?gs:Ns,this.setHoveredField=this.setHoveredField.bind(this),this.setActiveField=this.setActiveField.bind(this),this.setEditorRef=this.setEditorRef.bind(this),this.setEditorFocus=this.setEditorFocus.bind(this)}setHoveredField(e){e!==this.state.hoveredField&&this.setState({hoveredField:e})}setActiveField(e){e!==this.state.activeField&&this.setState({activeField:e},(()=>this.setEditorFocus(e)))}setEditorFocus(e){switch(e){case"title":this.titleEditorRef.focus();break;case"description":this.descriptionEditorRef.focus()}}setEditorRef(e,t){switch(e){case"title":this.titleEditorRef=t;break;case"description":this.descriptionEditorRef=t}}render(){const{onDescriptionChange:e,onTitleChange:t,onSelectImageClick:s,onRemoveImageClick:r,socialMediumName:i,imageWarnings:o,siteUrl:a,description:n,descriptionInputPlaceholder:l,descriptionPreviewFallback:c,imageUrl:d,imageFallbackUrl:u,alt:p,title:m,titleInputPlaceholder:h,titlePreviewFallback:g,replacementVariables:y,recommendedReplacementVariables:x,applyReplacementVariables:w,onReplacementVariableSearchChange:f,isPremium:v,isLarge:b,socialPreviewLabel:S,idSuffix:k,activeMetaTabId:_}=this.props,j=w({title:m||g,description:n||c});return(0,ge.jsxs)(G().Fragment,{children:[S&&(0,ge.jsx)(Ms.SimulatedLabel,{children:S}),(0,ge.jsx)(this.SocialPreview,{onMouseHover:this.setHoveredField,onSelect:this.setActiveField,onImageClick:s,siteUrl:a,title:j.title,description:j.description,imageUrl:d,imageFallbackUrl:u,alt:p,isLarge:b,activeMetaTabId:_}),(0,ge.jsx)(Kt.SocialMetadataPreviewForm,{onDescriptionChange:e,socialMediumName:i,title:m,titleInputPlaceholder:h,onRemoveImageClick:r,imageSelected:!!d,imageUrl:d,imageFallbackUrl:u,onTitleChange:t,onSelectImageClick:s,description:n,descriptionInputPlaceholder:l,imageWarnings:o,replacementVariables:y,recommendedReplacementVariables:x,onReplacementVariableSearchChange:f,onMouseHover:this.setHoveredField,hoveredField:this.state.hoveredField,onSelect:this.setActiveField,activeField:this.state.activeField,isPremium:v,setEditorRef:this.setEditorRef,idSuffix:k})]})}}$s.propTypes={title:K().string.isRequired,onTitleChange:K().func.isRequired,description:K().string.isRequired,onDescriptionChange:K().func.isRequired,imageUrl:K().string.isRequired,imageFallbackUrl:K().string.isRequired,onSelectImageClick:K().func.isRequired,onRemoveImageClick:K().func.isRequired,socialMediumName:K().string.isRequired,alt:K().string,isPremium:K().bool,imageWarnings:K().array,isLarge:K().bool,siteUrl:K().string,descriptionInputPlaceholder:K().string,titleInputPlaceholder:K().string,descriptionPreviewFallback:K().string,titlePreviewFallback:K().string,replacementVariables:As.replacementVariablesShape,recommendedReplacementVariables:As.recommendedReplacementVariablesShape,applyReplacementVariables:K().func,onReplacementVariableSearchChange:K().func,socialPreviewLabel:K().string,idSuffix:K().string,activeMetaTabId:K().string},$s.defaultProps={imageWarnings:[],recommendedReplacementVariables:[],replacementVariables:[],isPremium:!1,isLarge:!0,siteUrl:"",descriptionInputPlaceholder:"",titleInputPlaceholder:"",descriptionPreviewFallback:"",titlePreviewFallback:"",alt:"",applyReplacementVariables:e=>e,onReplacementVariableSearchChange:null,socialPreviewLabel:"",idSuffix:"",activeMetaTabId:""};const Fs={},qs=(e,t,{log:s=console.warn}={})=>{Fs[e]||(Fs[e]=!0,s(t))},Us=(e,t=o.noop)=>{const s={};for(const r in e)Object.hasOwn(e,r)&&Object.defineProperty(s,r,{set:s=>{e[r]=s,t("set",r,s)},get:()=>(t("get",r),e[r])});return s};Us({squareWidth:125,squareHeight:125,landscapeWidth:506,landscapeHeight:265,aspectRatio:50.2},((e,t)=>qs(`@yoast/social-metadata-previews/TWITTER_IMAGE_SIZES/${e}/${t}`,`[@yoast/social-metadata-previews] "TWITTER_IMAGE_SIZES.${t}" is deprecated and will be removed in the future, please use this from @yoast/social-metadata-forms instead.`))),Us({squareWidth:158,squareHeight:158,landscapeWidth:527,landscapeHeight:273,portraitWidth:158,portraitHeight:237,aspectRatio:52.2,largeThreshold:{width:446,height:233}},((e,t)=>qs(`@yoast/social-metadata-previews/FACEBOOK_IMAGE_SIZES/${e}/${t}`,`[@yoast/social-metadata-previews] "FACEBOOK_IMAGE_SIZES.${t}" is deprecated and will be removed in the future, please use this from @yoast/social-metadata-forms instead.`)));const Os=({title:e,description:s})=>{const r=(0,t.useSelect)((e=>e(X).getSiteUrl()),[]),i=(0,t.useSelect)((e=>e(X).getFacebookImageUrl()),[]),a=(0,t.useSelect)((e=>e(X).getEditorDataImageFallback()),[]),n=(0,t.useSelect)((e=>e(X).getFacebookAltText()),[]);return(0,ge.jsx)("div",{className:"yst-bg-slate-200 yst-p-2 yst--mx-6 yst-mx-auto",children:(0,ge.jsx)(gs,{title:e,description:s,siteUrl:r,imageUrl:i,imageFallbackUrl:a,alt:n,onSelect:o.noop,onImageClick:o.noop,onMouseHover:o.noop})})};Os.propTypes={title:K().string.isRequired,description:K().string.isRequired};const Ws=()=>(0,ge.jsxs)("div",{className:"yst-flex yst-flex-col yst-w-[527px] yst-border yst-mx-auto",children:[(0,ge.jsx)(i.SkeletonLoader,{className:"yst-h-[273px] yst-w-full yst-rounded-none yst-border yst-border-dashed"}),(0,ge.jsxs)("div",{className:"yst-w-full yst-p-4 yst-space-y-1",children:[(0,ge.jsx)(i.SkeletonLoader,{className:"yst-h-3 yst-w-1/3"}),(0,ge.jsx)(i.SkeletonLoader,{className:"yst-h-5 yst-w-10/12"}),(0,ge.jsx)(i.SkeletonLoader,{className:"yst-h-3 yst-w-full"})]})]}),Bs=({children:e,onRetry:t})=>{const{onClose:s}=(0,i.useModalContext)();return(0,ge.jsxs)(H.Fragment,{children:[e,(0,ge.jsxs)("div",{className:"yst-mt-6 yst-mb-1 yst-flex yst-space-x-3 rtl:yst-space-x-reverse yst-place-content-end",children:[(0,ge.jsx)(i.Button,{variant:"secondary",onClick:s,children:(0,z.__)("Close","wordpress-seo")}),(0,ge.jsx)(i.Button,{variant:"primary",onClick:t,children:(0,z.__)("Try again","wordpress-seo")})]})]})};Bs.propTypes={children:K().node.isRequired,onRetry:K().func.isRequired};const Gs=({errorCode:e,errorIdentifier:t,invalidSubscriptions:s=[],showActions:r=!1,onRetry:i=o.noop,errorMessage:a=""})=>{switch(e){case 400:switch(t){case"AI_CONTENT_FILTER":return(0,ge.jsx)(vt,{});case"NOT_ENOUGH_CONTENT":return(0,ge.jsx)(gt,{});case"SITE_UNREACHABLE":return(0,ge.jsx)(kt,{});case"WP_HTTP_REQUEST_ERROR":return r?(0,ge.jsx)(Bs,{onRetry:i,children:(0,ge.jsx)(bt,{errorMessage:a})}):(0,ge.jsx)(bt,{errorMessage:a});default:return r?(0,ge.jsx)(Bs,{onRetry:i,children:(0,ge.jsx)(ht,{})}):(0,ge.jsx)(ht,{})}case 402:return(0,ge.jsx)(wt,{invalidSubscriptions:s});case 408:return r?(0,ge.jsx)(Bs,{onRetry:i,children:(0,ge.jsx)(ft,{})}):(0,ge.jsx)(ft,{});case 429:return"USAGE_LIMIT_REACHED"===t?(0,ge.jsx)(wt,{invalidSubscriptions:s}):(0,ge.jsx)(xt,{});case 410:return(0,ge.jsx)(St,{});default:return r?(0,ge.jsx)(Bs,{onRetry:i,children:(0,ge.jsx)(ht,{})}):(0,ge.jsx)(ht,{})}};Gs.propTypes={errorCode:K().number.isRequired,errorIdentifier:K().string.isRequired,invalidSubscriptions:K().array,showActions:K().bool,onRetry:K().func,errorMessage:K().string};const Ds=K().shape({value:K().string.isRequired,label:K().node.isRequired}),Hs=({id:e,name:t,suggestion:s,isChecked:r,onChange:i})=>{const o=(0,H.useCallback)((()=>i(s.value)),[s,i]);return(0,ge.jsxs)("label",{htmlFor:e,className:dt()("yst-flex yst-p-4 yst-items-center yst-border first:yst-rounded-t-md last:yst-rounded-b-md",r&&"yst-z-10 yst-border-primary-500"),children:[(0,ge.jsx)("input",{type:"radio",id:e,name:t,className:"yst-radio__input",value:s.value,checked:r,onChange:o}),(0,ge.jsx)("div",{className:dt()("yst-label yst-radio__label yst-flex yst-flex-wrap yst-items-center",!r&&"yst-text-slate-600"),children:s.label})]})};Hs.propTypes={id:K().string.isRequired,name:K().string.isRequired,suggestion:Ds.isRequired,isChecked:K().bool.isRequired,onChange:K().func.isRequired};const zs=({idSuffix:e,suggestions:t,selected:s,onChange:r})=>(0,ge.jsx)("div",{children:(0,ge.jsx)(i.RadioGroup,{className:"yst-suggestions-radio-group yst-flex yst-flex-col",id:`yst-ai-suggestions-radio-group__${e}`,children:t.map(((t,i)=>(0,ge.jsx)(Hs,{id:`yst-ai-suggestions-radio-${e}__${i}`,name:`ai-suggestion__${e}`,isChecked:t.value===s,onChange:r,suggestion:t},`yst-ai-suggestions-radio-${e}__${i}`)))})});zs.propTypes={idSuffix:K().string.isRequired,suggestions:K().arrayOf(Ds).isRequired,selected:K().string.isRequired,onChange:K().func.isRequired};const Vs=[["yst-h-3 yst-w-full","yst-mt-2.5 yst-h-3 yst-w-9/12"],["yst-h-3 yst-w-full","yst-mt-2.5 yst-h-3 yst-w-7/12"],["yst-h-3 yst-w-full","yst-mt-2.5 yst-h-3 yst-w-10/12"],["yst-h-3 yst-w-full","yst-mt-2.5 yst-h-3 yst-w-11/12"],["yst-h-3 yst-w-full","yst-mt-2.5 yst-h-3 yst-w-8/12"]],Ys=({suggestionClassNames:e=Vs})=>(0,ge.jsx)("div",{className:"yst-flex yst-flex-col yst--space-y-[1px]",children:e.map(((e,t)=>(0,ge.jsxs)("div",{className:"yst-flex yst-p-4 yst-gap-x-3 yst-items-center yst-border first:yst-rounded-t-md last:yst-rounded-b-md",children:[(0,ge.jsx)("input",{type:"radio",disabled:!0,className:"yst-my-0.5"}),(0,ge.jsx)("div",{className:"yst-flex yst-flex-col yst-w-full",children:e.map(((e,s)=>(0,ge.jsx)(i.SkeletonLoader,{className:e},`yst-ai-suggestion-radio-skeleton-${t}__${s}`)))})]},`yst-ai-suggestion-radio-skeleton__${t}`)))});Ys.propTypes={suggestionClassNames:K().arrayOf(K().arrayOf(K().string))};const Ks="ai_generator_tip_notification",Zs=()=>{const e=(0,t.useSelect)((e=>e(X).isAlertDismissed(Ks)),[]),s=(0,t.useSelect)((e=>e(X).getEditorDataContent()),[]),r=(0,t.useSelect)((e=>e(X).getIsWooProductEntity()),[]),[o,,,a]=(0,i.useToggleState)(!1),{editType:n,contentType:l}=Ie(),{dismissAlert:c}=(0,t.useDispatch)(X),d=(0,H.useCallback)((()=>{c(Ks)}),[c]),u=(0,H.useMemo)((()=>n===se?(0,z.__)("%1$sTip%2$s: Improve the accuracy of your generated AI descriptions by writing more content in your page.","wordpress-seo"):(0,z.__)("%1$sTip%2$s: Improve the accuracy of your generated AI titles by writing more content in your page.","wordpress-seo")
/* translators: %1$s and %2$s expand to opening and closing of a span in order to emphasise the word. */),[n]),p=(0,H.useMemo)((()=>((e,t)=>e||t===ie?150:300)(r,l)),[l,r]);return e||o||s.length>p?null:(0,ge.jsxs)(i.Notifications.Notification,{id:"ai-generator-content-tip",variant:"info",dismissScreenReaderLabel:(0,z.__)("Dismiss","wordpress-seo"),children:[he((0,z.sprintf)(u,"<span>","</span>"),{span:(0,ge.jsx)("span",{className:"yst-font-medium yst-text-slate-800"})}),(0,ge.jsxs)("div",{className:"yst-flex yst-mt-3 yst--ms-3 yst-gap-1",children:[(0,ge.jsx)(i.Button,{type:"button",variant:"tertiary",onClick:d,children:(0,z.__)("Don’t show again","wordpress-seo")}),(0,ge.jsx)(i.Button,{type:"button",variant:"tertiary",className:"yst-text-slate-800",onClick:a,children:(0,z.__)("Dismiss","wordpress-seo")})]})]})},Xs=({title:e,description:t,showPreviewSkeleton:s})=>(0,ge.jsxs)("div",{children:[(0,ge.jsx)("div",{className:"yst-flex yst-mb-6",children:(0,ge.jsx)(i.Label,{as:"span",className:"yst-flex-grow yst-cursor-default",children:(0,z.__)("X preview","wordpress-seo")})}),s?(0,ge.jsx)(Qs,{}):(0,ge.jsx)(Js,{title:e,description:t})]});Xs.propTypes={title:K().string.isRequired,description:K().string.isRequired,showPreviewSkeleton:K().bool.isRequired};const Js=({title:e,description:s})=>{const r=(0,t.useSelect)((e=>e(X).getSiteUrl()),[]),i=(0,t.useSelect)((e=>e(X).getTwitterImageUrl()),[]),a=(0,t.useSelect)((e=>e(X).getFacebookImageUrl()),[]),n=(0,t.useSelect)((e=>e(X).getEditorDataImageFallback()),[]),l=(0,t.useSelect)((e=>e(X).getTwitterImageType()),[]),c=(0,t.useSelect)((e=>e(X).getTwitterAltText()),[]);return(0,ge.jsx)("div",{className:"yst-bg-slate-200 yst-p-2 yst--mx-6",children:(0,ge.jsx)(Ns,{title:e,description:s,siteUrl:r,imageUrl:i,imageFallbackUrl:a||n,isLarge:"summary"!==l,alt:c,onSelect:o.noop,onImageClick:o.noop,onMouseHover:o.noop})})};Js.propTypes={title:K().string.isRequired,description:K().string.isRequired};const Qs=()=>(0,ge.jsxs)("div",{className:"yst-flex yst-flex-col yst-max-h-[370px] yst-w-[507px] yst-border yst-rounded-t-[14px] yst-overflow-hidden yst-mx-auto",children:[(0,ge.jsx)(i.SkeletonLoader,{className:"yst-h-[265px] yst-w-full yst-rounded-none yst-border yst-border-dashed"}),(0,ge.jsxs)("div",{className:"yst-w-full yst-p-4 yst-space-y-1",children:[(0,ge.jsx)(i.SkeletonLoader,{className:"yst-h-3 yst-w-1/3"}),(0,ge.jsx)(i.SkeletonLoader,{className:"yst-h-5 yst-w-10/12"}),(0,ge.jsx)(i.SkeletonLoader,{className:"yst-h-3 yst-w-full"})]})]}),er="yst-mt-1 yst-mb-3",tr="yst-flex yst-justify-end yst--me-8 yst-gap-3 yst--ms-2",sr=({onClose:e})=>(0,ge.jsxs)(ge.Fragment,{children:[(0,ge.jsx)("p",{className:er,children:(0,z.__)("As long as this is a beta feature, you get unlimited sparks.","wordpress-seo")}),(0,ge.jsx)("div",{className:tr,children:(0,ge.jsx)(i.Button,{type:"button",variant:"primary",size:"small",onClick:e,children:(0,z.__)("Got it!","wordpress-seo")})})]}),rr=({onClose:e,upsellLink:t,isWooProductEntity:s=!1,ctbId:r="f6a84663-465f-4cb5-8ba5-f7a6d72224b2"})=>{const o=(0,i.useSvgAria)();return(0,ge.jsxs)(ge.Fragment,{children:[(0,ge.jsx)("p",{className:er,children:(0,z.sprintf)(/* translators: %s expands to Yoast SEO Premium or Yoast WooCommerce SEO. */
(0,z.__)("Keep the momentum going, unlock unlimited sparks with %s!","wordpress-seo"),s?"Yoast WooCommerce SEO":"Yoast SEO Premium")}),(0,ge.jsxs)("div",{className:tr,children:[(0,ge.jsx)(i.Button,{type:"button",variant:"tertiary",size:"small",onClick:e,children:(0,z.__)("Close","wordpress-seo")}),(0,ge.jsxs)(i.Button,{as:"a",size:"small",variant:"upsell",href:t,target:"_blank",rel:"noopener noreferrer","data-action":"load-nfd-ctb","data-ctb-id":r,children:[(0,ge.jsx)(Ve,{className:"yst-w-4 yst-h-4 yst--ms-1 yst-me-2 yst-shrink-0",...o}),(0,z.sprintf)(/* translators: %1$s expands to Yoast SEO Premium or Yoast WooCommerce SEO. */
(0,z.__)("Unlock with %1$s","wordpress-seo"),s?"Yoast WooCommerce SEO":"Yoast SEO Premium"),(0,ge.jsx)("span",{className:"yst-sr-only",children:/* translators: Hidden accessibility text. */
(0,z.__)("(Opens in a new browser tab)","wordpress-seo")})]})]})]})},ir=({className:e=""})=>{const{isUsageCountLimitReached:s,usageCount:r,usageCountLimit:o,premiumUpsellLink:a,wooUpsellLink:n,isWooProductEntity:l,hasValidPremiumSubscription:c,hasValidWooSubscription:d}=(0,t.useSelect)((e=>{const t=e(Z),s=e(X);return{isUsageCountLimitReached:t.isUsageCountLimitReached(),usageCount:t.selectUsageCount(),usageCountLimit:t.selectUsageCountLimit(),premiumUpsellLink:s.selectLink("https://yoa.st/ai-toast-out-of-free-sparks"),wooUpsellLink:s.selectLink("https://yoa.st/ai-toast-out-of-free-sparks-woo"),isWooProductEntity:s.getIsWooProductEntity(),hasValidPremiumSubscription:t.selectPremiumSubscription(),hasValidWooSubscription:t.selectWooCommerceSubscription()}}),[]),u=(0,H.useMemo)((()=>c&&!l||l&&d&&c),[c,l,d]),[p,,m,,h]=(0,i.useToggleState)(r===o);(0,H.useEffect)((()=>{m(u&&r===o||!u&&s)}),[r,o,u,s]);const g=(0,H.useMemo)((()=>l?n:a),[l,n,a]),y=(0,H.useMemo)((()=>l&&!d),[l,d]);return p&&(0,ge.jsx)(i.Notifications.Notification,{id:"ai-sparks-limit",className:e,variant:"info",dismissScreenReaderLabel:(0,z.__)("Close","wordpress-seo"),title:u?(0,z.sprintf)(/* translators: %s is the number of the sparks. */
(0,z._n)("You've used %s spark this month.","You've used %s sparks this month.",o,"wordpress-seo"),o):(0,z.__)("You're out of free sparks!","wordpress-seo"),size:u?"default":"large",children:u?(0,ge.jsx)(sr,{onClose:h}):(0,ge.jsx)(rr,{onClose:h,upsellLink:g,isWooUpsell:y})})},or=()=>{const{setPromptContent:e}=(0,t.dispatch)(Z);return()=>{(e=>{const s=(0,t.select)(X).getIsProduct(),r=(0,t.select)(X).getIsTerm(),i=(0,t.select)(X).getIsWooCommerceActive(),a=s&&i||r?150:300,n=(0,o.get)(window,"YoastSEO.analysis.worker.runResearch",o.noop),l=(0,o.get)(window,"YoastSEO.analysis.collectData",!1);n("getParagraphs",l?pe.Paper.parse(l()):null).then((t=>{let s="";if(t.result){const e=t.result;if(e){let t=0;e.forEach((e=>{e.sentences.forEach((e=>{if(t+=e.tokens.length,t>a)return s;s+=e.text.replace(/[\n\r]+/g," ")})),s+=" ",t+=1}))}}e(s.trimEnd()||".")}))})(e)}},ar=()=>{or(),(0,t.subscribe)((0,o.debounce)((()=>{const{getEditorDataContent:e}=(0,t.select)(X),s=or();return setTimeout(s,1500),((e,t)=>{let s=e();return()=>{const r=e();(0,o.isEqual)(r,s)||(s=r,t((0,o.clone)(r)))}})(e,s)})(),1500,{maxWait:3e3}))};let nr=!1;const lr=()=>{nr||(nr=!0)},cr=(e,t)=>nr?(ke(t)&&e.push((0,z.__)("Please enter a valid focus keyphrase.","wordpress-seo")),e):e,dr="appliedSuggestions",ur=(0,a.createSlice)({name:dr,initialState:{},reducers:{addAppliedSuggestion:(e,{payload:{editType:t,previewType:s,suggestion:r}})=>{e[s]={...e[s],[t]:r}}}}),pr=ur.getInitialState,mr={selectAppliedSuggestions:e=>(0,o.get)(e,dr,{})};mr.selectAppliedSuggestionFor=(0,a.createSelector)([mr.selectAppliedSuggestions,(e,t)=>t],((e,{editType:t,previewType:s})=>(0,o.get)(e,[s,t],"")));const hr=ur.actions,gr=ur.reducer,yr="productSubscriptions",xr=(0,a.createSlice)({name:yr,initialState:{premiumSubscription:!1,wooCommerceSubscription:!1},reducers:{}}),wr=xr.getInitialState,fr={selectProductSubscriptions:e=>(0,o.get)(e,yr,wr()),selectPremiumSubscription:e=>(0,o.get)(e,`${yr}.premiumSubscription`),selectWooCommerceSubscription:e=>(0,o.get)(e,`${yr}.wooCommerceSubscription`)},vr=xr.actions,br=xr.reducer,Sr="promptContent",kr=(0,a.createSlice)({name:Sr,initialState:{content:"",initialized:!1},reducers:{setPromptContent:(e,{payload:t})=>({content:t,initialized:!0})}}),_r=kr.getInitialState,jr={selectPromptContent:e=>(0,o.get)(e,`${Sr}.content`,""),selectPromptContentInitialized:e=>(0,o.get)(e,`${Sr}.initialized`,!1)},Cr=kr.actions,Er=kr.reducer,Rr="freeSparks",Ir="activateFreeSparks",Lr=(0,a.createSlice)({name:Rr,initialState:{isFreeSparksActive:!1,endpoint:"yoast/v1/ai/free_sparks"},extraReducers:e=>{e.addCase(`${Ir}/${I}`,(e=>{e.isFreeSparksActive=!0}))}}),Tr=Lr.getInitialState,Pr={selectFreeSparksActiveEndpoint:e=>(0,o.get)(e,[Rr,"endpoint"],Lr.getInitialState().endpoint),selectIsFreeSparksActive:e=>(0,o.get)(e,[Rr,"isFreeSparksActive"],Lr.getInitialState().isFreeSparksActive)},Nr={...Lr.actions,activateFreeSparks:function*({endpoint:e}){try{yield{type:Ir,payload:e}}catch(e){console.error("Error starting free sparks:",e)}return{type:`${Ir}/${I}`}}},Mr={[Ir]:async({payload:e})=>u()({method:"POST",path:e})},Ar=Lr.reducer,$r=window.wp.domReady,Fr=(s,{fieldId:r,type:o})=>{const a=(0,t.select)(X).getPostType(),n=function(e){return e.startsWith("yoast-google-preview")?J:e.startsWith("social")?Q:e.startsWith("x-")?ee:void 0}(r);if(!n)return s;const l={isRtl:(0,t.select)(X).getPreference("isRtl")},c={editType:o,previewType:n,postType:a,contentType:(0,t.select)(X).getIsTerm()?"term":"post"};return s.push((0,ge.jsx)(e.Fill,{name:`yoast.replacementVariableEditor.additionalButtons.${r}`,children:(0,ge.jsx)(i.Root,{context:l,children:(0,ge.jsx)(Re,{value:c,children:(0,ge.jsx)($t,{onUseAi:lr})})})})),s};s.n($r)()((()=>{window.wpseoScriptData.postType&&(((e={})=>{(0,t.register)((e=>(0,t.createReduxStore)(Z,{actions:{...x,...hr,...vr,...Cr,...De,...Nr},selectors:{...y,...mr,...fr,...jr,...Ge,...Pr},initialState:(0,o.merge)({},{[p]:g(),[dr]:pr(),[yr]:wr(),[Sr]:_r(),[$e]:Be(),[Rr]:Tr()},e),reducer:(0,t.combineReducers)({[p]:f,[dr]:gr,[yr]:br,[Sr]:Er,[$e]:ze,[Rr]:Ar}),controls:{...w,...He,...Mr}}))(e))})({[p]:{hasConsent:"1"===(0,o.get)(window,"wpseoAiGenerator.hasConsent",!1),endpoint:"yoast/v1/ai_generator/consent"},[$e]:{endpoint:"yoast/v1/ai_generator/get_usage"},[yr]:(0,o.get)(window,"wpseoAiGenerator.productSubscriptions",{}),[Rr]:{isFreeSparksActive:"1"===(0,o.get)(window,"wpseoAiGenerator.isFreeSparks",!1),endpoint:"yoast/v1/ai/free_sparks"}}),window.jQuery(window).on("YoastSEO:ready",(()=>{ar()})),(0,r.addFilter)("yoast.replacementVariableEditor.additionalButtons","yoast/yoast-seo/AiGenerator",Fr),(0,r.addFilter)("yoast.focusKeyphrase.errors","yoast/yoast-seo/AiGenerator",cr),(0,r.addAction)("yoast.elementor.loaded","yoast/yoast-seo/AiGenerator",ar))}))})()})();