2022-04-11 14:04:30 +02:00
/******/ ( function ( ) { // webpackBootstrap
/******/ "use strict" ;
2023-02-07 08:04:52 +01:00
/******/ var _ _webpack _modules _ _ = ( {
/***/ 5619 :
/***/ ( function ( module ) {
// do not edit .js files directly - edit src/index.jst
var envHasBigInt64Array = typeof BigInt64Array !== 'undefined' ;
module . exports = function equal ( a , b ) {
if ( a === b ) return true ;
if ( a && b && typeof a == 'object' && typeof b == 'object' ) {
if ( a . constructor !== b . constructor ) return false ;
var length , i , keys ;
if ( Array . isArray ( a ) ) {
length = a . length ;
if ( length != b . length ) return false ;
for ( i = length ; i -- !== 0 ; )
if ( ! equal ( a [ i ] , b [ i ] ) ) return false ;
return true ;
}
if ( ( a instanceof Map ) && ( b instanceof Map ) ) {
if ( a . size !== b . size ) return false ;
for ( i of a . entries ( ) )
if ( ! b . has ( i [ 0 ] ) ) return false ;
for ( i of a . entries ( ) )
if ( ! equal ( i [ 1 ] , b . get ( i [ 0 ] ) ) ) return false ;
return true ;
}
if ( ( a instanceof Set ) && ( b instanceof Set ) ) {
if ( a . size !== b . size ) return false ;
for ( i of a . entries ( ) )
if ( ! b . has ( i [ 0 ] ) ) return false ;
return true ;
}
if ( ArrayBuffer . isView ( a ) && ArrayBuffer . isView ( b ) ) {
length = a . length ;
if ( length != b . length ) return false ;
for ( i = length ; i -- !== 0 ; )
if ( a [ i ] !== b [ i ] ) return false ;
return true ;
}
if ( a . constructor === RegExp ) return a . source === b . source && a . flags === b . flags ;
if ( a . valueOf !== Object . prototype . valueOf ) return a . valueOf ( ) === b . valueOf ( ) ;
if ( a . toString !== Object . prototype . toString ) return a . toString ( ) === b . toString ( ) ;
keys = Object . keys ( a ) ;
length = keys . length ;
if ( length !== Object . keys ( b ) . length ) return false ;
for ( i = length ; i -- !== 0 ; )
if ( ! Object . prototype . hasOwnProperty . call ( b , keys [ i ] ) ) return false ;
for ( i = length ; i -- !== 0 ; ) {
var key = keys [ i ] ;
if ( ! equal ( a [ key ] , b [ key ] ) ) return false ;
}
return true ;
}
// true if both NaN, false otherwise
return a !== a && b !== b ;
} ;
/***/ } )
/******/ } ) ;
/************************************************************************/
/******/ // The module cache
/******/ var _ _webpack _module _cache _ _ = { } ;
/******/
/******/ // The require function
/******/ function _ _webpack _require _ _ ( moduleId ) {
/******/ // Check if module is in cache
/******/ var cachedModule = _ _webpack _module _cache _ _ [ moduleId ] ;
/******/ if ( cachedModule !== undefined ) {
/******/ return cachedModule . exports ;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = _ _webpack _module _cache _ _ [ moduleId ] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports : { }
/******/ } ;
/******/
/******/ // Execute the module function
/******/ _ _webpack _modules _ _ [ moduleId ] ( module , module . exports , _ _webpack _require _ _ ) ;
/******/
/******/ // Return the exports of the module
/******/ return module . exports ;
/******/ }
2022-04-11 14:04:30 +02:00
/******/
/************************************************************************/
/******/ /* webpack/runtime/compat get default export */
/******/ ! function ( ) {
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ _ _webpack _require _ _ . n = function ( module ) {
/******/ var getter = module && module . _ _esModule ?
/******/ function ( ) { return module [ 'default' ] ; } :
/******/ function ( ) { return module ; } ;
/******/ _ _webpack _require _ _ . d ( getter , { a : getter } ) ;
/******/ return getter ;
/******/ } ;
/******/ } ( ) ;
/******/
/******/ /* webpack/runtime/define property getters */
/******/ ! function ( ) {
/******/ // define getter functions for harmony exports
/******/ _ _webpack _require _ _ . d = function ( exports , definition ) {
/******/ for ( var key in definition ) {
/******/ if ( _ _webpack _require _ _ . o ( definition , key ) && ! _ _webpack _require _ _ . o ( exports , key ) ) {
/******/ Object . defineProperty ( exports , key , { enumerable : true , get : definition [ key ] } ) ;
/******/ }
/******/ }
2019-09-19 17:19:18 +02:00
/******/ } ;
2022-04-11 14:04:30 +02:00
/******/ } ( ) ;
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ ! function ( ) {
/******/ _ _webpack _require _ _ . o = function ( obj , prop ) { return Object . prototype . hasOwnProperty . call ( obj , prop ) ; }
/******/ } ( ) ;
/******/
2019-09-19 17:19:18 +02:00
/************************************************************************/
2022-04-11 14:04:30 +02:00
var _ _webpack _exports _ _ = { } ;
2023-02-07 08:04:52 +01:00
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
! function ( ) {
2019-09-19 17:19:18 +02:00
2022-04-11 14:04:30 +02:00
// EXPORTS
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , {
"default" : function ( ) { return /* binding */ build _module ; }
} ) ;
2019-09-19 17:19:18 +02:00
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js
function _extends ( ) {
2022-09-20 17:43:29 +02:00
_extends = Object . assign ? Object . assign . bind ( ) : function ( target ) {
2022-04-11 14:04:30 +02:00
for ( var i = 1 ; i < arguments . length ; i ++ ) {
var source = arguments [ i ] ;
for ( var key in source ) {
if ( Object . prototype . hasOwnProperty . call ( source , key ) ) {
target [ key ] = source [ key ] ;
}
}
}
return target ;
} ;
return _extends . apply ( this , arguments ) ;
}
; // CONCATENATED MODULE: external ["wp","element"]
var external _wp _element _namespaceObject = window [ "wp" ] [ "element" ] ;
; // CONCATENATED MODULE: external ["wp","data"]
var external _wp _data _namespaceObject = window [ "wp" ] [ "data" ] ;
2023-02-07 08:04:52 +01:00
// EXTERNAL MODULE: ./node_modules/fast-deep-equal/es6/index.js
var es6 = _ _webpack _require _ _ ( 5619 ) ;
var es6 _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( es6 ) ;
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: external ["wp","compose"]
var external _wp _compose _namespaceObject = window [ "wp" ] [ "compose" ] ;
; // CONCATENATED MODULE: external ["wp","i18n"]
var external _wp _i18n _namespaceObject = window [ "wp" ] [ "i18n" ] ;
; // CONCATENATED MODULE: external ["wp","apiFetch"]
var external _wp _apiFetch _namespaceObject = window [ "wp" ] [ "apiFetch" ] ;
var external _wp _apiFetch _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( external _wp _apiFetch _namespaceObject ) ;
; // CONCATENATED MODULE: external ["wp","url"]
var external _wp _url _namespaceObject = window [ "wp" ] [ "url" ] ;
; // CONCATENATED MODULE: external ["wp","components"]
var external _wp _components _namespaceObject = window [ "wp" ] [ "components" ] ;
; // CONCATENATED MODULE: external ["wp","blocks"]
var external _wp _blocks _namespaceObject = window [ "wp" ] [ "blocks" ] ;
; // CONCATENATED MODULE: ./node_modules/@wordpress/server-side-render/build-module/server-side-render.js
2019-09-19 17:19:18 +02:00
/ * *
* External dependencies
* /
/ * *
* WordPress dependencies
* /
2021-04-15 17:19:43 +02:00
2023-02-07 08:04:52 +01:00
const EMPTY _OBJECT = { } ;
2021-11-15 13:50:17 +01:00
function rendererPath ( block ) {
let attributes = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : null ;
let urlQueryArgs = arguments . length > 2 && arguments [ 2 ] !== undefined ? arguments [ 2 ] : { } ;
2022-04-11 14:04:30 +02:00
return ( 0 , external _wp _url _namespaceObject . addQueryArgs ) ( ` /wp/v2/block-renderer/ ${ block } ` , {
2021-05-19 17:09:27 +02:00
context : 'edit' ,
... ( null !== attributes ? {
attributes
} : { } ) ,
... urlQueryArgs
} ) ;
2019-09-19 17:19:18 +02:00
}
2023-02-07 08:04:52 +01:00
function removeBlockSupportAttributes ( attributes ) {
const {
backgroundColor ,
borderColor ,
fontFamily ,
fontSize ,
gradient ,
textColor ,
className ,
... restAttributes
} = attributes ;
const {
border ,
color ,
elements ,
spacing ,
typography ,
... restStyles
} = ( attributes === null || attributes === void 0 ? void 0 : attributes . style ) || EMPTY _OBJECT ;
return { ... restAttributes ,
style : restStyles
} ;
}
2020-06-26 15:33:47 +02:00
2021-11-15 13:50:17 +01:00
function DefaultEmptyResponsePlaceholder ( _ref ) {
let {
className
} = _ref ;
2022-04-11 14:04:30 +02:00
return ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _components _namespaceObject . Placeholder , {
2021-04-15 17:19:43 +02:00
className : className
2022-04-11 14:04:30 +02:00
} , ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( 'Block rendered as empty.' ) ) ;
2021-04-15 17:19:43 +02:00
}
2019-09-19 17:19:18 +02:00
2021-11-15 13:50:17 +01:00
function DefaultErrorResponsePlaceholder ( _ref2 ) {
let {
response ,
className
} = _ref2 ;
2022-04-11 14:04:30 +02:00
const errorMessage = ( 0 , external _wp _i18n _namespaceObject . sprintf ) ( // translators: %s: error message describing the problem
( 0 , external _wp _i18n _namespaceObject . _ _ ) ( 'Error loading block: %s' ) , response . errorMsg ) ;
return ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _components _namespaceObject . Placeholder , {
2021-04-15 17:19:43 +02:00
className : className
} , errorMessage ) ;
}
2019-09-19 17:19:18 +02:00
2021-11-15 13:50:17 +01:00
function DefaultLoadingResponsePlaceholder ( _ref3 ) {
let {
children ,
showLoader
} = _ref3 ;
2022-04-11 14:04:30 +02:00
return ( 0 , external _wp _element _namespaceObject . createElement ) ( "div" , {
2021-11-08 15:29:21 +01:00
style : {
position : 'relative'
}
2022-04-11 14:04:30 +02:00
} , showLoader && ( 0 , external _wp _element _namespaceObject . createElement ) ( "div" , {
2021-11-08 15:29:21 +01:00
style : {
position : 'absolute' ,
top : '50%' ,
left : '50%' ,
marginTop : '-9px' ,
marginLeft : '-9px'
}
2022-04-11 14:04:30 +02:00
} , ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _components _namespaceObject . Spinner , null ) ) , ( 0 , external _wp _element _namespaceObject . createElement ) ( "div" , {
2021-11-08 15:29:21 +01:00
style : {
opacity : showLoader ? '0.3' : 1
}
} , children ) ) ;
2021-04-15 17:19:43 +02:00
}
2019-09-19 17:19:18 +02:00
2021-04-15 17:19:43 +02:00
function ServerSideRender ( props ) {
2021-05-19 17:09:27 +02:00
const {
attributes ,
block ,
className ,
httpMethod = 'GET' ,
urlQueryArgs ,
2023-02-07 08:04:52 +01:00
skipBlockSupportAttributes = false ,
2021-05-19 17:09:27 +02:00
EmptyResponsePlaceholder = DefaultEmptyResponsePlaceholder ,
ErrorResponsePlaceholder = DefaultErrorResponsePlaceholder ,
LoadingResponsePlaceholder = DefaultLoadingResponsePlaceholder
} = props ;
2022-04-11 14:04:30 +02:00
const isMountedRef = ( 0 , external _wp _element _namespaceObject . useRef ) ( true ) ;
const [ showLoader , setShowLoader ] = ( 0 , external _wp _element _namespaceObject . useState ) ( false ) ;
const fetchRequestRef = ( 0 , external _wp _element _namespaceObject . useRef ) ( ) ;
const [ response , setResponse ] = ( 0 , external _wp _element _namespaceObject . useState ) ( null ) ;
const prevProps = ( 0 , external _wp _compose _namespaceObject . usePrevious ) ( props ) ;
const [ isLoading , setIsLoading ] = ( 0 , external _wp _element _namespaceObject . useState ) ( false ) ;
2021-04-15 17:19:43 +02:00
function fetchData ( ) {
2023-02-07 08:04:52 +01:00
var _sanitizedAttributes , _sanitizedAttributes2 ;
2021-04-15 17:19:43 +02:00
if ( ! isMountedRef . current ) {
return ;
2019-09-19 17:19:18 +02:00
}
2021-04-15 17:19:43 +02:00
2021-11-08 15:29:21 +01:00
setIsLoading ( true ) ;
2019-09-19 17:19:18 +02:00
2023-02-07 08:04:52 +01:00
let sanitizedAttributes = attributes && ( 0 , external _wp _blocks _namespaceObject . _ _experimentalSanitizeBlockAttributes ) ( block , attributes ) ;
if ( skipBlockSupportAttributes ) {
sanitizedAttributes = removeBlockSupportAttributes ( sanitizedAttributes ) ;
} // If httpMethod is 'POST', send the attributes in the request body instead of the URL.
2021-04-15 17:19:43 +02:00
// This allows sending a larger attributes object than in a GET request, where the attributes are in the URL.
2021-05-19 17:09:27 +02:00
const isPostRequest = 'POST' === httpMethod ;
2023-02-07 08:04:52 +01:00
const urlAttributes = isPostRequest ? null : ( _sanitizedAttributes = sanitizedAttributes ) !== null && _sanitizedAttributes !== void 0 ? _sanitizedAttributes : null ;
2021-05-19 17:09:27 +02:00
const path = rendererPath ( block , urlAttributes , urlQueryArgs ) ;
const data = isPostRequest ? {
2023-02-07 08:04:52 +01:00
attributes : ( _sanitizedAttributes2 = sanitizedAttributes ) !== null && _sanitizedAttributes2 !== void 0 ? _sanitizedAttributes2 : null
2021-04-15 17:19:43 +02:00
} : null ; // Store the latest fetch request so that when we process it, we can
// check if it is the current request, to avoid race conditions on slow networks.
2021-05-19 17:09:27 +02:00
const fetchRequest = fetchRequestRef . current = external _wp _apiFetch _default ( ) ( {
path ,
data ,
2021-04-15 17:19:43 +02:00
method : isPostRequest ? 'POST' : 'GET'
2021-05-19 17:09:27 +02:00
} ) . then ( fetchResponse => {
2021-04-15 17:19:43 +02:00
if ( isMountedRef . current && fetchRequest === fetchRequestRef . current && fetchResponse ) {
setResponse ( fetchResponse . rendered ) ;
2019-09-19 17:19:18 +02:00
}
2021-05-19 17:09:27 +02:00
} ) . catch ( error => {
2021-04-15 17:19:43 +02:00
if ( isMountedRef . current && fetchRequest === fetchRequestRef . current ) {
setResponse ( {
error : true ,
errorMsg : error . message
2019-09-19 17:19:18 +02:00
} ) ;
}
2021-11-08 15:29:21 +01:00
} ) . finally ( ( ) => {
if ( isMountedRef . current && fetchRequest === fetchRequestRef . current ) {
setIsLoading ( false ) ;
}
2021-04-15 17:19:43 +02:00
} ) ;
return fetchRequest ;
}
2019-09-19 17:19:18 +02:00
2022-04-11 14:04:30 +02:00
const debouncedFetchData = ( 0 , external _wp _compose _namespaceObject . useDebounce ) ( fetchData , 500 ) ; // When the component unmounts, set isMountedRef to false. This will
2021-04-15 17:19:43 +02:00
// let the async fetch callbacks know when to stop.
2019-09-19 17:19:18 +02:00
2022-04-11 14:04:30 +02:00
( 0 , external _wp _element _namespaceObject . useEffect ) ( ( ) => ( ) => {
2021-05-19 17:09:27 +02:00
isMountedRef . current = false ;
2021-04-15 17:19:43 +02:00
} , [ ] ) ;
2022-04-11 14:04:30 +02:00
( 0 , external _wp _element _namespaceObject . useEffect ) ( ( ) => {
2021-04-15 17:19:43 +02:00
// Don't debounce the first fetch. This ensures that the first render
2022-04-12 17:12:47 +02:00
// shows data as soon as possible.
2021-04-15 17:19:43 +02:00
if ( prevProps === undefined ) {
fetchData ( ) ;
2023-02-07 08:04:52 +01:00
} else if ( ! es6 _default ( ) ( prevProps , props ) ) {
2021-04-15 17:19:43 +02:00
debouncedFetchData ( ) ;
2019-09-19 17:19:18 +02:00
}
2021-04-15 17:19:43 +02:00
} ) ;
2021-11-08 15:29:21 +01:00
/ * *
* Effect to handle showing the loading placeholder .
* Show it only if there is no previous response or
* the request takes more than one second .
* /
2021-04-15 17:19:43 +02:00
2022-04-11 14:04:30 +02:00
( 0 , external _wp _element _namespaceObject . useEffect ) ( ( ) => {
2021-11-08 15:29:21 +01:00
if ( ! isLoading ) {
return ;
}
const timeout = setTimeout ( ( ) => {
setShowLoader ( true ) ;
} , 1000 ) ;
return ( ) => clearTimeout ( timeout ) ;
} , [ isLoading ] ) ;
const hasResponse = ! ! response ;
const hasEmptyResponse = response === '' ;
const hasError = response === null || response === void 0 ? void 0 : response . error ;
2022-01-04 06:39:28 +01:00
if ( isLoading ) {
2022-04-11 14:04:30 +02:00
return ( 0 , external _wp _element _namespaceObject . createElement ) ( LoadingResponsePlaceholder , _extends ( { } , props , {
2022-01-04 06:39:28 +01:00
showLoader : showLoader
2022-04-11 14:04:30 +02:00
} ) , hasResponse && ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _element _namespaceObject . RawHTML , {
2022-01-04 06:39:28 +01:00
className : className
} , response ) ) ;
}
2021-11-08 15:29:21 +01:00
if ( hasEmptyResponse || ! hasResponse ) {
2022-04-11 14:04:30 +02:00
return ( 0 , external _wp _element _namespaceObject . createElement ) ( EmptyResponsePlaceholder , props ) ;
2021-11-08 15:29:21 +01:00
}
if ( hasError ) {
2022-04-11 14:04:30 +02:00
return ( 0 , external _wp _element _namespaceObject . createElement ) ( ErrorResponsePlaceholder , _extends ( {
2021-04-15 17:19:43 +02:00
response : response
} , props ) ) ;
2019-09-19 17:19:18 +02:00
}
2021-04-15 17:19:43 +02:00
2022-04-11 14:04:30 +02:00
return ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _element _namespaceObject . RawHTML , {
2021-04-15 17:19:43 +02:00
className : className
} , response ) ;
}
2019-09-19 17:19:18 +02:00
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/server-side-render/build-module/index.js
2019-09-19 17:19:18 +02:00
/ * *
* WordPress dependencies
* /
/ * *
* Internal dependencies
* /
/ * *
* Constants
* /
2023-02-07 08:04:52 +01:00
const build _module _EMPTY _OBJECT = { } ;
2022-04-11 14:04:30 +02:00
const ExportedServerSideRender = ( 0 , external _wp _data _namespaceObject . withSelect ) ( select => {
2021-11-08 15:29:21 +01:00
// FIXME: @wordpress/server-side-render should not depend on @wordpress/editor.
// It is used by blocks that can be loaded into a *non-post* block editor.
// eslint-disable-next-line @wordpress/data-no-store-string-literals
2021-05-19 17:09:27 +02:00
const coreEditorSelect = select ( 'core/editor' ) ;
2019-09-19 17:19:18 +02:00
if ( coreEditorSelect ) {
2021-05-19 17:09:27 +02:00
const currentPostId = coreEditorSelect . getCurrentPostId ( ) ; // For templates and template parts we use a custom ID format.
2021-04-15 17:19:43 +02:00
// Since they aren't real posts, we don't want to use their ID
// for server-side rendering. Since they use a string based ID,
// we can assume real post IDs are numbers.
2019-09-19 17:19:18 +02:00
2021-05-21 12:14:23 +02:00
if ( currentPostId && typeof currentPostId === 'number' ) {
2019-09-19 17:19:18 +02:00
return {
2021-05-19 17:09:27 +02:00
currentPostId
2019-09-19 17:19:18 +02:00
} ;
}
}
2023-02-07 08:04:52 +01:00
return build _module _EMPTY _OBJECT ;
2021-11-15 13:50:17 +01:00
} ) ( _ref => {
let {
2023-02-07 08:04:52 +01:00
urlQueryArgs = build _module _EMPTY _OBJECT ,
2021-11-15 13:50:17 +01:00
currentPostId ,
... props
} = _ref ;
2022-04-11 14:04:30 +02:00
const newUrlQueryArgs = ( 0 , external _wp _element _namespaceObject . useMemo ) ( ( ) => {
2019-09-19 17:19:18 +02:00
if ( ! currentPostId ) {
return urlQueryArgs ;
}
2021-05-19 17:09:27 +02:00
return {
post _id : currentPostId ,
... urlQueryArgs
} ;
2019-09-19 17:19:18 +02:00
} , [ currentPostId , urlQueryArgs ] ) ;
2022-04-11 14:04:30 +02:00
return ( 0 , external _wp _element _namespaceObject . createElement ) ( ServerSideRender , _extends ( {
2019-09-19 17:19:18 +02:00
urlQueryArgs : newUrlQueryArgs
} , props ) ) ;
} ) ;
2022-04-11 14:04:30 +02:00
/* harmony default export */ var build _module = ( ExportedServerSideRender ) ;
2019-09-19 17:19:18 +02:00
2023-02-07 08:04:52 +01:00
} ( ) ;
2022-04-11 14:04:30 +02:00
( window . wp = window . wp || { } ) . serverSideRender = _ _webpack _exports _ _ [ "default" ] ;
/******/ } ) ( )
;