/**
 * `core/site` data store: urls.
 *
 * Site Kit by Google, Copyright 2021 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * Internal dependencies
 */
import { getLocale, getLocaleLanguage } from '../../../util';

export const initialState = {};

export const actions = {};

export const controls = {};

export function reducer( state ) {
	return state;
}

export const resolvers = {};

export const selectors = {
	/**
	 * Gets an external Google URL that includes the user's locale.
	 *
	 * @since n.e.x.t
	 *
	 * @param {Object} state          Data store's state.
	 * @param {Object} [args]         Optional arguments for the resulting URL.
	 * @param {string} [args.website] Base URL hostname and schema.
	 * @param {string} [args.path]    URL path to build complete URL with starting slash.
	 * @param {Object} [args.query]   Object to append query to the URL.
	 * @param {string} [args.hash]    Optional hash.
	 * @param {string} [args.locale]  Optional locale.
	 * @return {(string|null)} The URL containing the user's locale or `null` if path is not set.
	 */
	getGoogleURL( state, args ) {
		const {
			website,
			path,
			query,
			hash,
			locale = getLocale(),
		} = args || {};

		if ( ! path ) {
			return null;
		}

		const url = new URL( website );

		url.pathname = path;
		url.hash = hash || '';

		const params = { ...query, hl: locale };
		for ( const key in params ) {
			url.searchParams.set( key, params[ key ] );
		}

		return url.toString();
	},

	/**
	 * Gets an external help link that includes the user's locale.
	 *
	 * @since 1.24.0
	 *
	 * @param {Object} state         Data store's state.
	 * @param {Object} [args]        Optional arguments for the resulting URL.
	 * @param {string} [args.path]   URL path to build complete URL with starting slash.
	 * @param {Object} [args.query]  Object to append query to the URL.
	 * @param {string} [args.hash]   Optional hash.
	 * @param {string} [args.locale] Optional locale.
	 * @return {(string|null)} The URL containing the user's locale or `null` if path is not set.
	 */
	getGoogleSupportURL( state, args ) {
		return selectors.getGoogleURL( state, { ...args, website: 'https://support.google.com' } );
	},

	/**
	 * Gets the Google privacy policy URL.
	 *
	 * @since n.e.x.t
	 *
	 * @param {Object} state Data store's state.
	 * @return {string} The Google privacy policy URL.
	 */
	getGooglePrivacyPolicyURL( state ) {
		return selectors.getGoogleURL( state, {
			website: 'https://myaccount.google.com',
			path: '/privacypolicy',
			locale: getLocaleLanguage(),
		} );
	},

	/**
	 * Gets the Google terms URL.
	 *
	 * @since n.e.x.t
	 *
	 * @param {Object} state Data store's state.
	 * @return {string} The Google terms URL.
	 */
	getGoogleTermsURL( state ) {
		return selectors.getGoogleURL( state, {
			website: 'https://policies.google.com',
			path: '/terms',
			locale: getLocaleLanguage(),
		} );
	},
};

export default {
	initialState,
	actions,
	controls,
	reducer,
	resolvers,
	selectors,
};

@@ -690,234 +690,183 @@
 ort 
-%7B getLocale, getLocaleLanguage %7D from '../../../util';%0A%0Aexport const initialState = %7B%7D;%0A%0Aexport const actions = %7B%7D;%0A%0Aexport const controls = %7B%7D;%0A%0Aexport function reducer( state ) %7B%0A%09return state;%0A%7D%0A%0Aexport const resolvers = %7B%7D
+Data from 'googlesitekit-data';%0Aimport %7B STORE_NAME %7D from './constants';%0Aimport %7B getLocale, getLocaleLanguage %7D from '../../../util';%0Aconst %7B createRegistrySelector %7D = Data
 ;%0A%0Ae
@@ -2549,16 +2549,56 @@
 pportURL
+: createRegistrySelector( ( select ) =%3E 
 ( state,
@@ -2600,24 +2600,27 @@
 tate, args )
+ =%3E
  %7B%0A%09%09return 
@@ -2617,35 +2617,46 @@
 %0A%09%09return select
-ors
+( STORE_NAME )
 .getGoogleURL( s
@@ -2658,25 +2658,21 @@
 RL( 
-state, %7B 
+%7B%0A%09%09%09
 ...args,
  web
@@ -2667,17 +2667,20 @@
 ...args,
- 
+%0A%09%09%09
 website:
@@ -2712,16 +2712,21 @@
 com'
- 
+,%0A%09%09
 %7D );%0A%09%7D
+ )
 ,%0A%0A%09
@@ -2925,25 +2925,61 @@
 olicyURL
-( state )
+: createRegistrySelector( ( select ) =%3E () =%3E
  %7B%0A%09%09ret
@@ -2980,35 +2980,46 @@
 %0A%09%09return select
-ors
+( STORE_NAME )
 .getGoogleURL( s
@@ -3008,39 +3008,32 @@
  ).getGoogleURL(
- state,
  %7B%0A%09%09%09website: '
@@ -3127,24 +3127,26 @@
 ),%0A%09%09%7D );%0A%09%7D
+ )
 ,%0A%0A%09/**%0A%09 * 
@@ -3315,17 +3315,53 @@
 sURL
-( state )
+: createRegistrySelector( ( select ) =%3E () =%3E
  %7B%0A%09
@@ -3374,19 +3374,30 @@
 n select
-ors
+( STORE_NAME )
 .getGoog
@@ -3402,23 +3402,16 @@
 ogleURL(
- state,
  %7B%0A%09%09%09we
@@ -3508,16 +3508,18 @@
 %09%7D );%0A%09%7D
+ )
 ,%0A%7D;%0A%0Aex
@@ -3537,66 +3537,8 @@
 t %7B%0A
-%09initialState,%0A%09actions,%0A%09controls,%0A%09reducer,%0A%09resolvers,%0A
 %09sel

Update url selectors to use createRegistrySelector helper.