{"version":3,"file":"NextSfaEmbeddedForm.CmDA0nol.mjs","names":["React.useState","React.useId"],"sources":["https:/framerusercontent.com/modules/VUnmSijcuFEJeMn93MLG/PvPGsljNUI00AGzr8g3T/NextSfaEmbeddedForm.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType}from\"framer\";const DEFAULT_SCRIPT_URL=\"https://geo-code-cloud.s3-ap-northeast-1.amazonaws.com/next-sfa/js/gc.nsfa.form.min.js\";function loadNextSfaScript(scriptUrl){if(typeof window===\"undefined\"||typeof document===\"undefined\"){return Promise.resolve();}if(window.__nextSfaFormScriptLoaded||typeof window.openForm===\"function\"){return Promise.resolve();}if(window.__nextSfaFormScriptPromise)return window.__nextSfaFormScriptPromise;const existingScript=document.querySelector(`script[src=\"${scriptUrl}\"]`);window.__nextSfaFormScriptPromise=new Promise((resolve,reject)=>{if(existingScript){if(existingScript.dataset.loaded===\"true\"){window.__nextSfaFormScriptLoaded=true;resolve();return;}existingScript.addEventListener(\"load\",()=>{existingScript.dataset.loaded=\"true\";window.__nextSfaFormScriptLoaded=true;resolve();},{once:true});existingScript.addEventListener(\"error\",()=>reject(new Error(\"Failed to load nextSFA form script\")),{once:true});return;}const script=document.createElement(\"script\");script.src=scriptUrl;script.async=false;script.dataset.nextSfaForm=\"true\";script.onload=()=>{script.dataset.loaded=\"true\";window.__nextSfaFormScriptLoaded=true;resolve();};script.onerror=()=>reject(new Error(\"Failed to load nextSFA form script\"));document.body.appendChild(script);});return window.__nextSfaFormScriptPromise;}function waitForOpenForm(timeout=6e3){const startedAt=Date.now();return new Promise((resolve,reject)=>{const check=()=>{if(typeof window.openForm===\"function\"){resolve();return;}if(Date.now()-startedAt>timeout){reject(new Error(\"nextSFA openForm was not available\"));return;}window.setTimeout(check,100);};check();});}/**\n * nextSFA Embedded Form\n *\n * Renders the official nextSFA form directly in the Framer page so the published page URL is used as the referrer.\n *\n * @framerIntrinsicWidth 500\n * @framerIntrinsicHeight 560\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function NextSfaEmbeddedForm(props){const{token,formId,formWidth,scriptUrl,minHeight,padding,borderRadius,background,loadingText,style}=props;const htmlFormId=`sfaForm_${formId}`;const[status,setStatus]=React.useState(\"loading\");const mountKey=React.useId().replace(/:/g,\"\");React.useEffect(()=>{if(typeof window===\"undefined\"||typeof document===\"undefined\")return;let cancelled=false;const formElement=document.getElementById(htmlFormId);if(formElement)formElement.innerHTML=\"\";setStatus(\"loading\");const initialize=()=>{if(cancelled||typeof window.openForm!==\"function\")return;const formElement=document.getElementById(htmlFormId);if(!formElement)return;formElement.innerHTML=\"\";window.__nextSfaFormInitialized=window.__nextSfaFormInitialized||{};window.__nextSfaFormInitialized[mountKey]=Date.now();try{window.openForm(token,formWidth,formId);setStatus(\"ready\");}catch(error){console.error(\"nextSFA openForm failed\",error);setStatus(\"error\");}};loadNextSfaScript(scriptUrl).then(()=>waitForOpenForm()).then(()=>{if(document.readyState===\"complete\"){window.setTimeout(initialize,50);}else{window.addEventListener(\"load\",()=>window.setTimeout(initialize,50),{once:true});}}).catch(()=>{if(!cancelled)setStatus(\"error\");});return()=>{cancelled=true;};},[htmlFormId,token,formWidth,formId,scriptUrl,mountKey]);const innerMinHeight=Math.max(minHeight-padding*2,320);return /*#__PURE__*/_jsxs(\"div\",{style:{...style,width:\"100%\",height:\"100%\",minHeight,background,borderRadius,boxSizing:\"border-box\",padding,overflowX:\"hidden\",overflowY:\"auto\",WebkitOverflowScrolling:\"touch\"},children:[/*#__PURE__*/_jsx(\"style\",{children:`\n                #${htmlFormId}, #${htmlFormId} * {\n                    box-sizing: border-box;\n                    max-width: 100%;\n                }\n                #${htmlFormId} {\n                    width: 100% !important;\n                    min-height: ${innerMinHeight}px;\n                    margin: 0 !important;\n                    overflow-x: hidden;\n                    overflow-wrap: break-word;\n                }\n                #${htmlFormId} table,\n                #${htmlFormId} iframe {\n                    width: 100% !important;\n                    max-width: 100% !important;\n                }\n                #${htmlFormId} input,\n                #${htmlFormId} select,\n                #${htmlFormId} textarea,\n                #${htmlFormId} button {\n                    max-width: 100% !important;\n                }\n                #${htmlFormId} img {\n                    max-width: 100% !important;\n                    height: auto !important;\n                }\n            `}),/*#__PURE__*/_jsx(\"form\",{id:htmlFormId,style:{width:\"100%\",margin:0}}),status!==\"ready\"&&/*#__PURE__*/_jsx(\"div\",{\"aria-live\":\"polite\",style:{width:\"100%\",minHeight:160,display:\"flex\",alignItems:\"center\",justifyContent:\"center\",color:status===\"error\"?\"#B42318\":\"#5A6B82\",fontFamily:\"Inter, system-ui, -apple-system, BlinkMacSystemFont, sans-serif\",fontSize:14,lineHeight:1.6,textAlign:\"center\"},children:status===\"error\"?\"フォームを読み込めませんでした。時間をおいて再度お試しください。\":loadingText})]});}addPropertyControls(NextSfaEmbeddedForm,{token:{type:ControlType.String,title:\"Token\",defaultValue:\"NA7QkhxT3CvCQCOcXLguVln6BsRU9FEw\"},formId:{type:ControlType.String,title:\"Form ID\",defaultValue:\"23\"},formWidth:{type:ControlType.String,title:\"Form Width\",defaultValue:\"500\"},scriptUrl:{type:ControlType.String,title:\"Script URL\",defaultValue:DEFAULT_SCRIPT_URL},minHeight:{type:ControlType.Number,title:\"Min Height\",defaultValue:520,min:320,max:900,step:10,unit:\"px\"},padding:{type:ControlType.Number,title:\"Padding\",defaultValue:0,min:0,max:48,step:1,unit:\"px\"},borderRadius:{type:ControlType.Number,title:\"Radius\",defaultValue:18,min:0,max:32,step:1,unit:\"px\"},background:{type:ControlType.Color,title:\"Background\",defaultValue:\"#FFFFFF\"},loadingText:{type:ControlType.String,title:\"Loading Text\",defaultValue:\"フォームを読み込んでいます...\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"NextSfaEmbeddedForm\",\"slots\":[],\"annotations\":{\"framerIntrinsicHeight\":\"560\",\"framerContractVersion\":\"1\",\"framer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