export function normalizePublicCodeText(value: string) { return value .trim() .replace(/[^a-zA-Z0-9]/gu, '') .toUpperCase(); } export function buildPuzzlePublicWorkCode(profileId: string) { const normalized = normalizePublicCodeText(profileId); const fallback = normalized || '00000000'; const suffix = fallback.slice(-8).padStart(8, '0'); return `PZ-${suffix}`; } export function buildBigFishPublicWorkCode(sessionId: string) { const normalized = normalizePublicCodeText(sessionId); const fallback = normalized || '00000000'; const suffix = fallback.slice(-8).padStart(8, '0'); return `BF-${suffix}`; } export function buildMatch3DPublicWorkCode(profileId: string) { const normalized = normalizePublicCodeText(profileId); const fallback = normalized || '00000000'; const suffix = fallback.slice(-8).padStart(8, '0'); return `M3-${suffix}`; } export function isSamePuzzlePublicWorkCode(keyword: string, profileId: string) { const normalizedKeyword = normalizePublicCodeText(keyword); return ( normalizedKeyword === normalizePublicCodeText(buildPuzzlePublicWorkCode(profileId)) || normalizedKeyword === normalizePublicCodeText(profileId) ); } export function isSameBigFishPublicWorkCode( keyword: string, sessionId: string, ) { const normalizedKeyword = normalizePublicCodeText(keyword); return ( normalizedKeyword === normalizePublicCodeText(buildBigFishPublicWorkCode(sessionId)) || normalizedKeyword === normalizePublicCodeText(sessionId) ); } export function isSameMatch3DPublicWorkCode(keyword: string, profileId: string) { const normalizedKeyword = normalizePublicCodeText(keyword); return ( normalizedKeyword === normalizePublicCodeText(buildMatch3DPublicWorkCode(profileId)) || normalizedKeyword === normalizePublicCodeText(profileId) ); }