PluginProbe ʕ •ᴥ•ʔ
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz / 2.12.3
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz v2.12.3
2.12.6 2.12.5 2.12.4 2.12.3 2.12.2 2.12.1 2.12.0 2.11.1 2.11.0 2.10.1 2.10.0 2.9.1 2.9.0 2.8.2 2.8.1 2.7.0 2.7.1 2.8.0 trunk 0.0.10 0.0.11 0.0.12 0.0.13 0.0.2 0.0.3 0.0.4 0.0.5 0.0.6 0.0.7 0.0.8 0.0.9 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.1.0 1.1.1 1.1.2 1.10.0 1.10.1 1.11.0 1.12.0 1.12.1 1.12.2 1.12.3 1.13.0 1.13.1 1.13.2 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.5.0 1.5.1 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.8.0 1.9.0 1.9.1 2.0.0 2.0.1 2.0.2 2.1.0 2.1.1 2.2.0 2.2.1 2.2.2 2.3.0 2.4.0 2.5.0 2.5.2 2.6.0
sureforms / assets / build / htmlFormDetector.js
sureforms / assets / build Last commit date
images 5 months ago blocks.asset.php 4 weeks ago blocks.js 4 weeks ago blocks.js.LICENSE.txt 5 months ago common-editor.css 5 months ago dashboard.asset.php 4 weeks ago dashboard.css 4 weeks ago dashboard.js 2 months ago dashboard.js.LICENSE.txt 3 months ago editor.asset.php 2 years ago editor.js 2 years ago editorNudge.asset.php 3 months ago editorNudge.js 3 months ago elementorPreviewStyling.asset.php 5 months ago elementorPreviewStyling.js 5 months ago entries.asset.php 4 weeks ago entries.js 4 weeks ago entries.js.LICENSE.txt 3 months ago formEditor.asset.php 1 month ago formEditor.js 1 month ago formEditor.js.LICENSE.txt 1 year ago formSubmit.asset.php 1 month ago formSubmit.js 1 month ago formSubmit.js.LICENSE.txt 1 year ago forms.asset.php 4 weeks ago forms.css 4 weeks ago forms.js 2 months ago forms.js.LICENSE.txt 3 months ago htmlFormDetector.asset.php 3 months ago htmlFormDetector.js 3 months ago htmlFormDetector.js.LICENSE.txt 3 months ago learn.asset.php 4 weeks ago learn.css 4 weeks ago learn.js 3 months ago learn.js.LICENSE.txt 5 months ago page_header.asset.php 2 months ago page_header.js 2 months ago page_header.js.LICENSE.txt 9 months ago partialEntriesEmptyState.asset.php 4 weeks ago partialEntriesEmptyState.css 4 weeks ago partialEntriesEmptyState.js 3 months ago partialEntriesEmptyState.js.LICENSE.txt 3 months ago payments.asset.php 4 weeks ago payments.css 4 weeks ago payments.js 3 months ago payments.js.LICENSE.txt 3 months ago previewStyling.asset.php 5 months ago previewStyling.js 5 months ago quickActionSidebar.asset.php 1 month ago quickActionSidebar.js 1 month ago quizEmptyState.asset.php 4 weeks ago quizEmptyState.css 4 weeks ago quizEmptyState.js 3 months ago quizEmptyState.js.LICENSE.txt 5 months ago settings.asset.php 4 weeks ago settings.css 4 weeks ago settings.js 1 month ago settings.js.LICENSE.txt 3 months ago suremail.asset.php 4 weeks ago suremail.css 4 weeks ago suremail.js 6 months ago suremail.js.LICENSE.txt 1 year ago surveyEmptyState.asset.php 4 weeks ago surveyEmptyState.css 4 weeks ago surveyEmptyState.js 3 months ago surveyEmptyState.js.LICENSE.txt 4 months ago templatePicker.asset.php 1 month ago templatePicker.js 1 month ago templatePicker.js.LICENSE.txt 3 months ago
htmlFormDetector.js
2 lines
1 /*! For license information please see htmlFormDetector.js.LICENSE.txt */
2 (()=>{"use strict";var t={n:e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return t.d(r,{a:r}),r},d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)};const e=window.wp.apiFetch;var r=t.n(e);const n=window.wp.blockEditor,o=window.wp.blocks,i=window.wp.components,a=window.wp.compose,u=window.wp.data,l=window.wp.element,c=window.wp.hooks,s=window.wp.i18n,f=function(){return React.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",className:"srfm-logo",xmlns:"http://www.w3.org/2000/svg"},React.createElement("style",null,".is-selected svg.srfm-logo path {fill:#000000;}"),React.createElement("g",{clipPath:"url(#clip0_15961_16935)"},React.createElement("rect",{width:"24",height:"24",fill:"evenodd"}),React.createElement("path",{d:"M6.85742 5.14258H17.1431V8.57115H8.57171L6.85742 10.2854V8.57115V5.14258Z",fill:"white"}),React.createElement("path",{d:"M6.85742 5.14258H17.1431V8.57115H8.57171L6.85742 10.2854V8.57115V5.14258Z",fill:"white"}),React.createElement("path",{d:"M6.85742 10.2852H15.4288V13.7137H8.57171L6.85742 15.428V13.7137V10.2852Z",fill:"white"}),React.createElement("path",{d:"M6.85742 10.2852H15.4288V13.7137H8.57171L6.85742 15.428V13.7137V10.2852Z",fill:"white"}),React.createElement("path",{d:"M6.85742 15.4287H12.0003V18.8573H6.85742V15.4287Z",fill:"white"}),React.createElement("path",{d:"M6.85742 15.4287H12.0003V18.8573H6.85742V15.4287Z",fill:"white"})),React.createElement("defs",null,React.createElement("clipPath",{id:"clip0_15961_16935"},React.createElement("rect",{width:"24",height:"24",fill:"white"}))))};function d(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var h={text:"input",email:"email",url:"url",tel:"phone",number:"number",password:"input",search:"input",file:"upload",hidden:"hidden"};function m(t){return"undefined"!=typeof window&&window.CSS&&"function"==typeof window.CSS.escape?window.CSS.escape(t):String(t).replace(/["\\]/g,"\\$&")}function p(t){for(var e=t.previousSibling;e;){if(1===e.nodeType){if("LABEL"===e.tagName)return e.getAttribute("for")?"":(e.textContent||"").trim();if("BR"!==e.tagName)return""}else if(3===e.nodeType&&""!==(e.textContent||"").trim())return"";e=e.previousSibling}return""}function v(t,e){var r=t.getAttribute("id");if(r){var n=e.querySelector('label[for="'.concat(m(r),'"]'));if(null!=n&&n.textContent)return n.textContent.trim()}var o=t.closest("label");if(null!=o&&o.textContent)return o.textContent.trim();var i=p(t);if(i)return i;var a=t.getAttribute("aria-label");if(a)return a.trim();var u=t.getAttribute("placeholder");if(u)return u.trim();var l=t.getAttribute("name");return l?l.replace(/[_-]+/g," ").replace(/\b\w/g,(function(t){return t.toUpperCase()})).trim():""}function y(t,e){var r=function(t){for(var e=t.nextSibling,r="";e&&1!==e.nodeType;)3===e.nodeType&&(r+=e.textContent||""),e=e.nextSibling;return r.trim()}(t);if(r)return r;var n=t.getAttribute("id");if(n){var o=e.querySelector('label[for="'.concat(m(n),'"]'));if(null!=o&&o.textContent)return o.textContent.trim()}var i=t.closest("label");if(null!=i&&i.textContent)return i.textContent.trim();var a=t.getAttribute("value");return a?a.trim():""}function g(t){var e,r;if("string"!=typeof t||!/<form\b/i.test(t))return null;var n=(new window.DOMParser).parseFromString(t,"text/html"),o=n.querySelector("form");if(!o)return null;var i=o.querySelectorAll("input, textarea, select");if(i.length>200)return{fields:[{fieldType:"input",label:"Field",required:!1,confidence:"low"}],submitText:"",styling:{},confidence:"low"};var a=[];i.forEach((function(t){if("INPUT"===t.tagName){var e=function(t,e){var r=(t.getAttribute("type")||"text").toLowerCase();if("submit"===r||"button"===r||"reset"===r||"image"===r)return null;if("checkbox"===r)return{fieldType:"gdpr",label:v(t,e)||"Checkbox",required:t.hasAttribute("required"),confidence:"medium"};if("radio"===r){var n,o=t.closest("fieldset"),i=null==o?void 0:o.querySelector("legend"),a=(null==i||null===(n=i.textContent)||void 0===n?void 0:n.trim())||p(t)||"";return{fieldType:"multi-choice",label:y(t,e)||"Choice",required:t.hasAttribute("required"),singleSelection:!0,confidence:"medium",_groupName:t.getAttribute("name")||"",_optionValue:t.getAttribute("value")||"",_groupLabel:a}}var u=h[r];return{fieldType:u||"input",label:v(t,e)||"Field",required:t.hasAttribute("required"),defaultValue:t.getAttribute("value")||void 0,placeholder:t.getAttribute("placeholder")||void 0,confidence:u?"high":"low"}}(t,n);e&&a.push(e)}else"TEXTAREA"===t.tagName?a.push(function(t,e){return{fieldType:"textarea",label:v(t,e)||"Message",required:t.hasAttribute("required"),placeholder:t.getAttribute("placeholder")||void 0,confidence:"high"}}(t,n)):"SELECT"===t.tagName&&a.push(function(t,e){var r,n=Array.from(t.querySelectorAll("option")).filter((function(t,e){var n,o=t.getAttribute("value"),i=(null===(n=t.textContent)||void 0===n?void 0:n.trim())||"";return!(0===e&&(null===o||""===o)&&i&&(r=i,1))})).map((function(t){var e,r=(null===(e=t.textContent)||void 0===e?void 0:e.trim())||t.getAttribute("value")||"";return r?{label:r,optionTitle:r}:null})).filter(Boolean);return{fieldType:"dropdown",label:v(t,e)||"Select",required:t.hasAttribute("required"),fieldOptions:n,placeholder:r,confidence:n.length?"high":"low"}}(t,n))}));var u=function(t){var e,r=[],n=new Map,o=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return d(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?d(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}(t);try{for(o.s();!(e=o.n()).done;){var i=e.value;if("multi-choice"===i.fieldType&&i._groupName){if(!n.has(i._groupName)){var a={fieldType:"multi-choice",label:i._groupLabel||i._groupName.replace(/[_-]+/g," "),required:i.required,singleSelection:!0,fieldOptions:[],confidence:"medium"};n.set(i._groupName,a),r.push(a)}var u=n.get(i._groupName),l=i.label||i._optionValue;l&&u.fieldOptions.push({label:l,optionTitle:l})}else r.push(i)}}catch(t){o.e(t)}finally{o.f()}return r}(a),l=o.querySelector('button[type="submit"], input[type="submit"]');if(!l){var c=Array.from(o.querySelectorAll("button:not([type])")).filter((function(t){return!/\b(cancel|reset|clear|back|close)\b/i.test((t.textContent||"").trim())}));l=c[c.length-1]||null}var s=(null===(e=l)||void 0===e||null===(e=e.textContent)||void 0===e?void 0:e.trim())||(null===(r=l)||void 0===r||null===(r=r.getAttribute("value"))||void 0===r?void 0:r.trim())||"",f=function(t,e){var r={};if(!t)return r;var n=t.style||{};if(n.backgroundColor){var o=b(n.backgroundColor);o&&(r.formBackgroundColor=o)}if(n.color){var i=b(n.color);i&&(r.textColor=i)}if(n.padding&&(r.formPadding=n.padding),n.borderRadius&&(r.formBorderRadius=n.borderRadius),n.border&&(r.formBorder=n.border),e){var a=e.style||{};if(a.backgroundColor){var u=b(a.backgroundColor);u&&(r.primaryColor=u)}if(a.color){var l=b(a.color);l&&(r.textColorOnPrimary=l)}}return r}(o,l),m=u.filter((function(t){return"low"===t.confidence})).length;return{fields:u,submitText:s,styling:f,confidence:0===u.length||2*m>u.length?"low":"high"}}function b(t){if("string"!=typeof t||!t.trim())return null;var e=window.document.createElement("div");if(e.style.color="",e.style.color=t,!e.style.color)return null;var r=e.style.color.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);if(!r)return null;var n=function(t){var e=Number(t).toString(16);return 1===e.length?"0"+e:e};return"#"+n(r[1])+n(r[2])+n(r[3])}function w(t){return w="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},w(t)}function _(){_=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function l(t,e,r,n){return Object.defineProperty(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n})}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function c(e,r,n,o){var i=r&&r.prototype instanceof d?r:d,a=Object.create(i.prototype);return l(a,"_invoke",function(e,r,n){var o=1;return function(i,a){if(3===o)throw Error("Generator is already running");if(4===o){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var u=n.delegate;if(u){var l=E(u,n);if(l){if(l===f)continue;return l}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(1===o)throw o=4,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=3;var c=s(e,r,n);if("normal"===c.type){if(o=n.done?4:2,c.arg===f)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(o=4,n.method="throw",n.arg=c.arg)}}}(e,n,new C(o||[])),!0),a}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=c;var f={};function d(){}function h(){}function m(){}var p={};l(p,i,(function(){return this}));var v=Object.getPrototypeOf,y=v&&v(v(k([])));y&&y!==r&&n.call(y,i)&&(p=y);var g=m.prototype=d.prototype=Object.create(p);function b(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){function r(o,i,a,u){var l=s(t[o],t,i);if("throw"!==l.type){var c=l.arg,f=c.value;return f&&"object"==w(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,u)}),(function(t){r("throw",t,a,u)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,u)}))}u(l.arg)}var o;l(this,"_invoke",(function(t,n){function i(){return new e((function(e,o){r(t,n,e,o)}))}return o=o?o.then(i,i):i()}),!0)}function E(e,r){var n=r.method,o=e.i[n];if(o===t)return r.delegate=null,"throw"===n&&e.i.return&&(r.method="return",r.arg=t,E(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;var i=s(o,e.i,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,f;var a=i.arg;return a?a.done?(r[e.r]=a.value,r.next=e.n,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,f):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,f)}function S(t){this.tryEntries.push(t)}function A(e){var r=e[4]||{};r.type="normal",r.arg=t,e[4]=r}function C(t){this.tryEntries=[[-1]],t.forEach(S,this),this.reset(!0)}function k(e){if(null!=e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,a=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(w(e)+" is not iterable")}return h.prototype=m,l(g,"constructor",m),l(m,"constructor",h),h.displayName=l(m,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,m):(t.__proto__=m,l(t,u,"GeneratorFunction")),t.prototype=Object.create(g),t},e.awrap=function(t){return{__await:t}},b(x.prototype),l(x.prototype,a,(function(){return this})),e.AsyncIterator=x,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new x(c(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},b(g),l(g,u,"Generator"),l(g,i,(function(){return this})),l(g,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.unshift(n);return function t(){for(;r.length;)if((n=r.pop())in e)return t.value=n,t.done=!1,t;return t.done=!0,t}},e.values=k,C.prototype={constructor:C,reset:function(e){if(this.prev=this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(A),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0][4];if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(t){a.type="throw",a.arg=e,r.next=t}for(var o=r.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i[4],u=this.prev,l=i[1],c=i[2];if(-1===i[0])return n("end"),!1;if(!l&&!c)throw Error("try statement without catch or finally");if(null!=i[0]&&i[0]<=u){if(u<l)return this.method="next",this.arg=t,n(l),!0;if(u<c)return n(c),!1}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n[0]>-1&&n[0]<=this.prev&&this.prev<n[2]){var o=n;break}}o&&("break"===t||"continue"===t)&&o[0]<=e&&e<=o[2]&&(o=null);var i=o?o[4]:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o[2],f):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r[2]===t)return this.complete(r[4],r[3]),A(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r[0]===t){var n=r[4];if("throw"===n.type){var o=n.arg;A(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={i:k(e),r,n},"next"===this.method&&(this.arg=t),f}},e}function x(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],l=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);l=!0);}catch(t){c=!0,o=t}finally{try{if(!l&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return u}}(t,e)||function(t,e){if(t){if("string"==typeof t)return E(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?E(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function E(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function S(t,e,r,n,o,i,a){try{var u=t[i](a),l=u.value}catch(t){return void r(t)}u.done?e(l):Promise.resolve(l).then(n,o)}function A(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){S(i,n,o,a,u,"next",t)}function u(t){S(i,n,o,a,u,"throw",t)}a(void 0)}))}}var C="core/html";function k(t,e,r){return T.apply(this,arguments)}function T(){return(T=A(_().mark((function t(e,n,i){var a,l,c,f,d,h,m,p,v,y,g,b;return _().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(l=(0,u.dispatch)("core/notices"),c=null===(a=window.srfm_html_form_detector)||void 0===a?void 0:a.rest_nonce){t.next=5;break}return l.createErrorNotice((0,s.__)("SureForms could not authenticate this request. Please reload the editor and try again.","sureforms"),{type:"snackbar"}),t.abrupt("return",!1);case 5:return f=(0,u.dispatch)("core/block-editor"),t.prev=6,t.next=9,r()({path:"/sureforms/v1/convert-html-form",method:"POST",headers:{"X-WP-Nonce":c},data:{parsed_fields:i.fields,submit_text:i.submitText,styling:i.styling||{},confidence:i.confidence,html:n,form_title:(void 0,void 0,x=void 0,E=void 0,void 0,E=null!==(w=null===(_=(0,u.select)("core/editor"))||void 0===_||null===(x=_.getEditedPostAttribute)||void 0===x?void 0:x.call(_,"title"))&&void 0!==w?w:"",S="string"==typeof E?E.trim():"",S?(0,s.sprintf)((0,s.__)("%s — Converted form","sureforms"),S):(0,s.__)("Converted form","sureforms"))}});case 9:if(h=t.sent,m=Number(null!==(d=null==h?void 0:h.form_id)&&void 0!==d?d:0),p="string"==typeof(null==h?void 0:h.shortcode)?h.shortcode:"",m&&p){t.next=16;break}throw(v=new Error("SureForms convert endpoint returned an unexpected payload.")).code="srfm_html_convert_bad_payload",v;case 16:return y=(0,o.createBlock)("core/shortcode",{text:p}),(g="string"==typeof(null==h?void 0:h.preserved_html)?h.preserved_html:"")?(b=(0,o.createBlock)(C,{content:g}),f.replaceBlock(e,[b,y])):f.replaceBlock(e,y),l.createSuccessNotice(null!=h&&h.used_ai?(0,s.__)("Form converted to SureForms using AI. Review the new form for any tweaks.","sureforms"):(0,s.__)("Form converted to SureForms.","sureforms"),{type:"snackbar"}),t.abrupt("return",!0);case 23:return t.prev=23,t.t0=t.catch(6),l.createErrorNotice(O(null===t.t0||void 0===t.t0?void 0:t.t0.code),{type:"snackbar"}),t.abrupt("return",!1);case 27:case"end":return t.stop()}var w,_,x,E,S}),t,null,[[6,23]])})))).apply(this,arguments)}function O(t){switch(t){case"srfm_html_convert_nonce_failed":case"rest_cookie_invalid_nonce":return(0,s.__)("SureForms could not authenticate this request. Please reload the editor and try again.","sureforms");case"srfm_html_convert_forbidden":case"rest_forbidden":return(0,s.__)("You do not have permission to convert this form.","sureforms");case"srfm_html_convert_too_large":return(0,s.__)("This form is too large to convert. Try simplifying the markup or building the form manually.","sureforms");case"srfm_html_convert_no_fields":return(0,s.__)("SureForms could not derive any fields from this form.","sureforms");case"srfm_html_convert_ai_failed":case"srfm_html_convert_ai_empty":return(0,s.__)("The SureForms AI service could not process this form. Please try again or build the form manually.","sureforms");case"srfm_html_convert_bad_payload":return(0,s.__)("SureForms received an unexpected response. Please try again.","sureforms");default:return(0,s.__)("Could not convert this form to SureForms. Please try again.","sureforms")}}var R=(0,a.createHigherOrderComponent)((function(t){return function(e){var r,o;if(e.name!==C)return React.createElement(t,e);var a=null!==(r=null===(o=e.attributes)||void 0===o?void 0:o.content)&&void 0!==r?r:"",u=x((0,l.useState)(a),2),c=u[0],d=u[1];(0,l.useEffect)((function(){var t=setTimeout((function(){return d(a)}),250);return function(){return clearTimeout(t)}}),[a]);var h=(0,l.useMemo)((function(){try{return g(c)}catch(t){return null}}),[c]),m=x((0,l.useState)(!1),2),p=m[0],v=m[1];if(!h||0===h.fields.length)return React.createElement(t,e);var y=function(){var t=A(_().mark((function t(){return _().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!p){t.next=2;break}return t.abrupt("return");case 2:return v(!0),t.next=5,k(e.clientId,a,h);case 5:t.sent||v(!1);case 7:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),b=p?(0,s.__)("Converting…","sureforms"):(0,s.__)("Convert to SureForms","sureforms");return React.createElement(l.Fragment,null,React.createElement(n.BlockControls,{group:"other"},React.createElement(i.ToolbarGroup,null,React.createElement(i.ToolbarButton,{icon:React.createElement(f,null),label:b,onClick:y,disabled:p,isBusy:p},b))),React.createElement(t,e))}}),"withConvertToSureForms");(0,c.addFilter)("editor.BlockEdit","".concat("sureforms/html-form-detector","/with-convert-button"),R)})();