{"version":3,"file":"FilloutEmbed.K2PBugYl.mjs","names":["React.useState","React.useMemo"],"sources":["https:/framerusercontent.com/modules/jew3FyMvzOzcLkSgS1iX/QT4gab4BW9AT42WiXu9F/FilloutEmbed.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";/* User request: Use direct robust iframe embed (not loader script), build Fillout URL as https://<domain>/t/<formId> with embed=true, include parent-page only for valid non-Framer-internal HTTP pages, keep controls editable (formId/domain/minHeight/redirectPath/debug), keep debug optional below iframe, disable lazy-loading for immediate preview render, and preserve postMessage tracking/redirect with trusted origins limited to configured domain or Fillout hosts. *//**\n * Fillout のフォームをページ本体のDOMに直接埋め込む。\n *\n * Framer の Embed コンポーネント(Insert > Utility > Embed)は中身を iframe で包むため、\n * Fillout のローダーが親ページの window から切り離され、\n *   1. URLパラメータ(utm_*, gclid)の継承が壊れる\n *   2. 送信後の親フレームへのリダイレクトが失敗する\n *   3. postMessage を親ページで受け取れない\n * の3つを同時に失う。だから Embed ではなくこのコードコンポーネントで直接置く。\n *\n * 送信完了は Fillout が親へ投げる postMessage(form_submit)で検知し、\n * dataLayer に流す。ページ遷移の検知に依存しない(Framer は SPA のため)。\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function FilloutEmbed(props){const{formId,domain,minHeight,redirectPath,redirectOnSubmit,debug,extraParams}=props;const onCanvas=RenderTarget.current()===RenderTarget.canvas;const[log,setLog]=React.useState([]);const normalizedDomain=React.useMemo(()=>{return domain.trim().replace(/^https?:\\/\\//i,\"\").replace(/\\/+$/g,\"\");},[domain]);const normalizedFormId=React.useMemo(()=>{return formId.trim().replace(/^\\/+|\\/+$/g,\"\");},[formId]);// SSR時は window が無いため useMemo はサーバー側の値で確定し、\n// ハイドレーション後も再計算されない。location は必ずマウント後に読む。\n// (2026-08-12: これを怠って本番でUTM/gclidが載らなかった)\nconst[clientHref,setClientHref]=React.useState(\"\");React.useEffect(()=>{if(onCanvas||typeof window===\"undefined\")return;setClientHref(window.location.href);},[onCanvas]);const safeParentPage=React.useMemo(()=>{if(!clientHref)return\"\";try{const current=new URL(clientHref);const host=current.hostname.toLowerCase();const path=current.pathname.toLowerCase();const isImageLikePath=/\\.(png|jpe?g|webp|gif|svg|avif)$/i.test(path);const isFramerInternalHost=host.endsWith(\"framerusercontent.com\")||host.endsWith(\"framer.com\")||host.endsWith(\"framercanvas.com\");if(current.protocol!==\"http:\"&&current.protocol!==\"https:\")return\"\";if(!host||isFramerInternalHost||isImageLikePath)return\"\";return`${current.origin}${current.pathname}`;}catch(error){return\"\";}},[clientHref]);// 親ページのURLパラメータ(utm_*, gclid 等)を読む。\n// Fillout のローダーが data-fillout-inherit-parameters でやっていたことを、\n// 素のiframe構成でも成立させるために自前で行う。\n// これが無いと広告経由の予約をFillout側で判別できない(2026-08-12に本番で欠落を実測)。\nconst parentParams=React.useMemo(()=>{if(onCanvas||!clientHref)return[];try{const current=new URL(clientHref);const host=current.hostname.toLowerCase();if(host.endsWith(\"framerusercontent.com\")||host.endsWith(\"framer.com\")||host.endsWith(\"framercanvas.com\"))return[];return[...current.searchParams.entries()];}catch(error){return[];}},[onCanvas,clientHref]);const embedSrc=React.useMemo(()=>{if(!normalizedDomain||!normalizedFormId)return\"\";try{const url=new URL(`https://${normalizedDomain}/t/${encodeURIComponent(normalizedFormId)}`);const query=new URLSearchParams;query.set(\"embed\",\"true\");if(safeParentPage)query.set(\"parent-page\",safeParentPage);for(const[key,value]of parentParams){if(key===\"embed\"||key===\"parent-page\")continue;query.set(key,value);}// 埋め込みページ固有の固定パラメータ(例: site=merinc)。\n// 4サイトが1本のFilloutフォームを共有するため、どのサイトからの送信かは\n// 埋め込んだページ側が名乗るしかない。親URLのクエリより後に適用して、\n// 外部から ?site=... を付けたリンクで詐称されないようにする。\nif(extraParams){const statics=new URLSearchParams(extraParams.trim().replace(/^[?&]+/,\"\"));for(const[key,value]of statics.entries()){if(key===\"embed\"||key===\"parent-page\")continue;query.set(key,value);}}url.search=query.toString();return url.toString();}catch(error){return\"\";}},[normalizedDomain,normalizedFormId,safeParentPage,parentParams,extraParams]);React.useEffect(()=>{if(onCanvas||typeof window===\"undefined\")return;const onMessage=e=>{try{const originHost=new URL(e.origin).hostname.toLowerCase();const configuredHost=normalizedDomain.toLowerCase();const isTrustedOrigin=originHost===configuredHost||originHost.endsWith(\".fillout.com\")||originHost===\"fillout.com\";if(!isTrustedOrigin)return;}catch(error){return;}let d=e.data;if(typeof d===\"string\"){try{d=JSON.parse(d);}catch(err){return;}}if(!d||typeof d!==\"object\")return;const t=d.type||(d.channel===\"form_channel\"?\"form_channel_\"+d.state:\"\");if(!t)return;if(t===\"form_submit\"||t===\"page_change\"){const w=window;w.dataLayer=w.dataLayer||[];w.dataLayer.push({event:t===\"form_submit\"?\"fillout_form_submit\":\"fillout_page_change\",fillout_form_id:formId,fillout_submission_uuid:d.submissionUuid,fillout_step_id:d.stepId});}if(t===\"form_submit\"&&redirectOnSubmit&&redirectPath){// GA4 は /g/collect を fetch で送るため、遷移が速すぎると送信がキャンセルされる。\n// 150ms では GA4 に届かないことを 2026-08-13 に実測（Make と Pipedrive には届いていた）。\n// 送信完了の表示中に待つだけなので UX への影響はない。短くするなら GA4 側で再実測すること。\nwindow.setTimeout(function(){window.location.assign(redirectPath);},800);}if(debug){React.startTransition(()=>{setLog(function(prev){return prev.slice(-14).concat([new Date().toISOString().slice(11,19)+\"  \"+t]);});});}};window.addEventListener(\"message\",onMessage);return()=>window.removeEventListener(\"message\",onMessage);},[onCanvas,debug,formId,redirectPath,redirectOnSubmit,normalizedDomain]);if(onCanvas){return /*#__PURE__*/_jsxs(\"div\",{style:{width:\"100%\",minHeight,display:\"flex\",alignItems:\"center\",justifyContent:\"center\",flexDirection:\"column\",gap:6,background:\"#f4f4f5\",border:\"1px dashed #a1a1aa\",borderRadius:8,color:\"#3f3f46\",fontSize:13,fontFamily:\"sans-serif\",textAlign:\"center\",padding:16},children:[/*#__PURE__*/_jsx(\"strong\",{children:\"Fillout フォーム\"}),/*#__PURE__*/_jsxs(\"span\",{children:[domain,\" / \",formId]}),/*#__PURE__*/_jsx(\"span\",{style:{opacity:.65},children:\"公開・プレビューでのみ描画されます\"})]});}// href が確定する前に iframe を出すとパラメータ無しで一度読み込まれ、\n// 直後に再読み込みされてフォームの入力が飛ぶ。確定してから出す。\nif(!onCanvas&&!clientHref){return /*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:minHeight,minHeight}});}return /*#__PURE__*/_jsxs(\"div\",{style:{width:\"100%\",position:\"relative\"},children:[/*#__PURE__*/_jsx(\"iframe\",{src:embedSrc,title:\"Fillout form\",style:{width:\"100%\",height:minHeight,minHeight,border:0},loading:\"eager\",allow:\"clipboard-write; fullscreen\"}),debug?/*#__PURE__*/_jsx(\"pre\",{style:{marginTop:12,padding:12,background:\"#18181b\",color:\"#a7f3d0\",fontSize:11,lineHeight:1.5,borderRadius:6,overflowX:\"auto\",whiteSpace:\"pre-wrap\",wordBreak:\"break-all\"},children:\"[検証用] iframe src:\\n\"+(embedSrc||\"(URL生成失敗)\")+\"\\n\\n[検証用] 受信した postMessage:\\n\"+(log.length?log.join(\"\\n\"):\"(まだ無し)\")}):null]});}addPropertyControls(FilloutEmbed,{formId:{type:ControlType.String,title:\"Form ID\",defaultValue:\"1MbiSJSHpzus\"},domain:{type:ControlType.String,title:\"Domain\",defaultValue:\"merinc.fillout.com\"},minHeight:{type:ControlType.Number,title:\"Min Height\",defaultValue:720,min:200,max:2e3,step:20},redirectPath:{type:ControlType.String,title:\"Redirect\",defaultValue:\"/bookingthankyou\"},redirectOnSubmit:{type:ControlType.Boolean,title:\"Redirect on Submit\",defaultValue:true},extraParams:{type:ControlType.String,title:\"Extra Params\",defaultValue:\"\",placeholder:\"site=merinc\"},debug:{type:ControlType.Boolean,title:\"Debug\",defaultValue:false}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"FilloutEmbed\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./FilloutEmbed.map"],"mappings":"2NAeG,SAAwB,EAAa,EAAM,CAAC,GAAK,CAAC,SAAO,SAAO,YAAU,eAAa,mBAAiB,QAAM,eAAa,EAAY,EAAS,EAAa,QAAQ,IAAI,EAAa,OAAY,CAAC,EAAI,GAAQA,EAAe,CAAC,CAAC,EAAQ,EAAiBC,MAA0B,EAAO,KAAK,CAAC,CAAC,QAAQ,gBAAgB,EAAE,CAAC,CAAC,QAAQ,QAAQ,EAAE,EAAI,CAAC,CAAM,CAAC,EAAQ,EAAiBA,MAA0B,EAAO,KAAK,CAAC,CAAC,QAAQ,aAAa,EAAE,EAAI,CAAC,CAAM,CAAC,EAG7b,CAAC,EAAW,GAAeD,EAAe,EAAE,EAAE,MAAoB,CAAI,GAAiB,IAAS,QAAmB,EAAc,EAAO,SAAS,IAAI,CAAE,EAAE,CAAC,CAAQ,CAAC,EAAE,IAAM,EAAeC,MAAkB,CAAC,GAAG,CAAC,EAAW,MAAM,GAAG,GAAG,CAAC,IAAM,EAAQ,IAAI,IAAI,CAAU,EAAQ,EAAK,EAAQ,SAAS,YAAY,EAAQ,EAAK,EAAQ,SAAS,YAAY,EAAQ,EAAgB,oCAAoC,KAAK,CAAI,EAAQ,EAAqB,EAAK,SAAS,uBAAuB,GAAG,EAAK,SAAS,YAAY,GAAG,EAAK,SAAS,kBAAkB,EAA+H,OAA1H,EAAQ,WAAW,SAAS,EAAQ,WAAW,UAAqB,CAAC,GAAM,GAAsB,EAAsB,GAAS,GAAG,EAAQ,SAAS,EAAQ,UAAW,MAAa,CAAC,MAAM,EAAG,CAAC,EAAE,CAAC,CAAU,CAAC,EAIrvB,EA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