5 lines
13 KiB
JavaScript
5 lines
13 KiB
JavaScript
(()=>{var e={332:(e,t)=>{var s;!function(){"use strict";var r={}.hasOwnProperty;function a(){for(var e=[],t=0;t<arguments.length;t++){var s=arguments[t];if(s){var n=typeof s;if("string"===n||"number"===n)e.push(s);else if(Array.isArray(s)){if(s.length){var i=a.apply(null,s);i&&e.push(i)}}else if("object"===n){if(s.toString!==Object.prototype.toString&&!s.toString.toString().includes("[native code]")){e.push(s.toString());continue}for(var o in s)r.call(s,o)&&s[o]&&e.push(o)}}}return e.join(" ")}e.exports?(a.default=a,e.exports=a):void 0===(s=function(){return a}.apply(t,[]))||(e.exports=s)}()}},t={};function s(r){var a=t[r];if(void 0!==a)return a.exports;var n=t[r]={exports:{}};return e[r](n,n.exports,s),n.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.React,t=window.wp.data,r=window.wp.domReady;var a=s.n(r);const n=window.wp.element,i=window.yoast.uiLibrary;var o=s(332),l=s.n(o);const c=window.lodash,u=window.yoast.reduxJsToolkit,m="adminUrl",d=(0,u.createSlice)({name:m,initialState:"",reducers:{setAdminUrl:(e,{payload:t})=>t}}),y=(d.getInitialState,{selectAdminUrl:e=>(0,c.get)(e,m,"")});y.selectAdminLink=(0,u.createSelector)([y.selectAdminUrl,(e,t)=>t],((e,t)=>{try{return new URL(t,e).href}catch(t){return e}})),d.actions,d.reducer;const p=window.wp.apiFetch;var g=s.n(p);const w="hasConsent",f=`${w}/storeConsent`,h=(0,u.createSlice)({name:w,initialState:!1,reducers:{giveAiGeneratorConsent:(e,{payload:t})=>t}}),v=h.getInitialState,E={selectHasAiGeneratorConsent:e=>(0,c.get)(e,w,!1)},b={...h.actions,storeAiGeneratorConsent:function*(e){try{yield{type:f,payload:e}}catch(e){return!1}return yield{type:`${w}/giveAiGeneratorConsent`,payload:e},!0}},k={[f]:async({payload:e})=>await g()({path:"yoast/v1/ai_generator/consent",method:"POST",data:{consent:e},parse:!1})},x=h.reducer,S="pluginUrl",R=(0,u.createSlice)({name:S,initialState:"",reducers:{setPluginUrl:(e,{payload:t})=>t}}),C=R.getInitialState,_={selectPluginUrl:e=>(0,c.get)(e,S,"")};_.selectImageLink=(0,u.createSelector)([_.selectPluginUrl,(e,t,s="assets/images")=>s,(e,t)=>t],((e,t,s)=>[(0,c.trimEnd)(e,"/"),(0,c.trim)(t,"/"),(0,c.trimStart)(s,"/")].join("/")));const N=R.actions,L=R.reducer,P=window.wp.url,q="linkParams",A=(0,u.createSlice)({name:q,initialState:{},reducers:{setLinkParams:(e,{payload:t})=>t}}),$=A.getInitialState,I={selectLinkParam:(e,t,s={})=>(0,c.get)(e,`${q}.${t}`,s),selectLinkParams:e=>(0,c.get)(e,q,{})};I.selectLink=(0,u.createSelector)([I.selectLinkParams,(e,t)=>t],((e,t)=>(0,P.addQueryArgs)(t,e)));const M=A.actions,G=A.reducer,O="request",B="success",T="error",U="idle",j="loading",W="wistiaEmbedPermission",z=(0,u.createSlice)({name:W,initialState:{value:!1,status:U,error:{}},reducers:{setWistiaEmbedPermissionValue:(e,{payload:t})=>{e.value=Boolean(t)}},extraReducers:e=>{e.addCase(`${W}/${O}`,(e=>{e.status=j})),e.addCase(`${W}/${B}`,((e,{payload:t})=>{e.status="success",e.value=Boolean(t&&t.value)})),e.addCase(`${W}/${T}`,((e,{payload:t})=>{e.status="error",e.value=Boolean(t&&t.value),e.error={code:(0,c.get)(t,"error.code",500),message:(0,c.get)(t,"error.message","Unknown")}}))}}),F=z.getInitialState,D={selectWistiaEmbedPermission:e=>(0,c.get)(e,W,{value:!1,status:U}),selectWistiaEmbedPermissionValue:e=>(0,c.get)(e,[W,"value"],!1),selectWistiaEmbedPermissionStatus:e=>(0,c.get)(e,[W,"status"],U),selectWistiaEmbedPermissionError:e=>(0,c.get)(e,[W,"error"],{})},H={...z.actions,setWistiaEmbedPermission:function*(e){yield{type:`${W}/${O}`};try{return yield{type:W,payload:e},{type:`${W}/${B}`,payload:{value:e}}}catch(t){return{type:`${W}/${T}`,payload:{error:t,value:e}}}}},Y={[W]:async({payload:e})=>g()({path:"/yoast/v1/wistia_embed_permission",method:"POST",data:{value:Boolean(e)}})},J=z.reducer,V=window.yoast.propTypes;var Q=s.n(V);const K=e.forwardRef((function(t,s){return e.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",ref:s},t),e.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"}))})),X=window.wp.i18n;Q().string.isRequired,Q().shape({src:Q().string.isRequired,width:Q().string,height:Q().string}).isRequired,Q().shape({value:Q().bool.isRequired,status:Q().string.isRequired,set:Q().func.isRequired}).isRequired,Q().string.isRequired,Q().shape({src:Q().string.isRequired,width:Q().string,height:Q().string}).isRequired,Q().shape({value:Q().bool.isRequired,status:Q().string.isRequired,set:Q().func.isRequired}).isRequired;const Z=({href:t,children:s,...r})=>(0,e.createElement)(i.Link,{target:"_blank",rel:"noopener noreferrer",...r,href:t},s,(0,e.createElement)("span",{className:"yst-sr-only"},/* translators: Hidden accessibility text. */ /* translators: Hidden accessibility text. */
|
|
(0,X.__)("(Opens in a new browser tab)","wordpress-seo-premium")));Z.propTypes={href:Q().string.isRequired,children:Q().node},Z.defaultProps={children:null};window.yoast.reactHelmet;Q().string.isRequired,Q().shape({src:Q().string.isRequired,width:Q().string,height:Q().string}).isRequired,Q().shape({value:Q().bool.isRequired,status:Q().string.isRequired,set:Q().func.isRequired}).isRequired;const ee=({onGiveConsent:t,learnMoreLink:s,privacyPolicyLink:r,termsOfServiceLink:a,imageLink:o})=>{const{onClose:l,initialFocus:c}=(0,i.useModalContext)(),[u,m]=(0,i.useToggleState)(!1),d=(0,n.useCallback)((()=>{l(),t()}),[t,l]),y=(0,n.useMemo)((()=>({src:o,width:"432",height:"244"})),[o]),p=(0,n.createInterpolateElement)((0,X.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. */ /* 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,X.__)("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-premium"),"<a1>","</a1>","<a2>","</a2>"),{a1:(0,e.createElement)(Z,{href:a}),a2:(0,e.createElement)(Z,{href:r})});return(0,e.createElement)(e.Fragment,null,(0,e.createElement)("div",{className:"yst-px-10 yst-pt-10 yst-introduction-gradient yst-text-center"},(0,e.createElement)("div",{className:"yst-relative yst-w-full"},(0,e.createElement)("img",{className:"yst-w-full yst-h-auto yst-rounded-md yst-drop-shadow-md",alt:"",loading:"lazy",decoding:"async",...y}))),(0,e.createElement)("div",{className:"yst-px-10 yst-pb-4 yst-flex yst-flex-col yst-items-center"},(0,e.createElement)("div",{className:"yst-mt-4 yst-mx-1.5 yst-text-center"},(0,e.createElement)("h3",{className:"yst-text-slate-900 yst-text-lg yst-font-medium"},(0,X.sprintf)(/* translators: %s expands to Yoast AI. */ /* translators: %s expands to Yoast AI. */
|
|
(0,X.__)("Grant consent for %s","wordpress-seo-premium"),"Yoast AI")),(0,e.createElement)("div",{className:"yst-mt-2 yst-text-slate-600 yst-text-sm"},(0,n.createInterpolateElement)((0,X.sprintf)(/* translators: %1$s is a break tag; %2$s and %3$s are anchor tag; %4$s is the arrow icon. */ /* translators: %1$s is a break tag; %2$s and %3$s are anchor tag; %4$s is the arrow icon. */
|
|
(0,X.__)("Enable AI-powered SEO! Use all AI Generate and Optimize features to boost your efficiency. Just give us the green light. %1$s%2$sLearn more%3$s%4$s","wordpress-seo-premium"),"<br/>","<a>","<ArrowNarrowRightIcon />","</a>"),{a:(0,e.createElement)(Z,{href:s,className:"yst-inline-flex yst-items-center yst-gap-1 yst-no-underline yst-font-medium",variant:"primary"}),ArrowNarrowRightIcon:(0,e.createElement)(K,{className:"yst-w-4 yst-h-4 rtl:yst-rotate-180"}),br:(0,e.createElement)("br",null)}))),(0,e.createElement)("div",{className:"yst-flex yst-w-full yst-mt-6"},(0,e.createElement)("hr",{className:"yst-w-full yst-text-gray-200"})),(0,e.createElement)("div",{className:"yst-flex yst-items-start yst-mt-4"},(0,e.createElement)("input",{type:"checkbox",id:"yst-ai-consent-checkbox",name:"yst-ai-consent-checkbox",checked:u,value:u?"true":"false",onChange:m,className:"yst-checkbox__input",ref:c}),(0,e.createElement)("label",{htmlFor:"yst-ai-consent-checkbox",className:"yst-label yst-checkbox__label yst-text-xs yst-font-normal yst-text-slate-500"},p)),(0,e.createElement)("div",{className:"yst-w-full yst-flex yst-mt-4"},(0,e.createElement)(i.Button,{as:"button",className:"yst-grow",size:"large",disabled:!u,onClick:d},(0,X.__)("Grant consent","wordpress-seo-premium"))),(0,e.createElement)(i.Button,{as:"button",className:"yst-mt-4",variant:"tertiary",onClick:l},(0,X.__)("Close","wordpress-seo-premium"))))};ee.propTypes={onGiveConsent:Q().func.isRequired,learnMoreLink:Q().string.isRequired,privacyPolicyLink:Q().string.isRequired,termsOfServiceLink:Q().string.isRequired,imageLink:Q().string.isRequired};const te="yoast-seo-premium/manage-ai-consent-button",se=({onStartGenerating:s})=>{const r=(0,t.useSelect)((e=>e(te).selectLink("https://yoa.st/ai-fix-assessments-terms-of-service")),[]),a=(0,t.useSelect)((e=>e(te).selectLink("https://yoa.st/ai-fix-assessments-privacy-policy")),[]),i=(0,t.useSelect)((e=>e(te).selectLink("https://yoa.st/ai-fix-assessments-consent-learn-more")),[]),o=(0,t.useSelect)((e=>e(te).selectImageLink("ai-consent.png")),[]),{storeAiGeneratorConsent:l}=(0,t.useDispatch)(te),c=(0,n.useCallback)((()=>{l(!0),s()}),[l,s]);return(0,e.createElement)(ee,{imageLink:o,onGiveConsent:c,learnMoreLink:i,termsOfServiceLink:r,privacyPolicyLink:a})};se.propTypes={onStartGenerating:Q().func.isRequired};const re=e.forwardRef((function(t,s){return e.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:s},t),e.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"}))})),ae=({onClose:s})=>{const{storeAiGeneratorConsent:r}=(0,t.useDispatch)(te),[a,o]=(0,n.useState)(!1),[l,c]=(0,n.useState)(!1),u=(0,n.useCallback)((async()=>{if(c(!1),o(!0),!1===await r(!1))return c(!0),void o(!1);s(),o(!1)}),[r,o,s]);return(0,e.createElement)("div",{className:"yst-flex yst-flex-row"},(0,e.createElement)("span",{className:"yst-shrink-0 yst-h-12 yst-w-12 yst-rounded-full yst-flex yst-justify-center yst-items-center yst-mb-3 yst-mr-5 yst-bg-red-100"},(0,e.createElement)(re,{className:"yst-w-6 yst-h-6 yst-align-center yst-text-red-600"})),(0,e.createElement)("div",null,(0,e.createElement)(i.Modal.Title,{className:"yst-font-semibold",as:"h3",size:"4"},(0,X.__)("Revoke AI consent","wordpress-seo-premium")),l&&(0,e.createElement)(i.Alert,{className:"yst-mt-2",variant:"error"},(0,X.__)("Something went wrong, please try again later.","wordpress-seo-premium")),(0,e.createElement)("p",{className:"yst-mt-2 yst-text-slate-600"},(0,X.__)("By revoking your consent, you will no longer have access to Yoast AI features. Are you sure you want to revoke your consent?","wordpress-seo-premium")),(0,e.createElement)("footer",{className:"yst-mt-6 sm:yst-flex sm:yst-flex-row-reverse"},(0,e.createElement)(i.Button,{variant:"error",isLoading:a,className:"yst-w-full sm:yst-w-auto yst-revoke-button",onClick:u},(0,X.__)("Yes, revoke consent","wordpress-seo-premium")),(0,e.createElement)(i.Button,{variant:"secondary",className:"yst-w-full sm:yst-w-auto yst-mr-3",onClick:s},(0,X.__)("Close","wordpress-seo-premium")))))};ae.propTypes={onClose:Q().func.isRequired};const ne=(e={})=>{(0,t.register)((e=>(0,t.createReduxStore)(te,{actions:{...b,...N,...M,...H},selectors:{...E,..._,...I,...D},initialState:(0,c.merge)({},{[w]:v(),[S]:C(),[q]:$(),[W]:F()},e),reducer:(0,t.combineReducers)({[w]:x,[S]:L,[q]:G,[W]:J}),controls:{...k,...Y}}))(e))};a()((()=>{const s=(0,c.get)(window,"yoast.editorModules.sharedAdmin.store.WISTIA_EMBED_PERMISSION_NAME","wistiaEmbedPermission");ne({[w]:"1"===(0,c.get)(window,"wpseoPremiumManageAiConsentButton.hasConsent",!1),[S]:(0,c.get)(window,"wpseoPremiumManageAiConsentButton.pluginUrl",""),[s]:{value:"1"===(0,c.get)(window,"wpseoPremiumManageAiConsentButton.wistiaEmbedPermission",!1)}});const r=document.getElementById("ai-generator-consent");r&&(0,n.render)((0,e.createElement)((()=>{const s=(0,t.useSelect)((e=>e(te).selectHasAiGeneratorConsent()),[]),[r,,,a,o]=(0,i.useToggleState)(!1),c=(0,n.useRef)(null),u=(0,n.useCallback)((e=>{e.preventDefault(),a()}),[a]);return(0,e.createElement)(n.Fragment,null,(0,e.createElement)(i.Modal,{className:"yst-introduction-modal",isOpen:r,onClose:o,initialFocus:c},(0,e.createElement)(i.Modal.Panel,{className:l()(!s&&"yst-p-0 yst-max-w-lg yst-rounded-3xl",s&&"yst-max-w-xl yst-rounded-lg")},!s&&(0,e.createElement)(se,{onStartGenerating:o,focusElementRef:c}),s&&(0,e.createElement)(ae,{onClose:o}))),(0,e.createElement)("button",{className:"button",id:"ai-generator-consent-button",onClick:u},(s?"Revoke":"Grant")+" consent"))}),null),r)}))})()})(); |