export const syncPCtoSP = (attributes, setAttributes, attributeKeys) => {
  const syncAttrs = {};
  
  attributeKeys.forEach(key => {
    const pcKey = `${key}PC`;
    const spKey = `${key}SP`;
    
    if (attributes[pcKey] !== undefined) {
      syncAttrs[spKey] = attributes[pcKey];
    }
  });
  
  if (Object.keys(syncAttrs).length > 0) {
    setAttributes(syncAttrs);
  }
};

export const createResponsiveChangeHandler = (
  attributeKey,
  setAttributes,
  responsiveEnabled,
  activeTab
) => {
  return (value) => {
    if (!responsiveEnabled) {
      setAttributes({
        [`${attributeKey}PC`]: value,
        [`${attributeKey}SP`]: value,
      });
    } else {
      const deviceSuffix = activeTab === 'pc' ? 'PC' : 'SP';
      setAttributes({ [`${attributeKey}${deviceSuffix}`]: value });
    }
  };
};
