sirius-press/wordpress/wp-includes/js/dist/script-modules/lazy-editor/index.min.js

38 lines
41 KiB
JavaScript
Raw Normal View History

var Ue=Object.create;var Rt=Object.defineProperty;var De=Object.getOwnPropertyDescriptor;var Ke=Object.getOwnPropertyNames;var He=Object.getPrototypeOf,Je=Object.prototype.hasOwnProperty;var P=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Xe=(t,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ke(e))!Je.call(t,n)&&n!==o&&Rt(t,n,{get:()=>e[n],enumerable:!(r=De(e,n))||r.enumerable});return t};var S=(t,e,o)=>(o=t!=null?Ue(He(t)):{},Xe(e||!t||!t.__esModule?Rt(o,"default",{value:t,enumerable:!0}):o,t));var ft=P((or,Tt)=>{Tt.exports=window.wp.editor});var N=P((rr,Ct)=>{Ct.exports=window.wp.coreData});var M=P((nr,Lt)=>{Lt.exports=window.wp.data});var Mt=P((sr,zt)=>{zt.exports=window.wp.components});var G=P((ir,Nt)=>{Nt.exports=window.wp.element});var pt=P((fr,Ut)=>{Ut.exports=window.wp.styleEngine});var Yt=P((Sr,Xt)=>{Xt.exports=window.wp.i18n});var ht=P((br,Zt)=>{Zt.exports=window.wp.blocks});var we=P((Dr,ve)=>{ve.exports=window.wp.privateApis});var It=P((nn,Re)=>{Re.exports=window.ReactJSXRuntime});var Me=P((fn,ze)=>{ze.exports=window.wp.blockEditor});var Te=S(ft(),1),Vt=S(N(),1),Ft=S(M(),1),Ce=S(Mt(),1),Le=S(G(),1);var Gt=S(N(),1),Bt=S(M(),1);function ot({templateId:t}={}){let{globalStylesId:e,stylesId:o}=(0,Bt.useSelect)(r=>{let n=r(Gt.store),s=t?n.getEntityRecord("postType","wp_template",t):null;return{globalStylesId:n.__experimentalGetCurrentGlobalStylesId(),stylesId:s?.styles_id}},[t]);return o||e}function rt(t,e,o){e=Array.isArray(e)?[...e]:[e],t=Array.isArray(t)?[...t]:{...t};let r=e.pop(),n=t;for(let s of e){let i=n[s];n=n[s]=Array.isArray(i)?[...i]:{...i}}return n[r]=o,t}var v=(t,e,o)=>{let r=Array.isArray(e)?e:e.split("."),n=t;return r.forEach(s=>{n=n?.[s]}),n??o};var Ye=["appearanceTools","useRootPaddingAwareAlignments","background.backgroundImage","background.backgroundRepeat","background.backgroundSize","background.backgroundPosition","background.gradient","border.color","border.radius","border.radiusSizes","border.style","border.width","shadow.presets","shadow.defaultPresets","color.background","color.button","color.caption","color.custom","color.customDuotone","color.customGradient","color.defaultDuotone","color.defaultGradients","color.defaultPalette","color.duotone","color.gradients","color.heading","color.link","color.palette","color.text","custom","dimensions.aspectRatio","dimensions.height","dimensions.minHeight","dimensions.minWidth","dimensions.width","dimensions.dimensionSizes","layout.contentSize","layout.definitions","layout.wideSize","lightbox.enabled","lightbox.allowEditing","position.fixed","position.sticky","spacing.customSpacingSize","spacing.defaultSpacingSizes","spacing.spacingSizes","spacing.spacingScale","spacing.blockGap","spacing.margin","spacing.padding","spacing.units","typography.fluid","typography.customFontSize","typography.defaultFontSizes","typography.dropCap","typography.fontFamilies","typography.fontSizes","typography.fontStyle","typography.fontWeight","typography.letterSpacing","typography.lineHeight","typography.textAlign","typography.textColumns","typography.textDecoration","typography.textIndent","typography.textTransform","typography.writingMode","viewport.mobile","viewport.tablet"];function Wt(t,e,o){let r=o?".blocks."+o:"",n=e?"."+e:"",s=`settings${r}${n}`,i=`settings${n}`;if(e)return v(t,s)??v(t,i);let a={};return Ye.forEach(l=>{let c=v(t,`settings${r}.${l}`)??v(t,`settings.${l}`);c!==void 0&&(a=rt(a,l.split("."),c))}),a}var Kt=S(pt(),1);var Ze="1600px",Qe="320px",qe=1,to=.25,eo=.75,oo="14px";function Dt({minimumFontSize:t,maximumFontSize:e,fontSize:o,minimumViewportWidth:r=Qe,maximumViewportWidth:n=Ze,scaleFactor:s=qe,minimumFontSizeLimit:i}){if(i=A(i)?i:oo,o){let b=A(o);if(!b?.unit||!b?.value)return null;let E=A(i,{coerceTo:b.unit});if(E?.value&&!t&&!e&&b?.value<=E?.value)return null;if(e||(e=`${b.value}${b.unit}`),!t){let _=b.unit==="px"?b.value:b.value*16,k=Math.min(Math.max(1-.075*Math.log2(_),to),eo),C=U(b.value*k,3);E?.value&&C<E?.value?t=`${E.value}${E.unit}`:t=`${C}${b.unit}`}}let a=A(t),l=a?.unit||"rem",c=A(e,{coerceTo:l});if(!a||
<svg
xmlns:xlink="http://www.w3.org/1999/xlink"
viewBox="0 0 0 0"
width="0"
height="0"
focusable="false"
role="none"
aria-hidden="true"
style="visibility: hidden; position: absolute; left: -9999px; overflow: hidden;"
>
<defs>
<filter id="${t}">
<!--
Use sRGB instead of linearRGB so transparency looks correct.
Use perceptual brightness to convert to grayscale.
-->
<feColorMatrix color-interpolation-filters="sRGB" type="matrix" values=" .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 "></feColorMatrix>
<!-- Use sRGB instead of linearRGB to be consistent with how CSS gradients work. -->
<feComponentTransfer color-interpolation-filters="sRGB">
<feFuncR type="table" tableValues="${o.r.join(" ")}"></feFuncR>
<feFuncG type="table" tableValues="${o.g.join(" ")}"></feFuncG>
<feFuncB type="table" tableValues="${o.b.join(" ")}"></feFuncB>
<feFuncA type="table" tableValues="${o.a.join(" ")}"></feFuncA>
</feComponentTransfer>
<!-- Re-mask the image with the original transparency since the feColorMatrix above loses that information. -->
<feComposite in2="SourceGraphic" operator="in"></feComposite>
</filter>
</defs>
</svg>`}function L(t){return t.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/([0-9])([a-zA-Z])/g,"$1-$2").replace(/([a-zA-Z])([0-9])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}function vt(t){if(!t)return;let e=t.match(/var:preset\|spacing\|(.+)/);return e?`var(--wp--preset--spacing--${e[1]})`:t}function mo(t){if(!t)return null;let e=typeof t=="string";return{top:e?t:t?.top,left:e?t:t?.left}}function wt(t,e="0"){let o=mo(t);if(!o)return null;let r=vt(o?.top)||e,n=vt(o?.left)||e;return r===n?r:`${r} ${n}`}var ue={backgroundSize:"cover",backgroundPosition:"50% 50%"};function fe(t){if(!t||!t?.backgroundImage?.url)return;let e;return t?.backgroundSize||(e={backgroundSize:ue.backgroundSize}),t?.backgroundSize==="contain"&&!t?.backgroundPosition&&(e={backgroundPosition:ue.backgroundPosition}),e}var pe={default:{name:"default",slug:"flow",className:"is-layout-flow",baseStyles:[{selector:" > .alignleft",rules:{float:"left","margin-inline-start":"0","margin-inline-end":"2em"}},{selector:" > .alignright",rules:{float:"right","margin-inline-start":"2em","margin-inline-end":"0"}},{selector:" > .aligncenter",rules:{"margin-left":"auto !important","margin-right":"auto !important"}}],spacingStyles:[{selector:" > :first-child",rules:{"margin-block-start":"0"}},{selector:" > :last-child",rules:{"margin-block-end":"0"}},{selector:" > *",rules:{"margin-block-start":null,"margin-block-end":"0"}}]},constrained:{name:"constrained",slug:"constrained",className:"is-layout-constrained",baseStyles:[{selector:" > .alignleft",rules:{float:"left","margin-inline-start":"0","margin-inline-end":"2em"}},{selector:" > .alignright",rules:{float:"right","margin-inline-start":"2em","margin-inline-end":"0"}},{selector:" > .aligncenter",rules:{"margin-left":"auto !important","margin-right":"auto !important"}},{selector:" > :where(:not(.alignleft):not(.alignright):not(.alignfull))",rules:{"max-width":"var(--wp--style--global--content-size)","margin-left":"auto !important","margin-right":"auto !important"}},{selector:" > .alignwide",rules:{"max-width":"var(--wp--style--global--wide-size)"}}],spacingStyles:[{selector:" > :first-child",rules:{"margin-block-start":"0"}},{selector:" > :last-child",rules:{"margin-block-end":"0"}},{selector:" > *",rules:{"margin-block-start":null,"margin-block-end":"0"}}]},flex:{name:"flex",slug:"flex",className:"is-layout-flex",displayMode:"flex",baseStyles:[{selector:"",rules:{"flex-wrap":"wrap","align-items":"center"}},{selector:" > :is(*, div)",rules:{margin:"0"}}],spacingStyles:[{selector:"",rules:{gap:null}}]},grid:{name:"grid",slug:"grid",className:"is-layout-grid",displayMode:"grid",baseStyles:[{selector:" > :is(*, div)",rules:{margin:"0"}}],spacingStyles:[{selector:"",rules:{gap:null}}]}};var de={mobile:"480px",tablet:"782px"},ge=/^(\d+|\d*\.\d+)(px|em|rem)$/,ho=16;function yo(t){return"mobile"in t||"tablet"in t}function So(t){return!t||typeof t!="object"?{}:yo(t)?t:t.settings?.viewport??{}}function bo(t){return typeof t=="string"&&ge.test(t.trim())}function vo(t){if(typeof t=="number")return t;if(typeof t!="string")return;let e=t.trim().match(ge);if(!e)return;let o=Number.parseFloat(e[1]);return e[2]==="px"?o:o*ho}function wo(t){let e=So(t),o={},r={};Object.keys(de).forEach(a=>{let l=a,c=e[l],p=vo(c);p!==void 0&&bo(c)&&(o[l]=c.trim(),r[l]=p)});let n=Object.keys(o);if(!n.length)return{...de};if(n.length===1)return o;let s=o.mobile,i=o.tablet;return r.mobile>=r.tablet?{mobile:s}:{mobile:s,tablet:i}}function Et(t){let e=wo(t),o={};return e.mobile&&(o["@mobile"]=`@media (width <= ${e.mobile})`),e.tablet&&(o["@tablet"]=e.mobile?`@media (${e.mobile} < width <= ${e.tablet})`:`@media (width <= ${e.tablet})`),o}var Eo={button:"wp-element-button",caption:"wp-element-caption"},xo={__experimentalBorder:"border",color:"color",dimensions:"dimensions",spacing:"spacing",typography:"typography"},ye={"core/button":[":hover",":focus",":focus-visible",":active"],"core/navigation-link":[":hover",":focus",":focus-visible",":active"]},$o={link:[":link",":any-link",":visited",":hover",":focus",":focus-visible",":active"],button:[":link",":any-l
.has-global-padding { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }
.has-global-padding > .alignfull { margin-right: calc(var(--wp--style--root--padding-right) * -1); margin-left: calc(var(--wp--style--root--padding-left) * -1); }
.has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull)) { padding-right: 0; padding-left: 0; }
.has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull)) > .alignfull { margin-left: 0; margin-right: 0;
`),g+="}"),a.blockStyles){let m=Et(t);c.forEach(y=>{if(y.isStyleVariation&&!a.variationStyles)return;let w=Ao(y,m);[y,...w,...me(y),...w.flatMap(me)].forEach(b=>{g+=zo(b,{tree:l,useRootPaddingAlign:u,disableLayoutStyles:n,hasBlockGapSupport:o,hasFallbackGapSupport:r,disableRootPadding:s})})})}if(a.layoutStyles&&(g=g+".wp-site-blocks > .alignleft { float: left; margin-right: 2em; }",g=g+".wp-site-blocks > .alignright { float: right; margin-left: 2em; }",g=g+".wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }"),a.blockGap&&o){let m=wt(l?.styles?.spacing?.blockGap)||"0.5em";g=g+`:root :where(.wp-site-blocks) > * { margin-block-start: ${m}; margin-block-end: 0; }`,g=g+":root :where(.wp-site-blocks) > :first-child { margin-block-start: 0; }",g=g+":root :where(.wp-site-blocks) > :last-child { margin-block-end: 0; }"}return a.presets&&p.forEach(({selector:m,presets:y})=>{(R===m||K===m)&&(m="");let w=_o(m,y);w.length>0&&(g+=w)}),g};function No(t,e){return $t(t,e).flatMap(({presets:r})=>ko(r))}var Go=(t,e)=>{if(t?.selectors&&Object.keys(t.selectors).length>0)return t.selectors;let o={root:e};return Object.entries(xo).forEach(([r,n])=>{let s=B(t,r);s&&(o[n]=s)}),o},Bo=(t,e)=>{let{getBlockStyles:o}=(0,he.select)($.store),r={};return t.forEach(n=>{let s=n.name,i=B(n);if(!i)return;let a=B(n,"filter.duotone");if(!a){let d=B(n),h=(0,$.getBlockSupport)(n,"color.__experimentalDuotone",!1);typeof h=="string"&&d&&(a=I(d,h))}let l=!!n?.supports?.layout||!!n?.supports?.__experimentalLayout,c=n?.supports?.spacing?.blockGap?.__experimentalDefault,p=o(s),u={};p?.forEach(d=>{let h=e?`-${e}`:"",g=`${d.name}${h}`,m=gt(g,i);u[g]=m});let f=Go(n,i);r[s]={duotoneSelector:a??void 0,fallbackGapValue:c,featureSelectors:Object.keys(f).length?f:void 0,hasLayoutSupport:l,name:s,selector:i,styleVariationSelectors:p?.length?u:void 0}}),r};function Wo(t){let e=t.styles?.blocks,o=e?.["core/separator"];return o&&o.color?.background&&!o.color?.text&&!o.border?.color?{...t,styles:{...t.styles,blocks:{...e,"core/separator":{...o,color:{...o.color,text:o.color?.background}}}}}:t}function be(t,e){let o="";return!t||t.trim()===""||t.split("&").forEach(n=>{if(!n||n.trim()==="")return;if(!n.includes("{"))o+=`:root :where(${e}){${n.trim()}}`;else{let i=n.replace("}","").split("{");if(i.length!==2)return;let[a,l]=i,c=a.match(/([>+~\s]*::[a-zA-Z-]+)/),p=c?c[1]:"",u=c?a.replace(p,"").trim():a.trim(),f;u===""?f=e:f=a.startsWith(" ")?I(e,u):st(e,u),o+=`:root :where(${f})${p}{${l.trim()}}`}}),o}function _t(t={},e=[],o={}){let{hasBlockGapSupport:r,hasFallbackGapSupport:n,disableLayoutStyles:s=!1,disableRootPadding:i=!1,styleOptions:a={}}=o,l=e.length>0?e:(0,$.getBlockTypes)(),c=Wt(t,"spacing.blockGap"),p=r??c!==null,u=n??!p;if(!t?.styles||!t?.settings)return[[],{}];let f=Wo(t),d=Bo(l),h=Lo(f,d),g=Mo(f,d,p,u,s,i,a),m=No(f,d),y=[{css:h,isGlobalStyles:!0},{css:g,isGlobalStyles:!0},{css:f?.styles?.css??"",isGlobalStyles:!0},{assets:m,__unstableType:"svgs",isGlobalStyles:!0}];return l.forEach(w=>{let b=f?.styles?.blocks?.[w.name];if(b?.css){let{featureSelectors:E}=d[w.name],_=typeof E=="object"?E?.css:void 0,k;typeof _=="string"?k=_:typeof _=="object"&&(k=_?.root);let C=k??d[w.name].selector;y.push({css:be(b.css,C),isGlobalStyles:!0})}}),[y,f.settings]}var Oe=S(N(),1),kt=S(G(),1),Pe=S(M(),1);var Ee=S(N(),1),xe=S(M(),1),$e=S(G(),1);function _e(t){let{userGlobalStyles:e}=(0,xe.useSelect)(o=>{let{getEntityRecord:r,getEditedEntityRecord:n,canUser:s}=o(Ee.store),i=s("update",{kind:"root",name:"globalStyles",id:t}),a;return typeof i=="boolean"&&(i?a=n("root","globalStyles",t):a=r("root","globalStyles",t,{context:"view"})),{userGlobalStyles:a}},[t]);return(0,$e.useMemo)(()=>e?{user:e}:{user:void 0},[e])}var ke=S(we(),1),{unlock:F}=(0,ke.__dangerousOptInToUnstableAPIsOnlyForCoreModules)("I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.","@wordpress/lazy-editor");function Y({stylesId:t}){let{editorSettings:e}=(0,Pe.useSelect)(i=>({editorSettings:F(i(Oe.store)).get
`):typeof e=="string"&&(r=e),r&&r.trim()){let n=t+"-"+o+"-inline-css";if(!document.getElementById(n)){let s=document.createElement("style");s.id=n,s.textContent=r.trim(),document.head.appendChild(s)}}}function Ve(t,e,o){let r=e;Array.isArray(r)&&(r=r.join(`
`));let n=document.createElement("script");return n.id=t+"-"+o+"-js",n.textContent=r.trim(),n}function Fe(t){let e=new Set,o=new Set,r=[];function n(s){if(!e.has(s)){if(o.has(s)){console.warn(`Circular dependency detected for handle: ${s}`);return}o.add(s),t[s]&&(t[s].deps||[]).forEach(a=>{t[a]&&n(a)}),o.delete(s),e.add(s),t[s]&&r.push(s)}}return Object.keys(t).forEach(s=>{n(s)}),r}async function Ho(t,e){let o=[];for(let r of t){if(r.src){let n=Promise.withResolvers();r.onload=()=>n.resolve(),r.onerror=()=>{console.error(`Failed to load script: ${r.id}`),n.resolve()},o.push(n.promise)}else await Promise.all(o),o=[];e.appendChild(r)}await Promise.all(o),o=[]}async function Jo(t,e,o,r,n,s){s&&Uo(s);let i=Fe(o),a=Fe(t),l=[];for(let u of i){let f=r.before?.[u];f&&Ie(u,f,"before"),l.push(Do(u,o[u]));let d=r.after?.[u];d&&Ie(u,d,"after")}let c=[];for(let u of a){let f=e.before?.[u];f&&c.push(Ve(u,f,"before")),c.push(Ko(u,t[u]));let d=e.after?.[u];d&&c.push(Ve(u,d,"after"))}let p=Ho(c,document.body);await Promise.all([Promise.all(l),p]),n&&n.length>0&&n.forEach(u=>{let f=u.match(/<script([^>]*)>(.*?)<\/script>/is);if(f){let d=f[1],h=f[2],g=document.createElement("script"),m=d.match(/id=["']([^"']+)["']/);m&&(g.id=m[1]);let y=d.match(/type=["']([^"']+)["']/);y&&(g.type=y[1]),g.textContent=h,document.body.appendChild(g)}})}var je=Jo;var Pt=S(N(),1),ct=S(G(),1),ut=S(M(),1);var Ot;async function Ae(){return Ot||(Ot=(async()=>{let e=await F((0,ut.resolveSelect)(Pt.store)).getEditorAssets();await je(e.scripts||{},e.inline_scripts||{before:{},after:{}},e.styles||{},e.inline_styles||{before:{},after:{}},e.html_templates||[],e.script_modules||{})})()),Ot}function Z(){let t=(0,ut.useSelect)(r=>F(r(Pt.store)).getEditorAssets(),[]),[e,o]=(0,ct.useState)(!1);return(0,ct.useEffect)(()=>{t&&!e&&Ae().then(()=>{o(!0)}).catch(r=>{console.error("Failed to load editor assets:",r)})},[t,e]),{isReady:!!t&&e,assetsLoaded:e}}var Q=S(It(),1),{Editor:Xo,BackButton:Yo}=F(Te.privateApis);function Zo({postType:t,postId:e,settings:o,backButton:r}){let n=(0,Ft.useSelect)(d=>{if(t||e)return null;let{getHomePage:h}=F(d(Vt.store));return h()},[t,e]),s=t||n?.postType,i=e||n?.postId,a=(0,Ft.useSelect)(d=>{if(!(!s||!i))return s==="wp_template"?i:F(d(Vt.store)).getTemplateId(s,i)},[s,i]),l=ot({templateId:a}),{isReady:c,editorSettings:p}=Y({stylesId:l}),{isReady:u}=Z(),f=(0,Le.useMemo)(()=>({...p,...o}),[p,o]);return!c||!u?(0,Q.jsx)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100vh"},children:(0,Q.jsx)(Ce.Spinner,{})}):(0,Q.jsx)(Xo,{postType:s,postId:i,templateId:a,settings:f,styles:f.styles,children:r&&(0,Q.jsx)(Yo,{children:r})})}var Ne=S(Yt(),1),tt=S(G(),1),q=S(Me(),1),Ge=S(ft(),1),Be=S(ht(),1);var z=S(It(),1);if(typeof document<"u"&&!document.head.querySelector("style[data-wp-hash='95327475c1']")){let t=document.createElement("style");t.setAttribute("data-wp-hash","95327475c1"),t.appendChild(document.createTextNode(".lazy-editor-block-preview__container{align-items:center;border-radius:4px;display:flex;flex-direction:column;height:100%;justify-content:center}.dataviews-view-grid .lazy-editor-block-preview__container .block-editor-block-preview__container{height:100%}.dataviews-view-table .lazy-editor-block-preview__container{text-wrap:balance;text-wrap:pretty;flex-grow:0;width:96px}")),document.head.appendChild(t)}var{useStyle:Qo}=F(Ge.privateApis);function qo({blocks:t,content:e,description:o}){let r=(0,tt.useId)(),n=Qo("color.background"),s=(0,tt.useMemo)(()=>t??(0,Be.parse)(e,{__unstableSkipMigrationLogs:!0}),[e,t]),i=!s?.length;return(0,z.jsxs)("div",{className:"lazy-editor-block-preview__container",style:{backgroundColor:n},"aria-describedby":o?r:void 0,children:[i&&(0,Ne.__)("Empty."),!i&&(0,z.jsx)(q.BlockPreview.Async,{children:(0,z.jsx)(q.BlockPreview,{blocks:s})}),!!o&&(0,z.jsx)("div",{hidden:!0,id:r,children:o})]})}function tr({blocks:t,content:e,description:o}){let r=ot(),{isReady:n,editorSettings:s}=Y({stylesId:r}),{isReady:i}=Z(),a=(0,tt.useMemo)(()=>({...s,isPreviewMode:!0}),[s]);return!n||!i?null:(0,z.jsx)(q.B