import { __ } from '@wordpress/i18n'; import { external, Icon } from '@wordpress/icons'; export const Support = ({ height }) => { if (!window.extHelpCenterData?.supportUrl) { return
; } return (
{__( 'For other questions, visit our support page.', 'extendify-local', )}
); }; import apiFetch from '@wordpress/api-fetch'; import { safeParseJson } from '@shared/lib/parsing'; import { create } from 'zustand'; import { devtools, persist, createJSONStorage } from 'zustand/middleware'; const key = 'extendify-help-center-tour-progress'; const startingState = { currentTour: null, currentStep: undefined, preparingStep: undefined, progress: [], // initialize the state with default values ...(safeParseJson(window.extHelpCenterData.userData.tourData)?.state ?? {}), }; const state = (set, get) => ({ ...startingState, startTour: async (tourData) => { const { trackTourProgress, updateProgress, getStepData, onTourPage } = get(); if (onTourPage(tourData?.settings?.startFrom)) { await tourData?.onStart?.(tourData); tourData.steps = tourData.steps?.filter( // Filter out steps that define a condition (s) => s?.showOnlyIf?.() || s?.showOnlyIf?.() === undefined, ) || []; await getStepData(0, tourData)?.events?.beforeAttach?.(tourData); } set({ currentTour: tourData, currentStep: 0, preparingStep: undefined }); // Increment the opened count const tour = trackTourProgress(tourData.id); updateProgress(tour.id, { openedCount: Number(tour.openedCount) + 1, lastAction: 'started', }); }, onTourPage: (startFrom = null) => { const url = window.location.href; if (startFrom?.includes(url)) return true; const { currentTour } = get(); return currentTour?.settings?.startFrom?.includes(url); }, completeCurrentTour: async () => { const { currentTour, wasCompleted, findTourProgress, updateProgress } = get(); const tour = findTourProgress(currentTour?.id); if (!tour?.id) return; // if already completed, don't update the completedAt if (!wasCompleted(tour.id)) { updateProgress(tour.id, { completedAt: new Date().toISOString(), lastAction: 'completed', }); } // Track how many times it was completed updateProgress(tour.id, { completedCount: Number(tour.completedCount) + 1, lastAction: 'completed', }); await currentTour?.onDetach?.(); await currentTour?.onFinish?.(); set({ currentTour: null, currentStep: undefined }); // fire an event to update the site assistant tour status in assistant code base. if (tour?.id === 'site-assistant-tour') { window.dispatchEvent( new CustomEvent('extendify-assist:is-tour-finished', { detail: { isFinished: true }, }), ); } }, closeCurrentTour: async (lastAction) => { const { currentTour, findTourProgress, updateProgress } = get(); const tour = findTourProgress(currentTour?.id); if (!tour?.id) return; const additional = {}; if (['redirected'].includes(lastAction)) { return updateProgress(tour?.id, { lastAction }); } if (['closed-by-caught-error'].includes(lastAction)) { return updateProgress(tour?.id, { lastAction, errored: true }); } if (lastAction === 'closed-manually') { additional.closedManuallyCount = Number(tour.closedManuallyCount) + 1; } await currentTour?.onDetach?.(); await currentTour?.onFinish?.(); updateProgress(tour?.id, { lastAction, ...additional }); set({ currentTour: null, currentStep: undefined, preparingStep: undefined, }); }, findTourProgress: (tourId) => get().progress.find((tour) => tour.id === tourId), wasCompleted: (tourId) => get().findTourProgress(tourId)?.completedAt, wasOpened: (tourId) => Number(get().findTourProgress(tourId)?.openedCount ?? 0) > 0, isSeen: (tourId) => get().findTourProgress(tourId)?.firstSeenAt, trackTourProgress: (tourId) => { const { findTourProgress } = get(); // If we are already tracking it, return that if (findTourProgress(tourId)) { return findTourProgress(tourId); } set((state) => ({ progress: [ ...state.progress, { id: tourId, firstSeenAt: new Date().toISOString(), updatedAt: new Date().toISOString(), completedAt: null, lastAction: 'init', currentStep: 0, openedCount: 0, closedManuallyCount: 0, completedCount: 0, errored: false, }, ], })); return findTourProgress(tourId); }, updateProgress: (tourId, update) => { const lastAction = update?.lastAction ?? 'unknown'; set((state) => { const progress = state.progress.map((tour) => { if (tour.id === tourId) { return { ...tour, ...update, lastAction, updatedAt: new Date().toISOString(), }; } return tour; }); return { progress }; }); }, getStepData: (step, tour = get().currentTour) => tour?.steps?.[step] ?? {}, hasNextStep: () => { if (!get().currentTour) return false; return Number(get().currentStep) < get().currentTour.steps.length - 1; }, nextStep: async () => { const { currentTour, goToStep, updateProgress, currentStep } = get(); const step = Number(currentStep) + 1; await goToStep(step); updateProgress(currentTour.id, { currentStep: step, lastAction: 'next', }); }, hasPreviousStep: () => { if (!get().currentTour) return false; return Number(get().currentStep) > 0; }, prevStep: async () => { const { currentTour, goToStep, updateProgress, currentStep } = get(); const step = currentStep - 1; await goToStep(step); updateProgress(currentTour.id, { currentStep: step, lastAction: 'prev', }); }, goToStep: async (step) => { const { currentTour, updateProgress, closeCurrentTour, getStepData } = get(); const tour = currentTour; // Check that the step is valid if (step < 0 || step > tour.steps.length - 1) { closeCurrentTour('closed-by-caught-error'); return; } updateProgress(tour.id, { currentStep: step, lastAction: `go-to-step-${step}`, }); const events = getStepData(step)?.events; if (events?.beforeAttach) { set(() => ({ preparingStep: step })); // Make sure the preparing animation runs at least 300ms await Promise.allSettled([ events.beforeAttach?.(tour), new Promise((resolve) => setTimeout(resolve, 300)), ]); set(() => ({ preparingStep: undefined })); } set(() => ({ currentStep: step })); }, }); const path = '/extendify/v1/help-center/tour-data'; const storage = { getItem: async () => await apiFetch({ path }), setItem: async (_name, state) => await apiFetch({ path, method: 'POST', data: { state } }), }; export const useTourStore = create( persist(devtools(state, { name: 'Extendify Tour Progress' }), { name: key, storage: createJSONStorage(() => storage), skipHydration: true, partialize: (state) => { // return without currentTour or currentStep // eslint-disable-next-line no-unused-vars const { currentTour, currentStep, preparingStep, ...newState } = state; return newState; }, }), ); import BarChart from './BarChart'; import Checkmark from './Checkmark'; import Design from './Design'; import Donate from './Donate'; import LeftCaret from './LeftCaret'; import Logo from './Logo'; import Monetization from './Monetization'; import OpenEnvelope from './OpenEnvelope'; import Pencil from './Pencil'; import Planner from './Planner'; import PreviewIcon from './PreviewIcon'; import PriceTag from './PriceTag'; import Radio from './Radio'; import RefreshIcon from './RefreshIcon'; import RightCaret from './RightCaret'; import School from './School'; import SearchIcon from './SearchIcon'; import Shop from './Shop'; import Speech from './Speech'; import Spinner from './Spinner'; import SpinnerIcon from './SpinnerIcon'; import Ticket from './Ticket'; export { BarChart, Checkmark, Design, Donate, LeftCaret, Logo, Monetization, OpenEnvelope, Pencil, Planner, PreviewIcon, PriceTag, Radio, School, RefreshIcon, RightCaret, SearchIcon, Shop, Speech, Spinner, SpinnerIcon, Ticket, }; 1.0Nossa Mídiahttps://nossamidia.net.brpaulochttps://nossamidia.net.br/author/pauloc/Archive Listing Templaterich600338<blockquote class="wp-embedded-content" data-secret="KP5EjSM6hq"><a href="https://nossamidia.net.br/dslc_templates/archive-listing-template/">Archive Listing Template</a></blockquote><iframe sandbox="allow-scripts" security="restricted" src="https://nossamidia.net.br/dslc_templates/archive-listing-template/embed/#?secret=KP5EjSM6hq" width="600" height="338" title="“Archive Listing Template” — Nossa Mídia" data-secret="KP5EjSM6hq" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" class="wp-embedded-content"></iframe><script type="text/javascript"> /* <![CDATA[ */ /*! This file is auto-generated */ !function(d,l){"use strict";l.querySelector&&d.addEventListener&&"undefined"!=typeof URL&&(d.wp=d.wp||{},d.wp.receiveEmbedMessage||(d.wp.receiveEmbedMessage=function(e){var t=e.data;if((t||t.secret||t.message||t.value)&&!/[^a-zA-Z0-9]/.test(t.secret)){for(var s,r,n,a=l.querySelectorAll('iframe[data-secret="'+t.secret+'"]'),o=l.querySelectorAll('blockquote[data-secret="'+t.secret+'"]'),c=new RegExp("^https?:$","i"),i=0;i<o.length;i++)o[i].style.display="none";for(i=0;i<a.length;i++)s=a[i],e.source===s.contentWindow&&(s.removeAttribute("style"),"height"===t.message?(1e3<(r=parseInt(t.value,10))?r=1e3:~~r<200&&(r=200),s.height=r):"link"===t.message&&(r=new URL(s.getAttribute("src")),n=new URL(t.value),c.test(n.protocol))&&n.host===r.host&&l.activeElement===s&&(d.top.location.href=t.value))}},d.addEventListener("message",d.wp.receiveEmbedMessage,!1),l.addEventListener("DOMContentLoaded",function(){for(var e,t,s=l.querySelectorAll("iframe.wp-embedded-content"),r=0;r<s.length;r++)(t=(e=s[r]).getAttribute("data-secret"))||(t=Math.random().toString(36).substring(2,12),e.src+="#?secret="+t,e.setAttribute("data-secret",t)),e.contentWindow.postMessage({message:"ready",secret:t},"*")},!1)))}(window,document); /* ]]> */ </script>