{"version":3,"file":"Front_db_Button.jTovkJGD.mjs","names":[],"sources":["https:/framerusercontent.com/modules/BI5yuKARRPQaLPuvPUJx/lh6Eq20LTl3mVVVbgwW2/Front_db_Button.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType}from\"framer\";import mixpanel from\"mixpanel-browser\";// Mixpanel 초기화\nmixpanel.init(\"9c4217481189fc04533c750772297e42\",{debug:true,track_pageview:true,persistence:\"localStorage\",record_sessions_percent:100});export function SubmitButton(props){const{text,middleText,width,height,backgroundColor,textColor}=props;const getSearchParams=()=>{const searchParamsObject={};const params=new URLSearchParams(window.location.search);for(let p of params){const key=p[0];const value=p[1];searchParamsObject[key]=value;}return searchParamsObject;};const[isSubmitted,setIsSubmitted]=React.useState(false);const handleClick=async()=>{try{const name=sessionStorage.getItem(\"name\")||\"\";const phone=sessionStorage.getItem(\"phone\")||\"\";const category=sessionStorage.getItem(\"category\")||\"\";const businessNumber=sessionStorage.getItem(\"businessNumber\")||\"\";const selectedFreebie=sessionStorage.getItem(\"selectedFreebie\")||\"[]\";const time=sessionStorage.getItem(\"ConsultationTimeSelector\")||\"\";if(phone===\"\"||phone.length!==11){alert(\"전화번호를 다시 확인해주세요\");return false;}// Mixpanel 사용자 식별\nmixpanel.identify(phone);if(!category){alert(\"업종을 입력해주세요\");return false;}if(window.fbq){window.fbq(\"track\",\"FormSubmission\",{content_name:\"상담 신청\",category,phone,businessNumber});}const newUrl=new URL(window.location.href);newUrl.searchParams.set(\"submitted\",\"true\");window.history.pushState({},\"\",newUrl);// Criteo 세일즈 태그 전환 트리거\nif(window.criteo_q){const deviceType=/iPad/.test(navigator.userAgent)?\"t\":/Mobile|iP(hone|od)|Android|BlackBerry|IEMobile|Silk/.test(navigator.userAgent)?\"m\":\"d\";window.criteo_q.push({event:\"setAccount\",account:122238},{event:\"setEmail\",email:\"\",hash_method:\"sha256\"},{event:\"setEmail\",email:\"\",hash_method:\"md5\"},{event:\"setZipcode\",zipcode:\"\"},{event:\"setSiteType\",type:deviceType},{event:\"trackTransaction\",id:Math.floor(Math.random()*99999999999),item:[{id:\"lead_submission\",price:0,quantity:1}]});}// 버튼 비활성화 및 폼 리셋 이벤트\nsetIsSubmitted(true);window.dispatchEvent(new Event(\"resetForm\"));//  API 호출\nconst res=await fetch(\"https://public-api.ishopcare.bz/public/inquiry/leads/by-framer\",{method:\"POST\",mode:\"cors\",headers:{\"Content-Type\":\"application/json\"},body:JSON.stringify({name,category,businessNumber,phone,etcInfo:selectedFreebie,windowLocationHref:newUrl.href,isAgreedMarketing:false})});// 응답 파싱 (없을 수도 있으니 try)\nlet data=null;try{data=await res.json();}catch(_){}// 중복리드\nif(res.status===406||data?.statusCode===406){alert(\"이미 상담을 진행하셨어요. 추가 문의는 1544-4223로 연락주시면 빠르게 상담 도와드릴게요.\");// 필요 시 재시도를 위해 버튼 다시 활성화\nsetIsSubmitted(false);return;}// 신규\nconst isSuccess=res.ok||data?.resultType===\"SUCCESS\"||String(data?.resultType||\"\").toUpperCase()===\"SUCCESS\";if(isSuccess){alert(\"접수 되었어요. 전화를 기다려주세요\");mixpanel.track(\"Submit Lead\",{host:newUrl.host,utmSource:newUrl.searchParams.get(\"utm_source\")??undefined,utmMedium:newUrl.searchParams.get(\"utm_medium\")??undefined,utmCampaign:newUrl.searchParams.get(\"utm_campaign\")??undefined,utmTerm:newUrl.searchParams.get(\"utm_term\")??undefined,utmContent:newUrl.searchParams.get(\"utm_content\")??undefined,referrer:newUrl.searchParams.get(\"referrer\")??undefined});// 성공 시에만 입력값 정리\nsessionStorage.removeItem(\"name\");sessionStorage.removeItem(\"phone\");sessionStorage.setItem(\"selectedFreebie\",JSON.stringify([\"인터넷\"]));return;}// 그 외 예외\nconsole.error(\"Unexpected response:\",res.status,data);alert(\"접수에 실패했어요. 다시 시도해주세요\");setIsSubmitted(false);}catch(error){console.error(error);alert(\"접수에 실패했어요. 다시 시도해주세요\");setIsSubmitted(false);}};return /*#__PURE__*/_jsxs(\"button\",{disabled:isSubmitted,onClick:e=>{e.preventDefault();handleClick();},style:{width:\"100%\",height:53,backgroundColor:backgroundColor,color:textColor,border:\"none\",borderRadius:\"9px\",fontSize:\"17px\",fontFamily:\"Toss Product Sans, sans-serif\",fontWeight:500,cursor:\"pointer\",display:\"flex\",flexDirection:\"column\",alignItems:\"center\",justifyContent:\"center\"},children:[text,/*#__PURE__*/_jsx(\"span\",{style:{fontSize:\"16px\",marginTop:\"4px\"},children:middleText})]});}// 기본 속성 설정\nSubmitButton.defaultProps={middleText:\"중간에 들어갈 텍스트\",width:340,height:53,backgroundColor:\"#007BFF\",textColor:\"#FFFFFF\"};// 속성 패널에 표시될 속성 추가\naddPropertyControls(SubmitButton,{middleText:{type:ControlType.String,title:\"Middle Text\"},width:{type:ControlType.Number,title:\"Width\",defaultValue:340},height:{type:ControlType.Number,title:\"Height\",defaultValue:55},backgroundColor:{type:ControlType.Color,title:\"Background Color\"},textColor:{type:ControlType.Color,title:\"Text Color\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"SubmitButton\":{\"type\":\"reactComponent\",\"name\":\"SubmitButton\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Front_db_Button.map"],"mappings":"qYAC0I,SAAgB,EAAa,EAAM,CAAC,GAAK,CAAC,OAAK,aAAW,QAAM,SAAO,kBAAgB,YAAU,CAAC,EAA2O,CAAC,EAAY,EAAe,CAAA,EAAgB,IAAa,EAAY,SAAS,CAAC,GAAG,CAAC,IAAM,EAAK,eAAe,QAAQ,SAAS,GAAS,EAAM,eAAe,QAAQ,UAAU,GAAS,EAAS,eAAe,QAAQ,aAAa,GAAS,EAAe,eAAe,QAAQ,mBAAmB,GAAS,EAAgB,eAAe,QAAQ,oBAAoB,KAAuE,GAAvD,eAAe,QAAQ,4BAAmC,IAAQ,IAAI,EAAM,SAAS,GAA6B,OAA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