(() => { const start=()=>{ const form=document.getElementById('cm-partner-form');if(!form||form.dataset.ready)return;form.dataset.ready='true'; const status=document.getElementById('cm-partner-status'),button=form.querySelector('button[type=submit]');let busy=false; const esc=s=>String(s).replace(/[&<>"']/g,c=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c])); form.addEventListener('submit',async event=>{ event.preventDefault();if(busy||!form.reportValidity())return; const data=Object.fromEntries(new FormData(form));for(const key of ['shop','contact','email','phone'])data[key]=(data[key]||'').trim(); if(['shop','contact','email','phone'].some(key=>!data[key])){status.textContent='모든 항목을 입력해 주세요.';return;} busy=true;button.disabled=true;button.textContent='접수 중…';status.textContent='신청 정보를 접수하고 있습니다.';form.setAttribute('aria-busy','true'); const token=Array.from(crypto.getRandomValues(new Uint8Array(16)),n=>n.toString(16).padStart(2,'0')).join(''),ref='CM-'+new Date().toISOString().slice(0,10).replaceAll('-','')+'-'+token.slice(0,8).toUpperCase(); const controller=new AbortController(),timeout=setTimeout(()=>controller.abort(),15000); try{ const {clientId}=await ShopbySkin.utils.fetchEnvironment(); const platform=document.querySelector('.header--mobile')||location.hostname.startsWith('pvm-')?'MOBILE_WEB':'PC'; // Permissions are enforced by Shopby: guest write enabled, post read ADMIN only. const response=await fetch('https://shop-api.e-ncp.com/boards/cyclemoa-partner/articles',{ method:'POST',signal:controller.signal,headers:{clientId,Version:'1.0',platform,'Content-Type':'application/json'}, body:JSON.stringify({articleTitle:'입점신청 '+ref,guestName:'입점 신청',password:'Cm!'+token.slice(0,12),secreted:true, articleContent:'

싸이클모아 입점 신청

접수번호: '+ref+'

'+[['매장명',data.shop],['담당자명',data.contact],['이메일',data.email],['연락처',data.phone]].map(([label,value])=>'

'+label+': '+esc(value)+'

').join('')+'

개인정보 수집·이용 동의: 동의함 (양식 2026-11-13)

운영 처리: 검토 후 파트너 가입 초대메일 발송. 검토 및 가입 안내 완료 후 이 접수 글을 삭제해 주세요.

',images:[]}) }); if(!response.ok)throw new Error('request rejected'); document.querySelector('.cm-partner-columns').hidden=true; const success=document.getElementById('cm-partner-success');success.hidden=false; document.getElementById('cm-partner-reference').textContent='접수번호 '+ref;form.reset();success.focus();success.scrollIntoView({block:'center',behavior:'smooth'}); }catch(error){status.textContent='접수 완료를 확인하지 못했습니다. 통신 오류가 계속되면 잠시 후 다시 이용해 주세요. 중복 접수가 걱정되면 고객센터로 확인해 주세요.';button.disabled=false;button.textContent='다시 접수하기';busy=false;} finally{clearTimeout(timeout);form.removeAttribute('aria-busy');} }); };if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',start,{once:true});else start(); })();