{
  "version": 3,
  "sources": ["ssg:https://framerusercontent.com/modules/wBuwXoih2kVMa1rOUPsb/buHBd0PPLof9Uovyz709/TallyForms.js"],
  "sourcesContent": ["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef,useState}from\"react\";import{addPropertyControls,ControlType}from\"framer\";const WIDGET_URL=\"https://tally.so/widgets/embed.js\";/**\n * @framerIntrinsicWidth 700\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight any\n */export default function TallyForms(props){const{form,title,alignLeft,background}=props;const iframeRef=useRef(null);// State to store the H1 title\nconst[pageTitle,setPageTitle]=useState(\"\");// Use the options to build the URL query params\nconst queryParams=[];queryParams.push(`hideTitle=${title?\"0\":\"1\"}`);queryParams.push(`alignLeft=${alignLeft?\"1\":\"0\"}`);queryParams.push(`transparentBackground=${background?\"0\":\"1\"}`);queryParams.push(\"dynamicHeight=1\");// Fetch the H1 title dynamically\nuseEffect(()=>{const h1Element=document.querySelector(\"h1\");if(h1Element){setPageTitle(h1Element.textContent||\"\");}},[]);// Include the page title in the query parameters if available\nif(pageTitle){queryParams.push(`pagetitle=${encodeURIComponent(pageTitle)}`);}// The iframe URL\nlet embedUrl=\"\";if(form.includes(\"tally.so/\")){// Tally link with form ID\nconst matches=form.match(/\\/(?:r|embed|popup|forms)\\/([a-zA-Z0-9]+)/);if(matches!==null){const formId=matches[1];embedUrl=`https://tally.so/embed/${formId}`;}}else if(form.startsWith(\"http\")&&form.includes(\".\")){// Custom domain\nembedUrl=form;queryParams.push(\"embed=1\");}// If we still don't have URL, we assume the form is the form ID itself\nif(!embedUrl){embedUrl=`https://tally.so/embed/${form}`;}// Append query params\nembedUrl=`${embedUrl}?${queryParams.join(\"&\")}`;const loadWidgetScript=()=>{const scriptEl=document.createElement(\"script\");scriptEl.src=WIDGET_URL;scriptEl.onload=loadEmbeds;scriptEl.onerror=loadEmbeds;document.body.appendChild(scriptEl);};const loadEmbeds=()=>{var _iframeEl_dataset;// Remove initialized attribute if any, so we can reload\nconst iframeEl=iframeRef.current;if(iframeEl===null||iframeEl===void 0?void 0:(_iframeEl_dataset=iframeEl.dataset)===null||_iframeEl_dataset===void 0?void 0:_iframeEl_dataset.tallyEmbedWidgetInitialized){iframeEl.removeAttribute(\"data-tally-embed-widget-initialized\");iframeEl.removeAttribute(\"src\");}// @ts-ignore\nif(typeof Tally!==\"undefined\"){// @ts-ignore\nTally.loadEmbeds();}else{document.querySelectorAll(\"iframe[data-tally-src]:not([src])\").forEach(function(e){e.src=e.dataset.tallySrc;});}};useEffect(()=>{// @ts-ignore\nif(typeof Tally!==\"undefined\"){loadEmbeds();}else if(document.querySelector(`script[src=\"${WIDGET_URL}\"]`)==null){loadWidgetScript();}},[embedUrl]);return /*#__PURE__*/_jsx(\"iframe\",{ref:iframeRef,\"data-tally-src\":embedUrl,width:\"100%\",height:\"100%\",frameBorder:0,marginHeight:0,marginWidth:0,title:\"Tally form\"});}addPropertyControls(TallyForms,{form:{type:ControlType.String,title:\"Form\",defaultValue:\"tally.so/r/3EKXW4\",description:\"Create a form in [Tally](https://tally.so?ref=framer) and copy the form link\"},title:{type:ControlType.Boolean,title:\"Title\",enabledTitle:\"Show\",disabledTitle:\"Hide\",defaultValue:false},alignLeft:{type:ControlType.Boolean,title:\"Align\",enabledTitle:\"Left\",disabledTitle:\"Center\",defaultValue:true},background:{type:ControlType.Boolean,title:\"Background\",enabledTitle:\"Show\",disabledTitle:\"Hide\",defaultValue:false}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TallyForms\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerIntrinsicWidth\":\"700\",\"framerSupportedLayoutHeight\":\"any\",\"framerSupportedLayoutWidth\":\"fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TallyForms.map"],
  "mappings": "8GAA4I,IAAMA,EAAW,oCAI3I,SAARC,EAA4BC,EAAM,CAAC,GAAK,CAA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GACvS,OAAO,MAAQ,IAClB,MAAM,WAAW,EAAQ,SAAS,iBAAiB,mCAAmC,EAAE,QAAQ,SAASC,EAAE,CAACA,EAAE,IAAIA,EAAE,QAAQ,QAAS,CAAC,CAAG,EAAE,OAAAT,EAAU,IAAI,CACtJ,OAAO,MAAQ,IAAaM,EAAW,EAAW,SAAS,cAAc,eAAenB,CAAU,IAAI,GAAG,MAAMiB,EAAiB,CAAG,EAAE,CAACF,CAAQ,CAAC,EAAsBQ,EAAK,SAAS,CAAC,IAAIhB,EAAU,iBAAiBQ,EAAS,MAAM,OAAO,OAAO,OAAO,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC,CAAE,CAACS,EAAoBvB,EAAW,CAAC,KAAK,CAAC,KAAKwB,EAAY,OAAO,MAAM,OAAO,aAAa,oBAAoB,YAAY,8EAA8E,EAAE,MAAM,CAAC,KAAKA,EAAY,QAAQ,MAAM,QAAQ,aAAa,OAAO,cAAc,OAAO,aAAa,EAAK,EAAE,UAAU,CAAC,KAAKA,EAAY,QAAQ,MAAM,QAAQ,aAAa,OAAO,cAAc,SAAS,aAAa,EAAI,EAAE,WAAW,CAAC,KAAKA,EAAY,QAAQ,MAAM,aAAa,aAAa,OAAO,cAAc,OAAO,aAAa,EAAK,CAAC,CAAC",
  "names": ["WIDGET_URL", "TallyForms", "props", "form", "title", "alignLeft", "background", "iframeRef", "pe", "pageTitle", "setPageTitle", "ye", "queryParams", "ue", "h1Element", "embedUrl", "matches", "loadWidgetScript", "scriptEl", "loadEmbeds", "_iframeEl_dataset", "iframeEl", "e", "p", "addPropertyControls", "ControlType"]
}
