df-ae-forms-package 1.0.46 → 1.0.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -7,7 +7,7 @@ import t,{useState as e,useEffect as A,useCallback as r,useRef as n,useMemo as i
7
7
  *
8
8
  * This source code is licensed under the MIT license found in the
9
9
  * LICENSE file in the root directory of this source tree.
10
- */"production"===process.env.NODE_ENV?z.exports=function(){if(V)return G;V=1;var e=t,A=Symbol.for("react.element"),r=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function a(t,e,r){var a,o={},l=null,c=null;for(a in void 0!==r&&(l=""+r),void 0!==e.key&&(l=""+e.key),void 0!==e.ref&&(c=e.ref),e)n.call(e,a)&&!s.hasOwnProperty(a)&&(o[a]=e[a]);if(t&&t.defaultProps)for(a in e=t.defaultProps)void 0===o[a]&&(o[a]=e[a]);return{$$typeof:A,type:t,key:l,ref:c,props:o,_owner:i.current}}return G.Fragment=r,G.jsx=a,G.jsxs=a,G}():z.exports=(q||(q=1,"production"!==process.env.NODE_ENV&&function(){var e,A=t,r=Symbol.for("react.element"),n=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),h=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen"),g=Symbol.iterator,m=A.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function v(t){for(var e=arguments.length,A=new Array(e>1?e-1:0),r=1;r<e;r++)A[r-1]=arguments[r];!function(t,e,A){var r=m.ReactDebugCurrentFrame.getStackAddendum();""!==r&&(e+="%s",A=A.concat([r]));var n=A.map(function(t){return String(t)});n.unshift("Warning: "+e),Function.prototype.apply.call(console[t],console,n)}("error",t,A)}function w(t){return t.displayName||"Context"}function B(t){if(null==t)return null;if("number"==typeof t.tag&&v("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),"function"==typeof t)return t.displayName||t.name||null;if("string"==typeof t)return t;switch(t){case i:return"Fragment";case n:return"Portal";case a:return"Profiler";case s:return"StrictMode";case u:return"Suspense";case h:return"SuspenseList"}if("object"==typeof t)switch(t.$$typeof){case l:return w(t)+".Consumer";case o:return w(t._context)+".Provider";case c:return function(t,e,A){var r=t.displayName;if(r)return r;var n=e.displayName||e.name||"";return""!==n?A+"("+n+")":A}(t,t.render,"ForwardRef");case d:var e=t.displayName||null;return null!==e?e:B(t.type)||"Memo";case f:var A=t,r=A._payload,p=A._init;try{return B(p(r))}catch(t){return null}}return null}e=Symbol.for("react.module.reference");var b,y,C,x,F,Q,U,E=Object.assign,N=0;function S(){}S.__reactDisabledLog=!0;var L,I=m.ReactCurrentDispatcher;function _(t,e,A){if(void 0===L)try{throw Error()}catch(t){var r=t.stack.trim().match(/\n( *(at )?)/);L=r&&r[1]||""}return"\n"+L+t}var O,k=!1,T="function"==typeof WeakMap?WeakMap:Map;function j(t,e){if(!t||k)return"";var A,r=O.get(t);if(void 0!==r)return r;k=!0;var n,i=Error.prepareStackTrace;Error.prepareStackTrace=void 0,n=I.current,I.current=null,function(){if(0===N){b=console.log,y=console.info,C=console.warn,x=console.error,F=console.group,Q=console.groupCollapsed,U=console.groupEnd;var t={configurable:!0,enumerable:!0,value:S,writable:!0};Object.defineProperties(console,{info:t,log:t,warn:t,error:t,group:t,groupCollapsed:t,groupEnd:t})}N++}();try{if(e){var s=function(){throw Error()};if(Object.defineProperty(s.prototype,"props",{set:function(){throw Error()}}),"object"==typeof Reflect&&Reflect.construct){try{Reflect.construct(s,[])}catch(t){A=t}Reflect.construct(t,[],s)}else{try{s.call()}catch(t){A=t}t.call(s.prototype)}}else{try{throw Error()}catch(t){A=t}t()}}catch(e){if(e&&A&&"string"==typeof e.stack){for(var a=e.stack.split("\n"),o=A.stack.split("\n"),l=a.length-1,c=o.length-1;l>=1&&c>=0&&a[l]!==o[c];)c--;for(;l>=1&&c>=0;l--,c--)if(a[l]!==o[c]){if(1!==l||1!==c)do{if(l--,--c<0||a[l]!==o[c]){var u="\n"+a[l].replace(" at new "," at ");return t.displayName&&u.includes("<anonymous>")&&(u=u.replace("<anonymous>",t.displayName)),"function"==typeof t&&O.set(t,u),u}}while(l>=1&&c>=0);break}}}finally{k=!1,I.current=n,function(){if(0===--N){var t={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:E({},t,{value:b}),info:E({},t,{value:y}),warn:E({},t,{value:C}),error:E({},t,{value:x}),group:E({},t,{value:F}),groupCollapsed:E({},t,{value:Q}),groupEnd:E({},t,{value:U})})}N<0&&v("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}(),Error.prepareStackTrace=i}var h=t?t.displayName||t.name:"",d=h?_(h):"";return"function"==typeof t&&O.set(t,d),d}function H(t,e,A){if(null==t)return"";if("function"==typeof t)return j(t,!(!(r=t.prototype)||!r.isReactComponent));var r;if("string"==typeof t)return _(t);switch(t){case u:return _("Suspense");case h:return _("SuspenseList")}if("object"==typeof t)switch(t.$$typeof){case c:return j(t.render,!1);case d:return H(t.type,e,A);case f:var n=t,i=n._payload,s=n._init;try{return H(s(i),e,A)}catch(t){}}return""}O=new T;var P=Object.prototype.hasOwnProperty,D={},M=m.ReactDebugCurrentFrame;function R(t){if(t){var e=t._owner,A=H(t.type,t._source,e?e.type:null);M.setExtraStackFrame(A)}else M.setExtraStackFrame(null)}var K=Array.isArray;function V(t){return K(t)}function z(t){return""+t}function G(t){if(function(t){try{return z(t),!1}catch(t){return!0}}(t))return v("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",function(t){return"function"==typeof Symbol&&Symbol.toStringTag&&t[Symbol.toStringTag]||t.constructor.name||"Object"}(t)),z(t)}var q,X,Y,J=m.ReactCurrentOwner,$={key:!0,ref:!0,__self:!0,__source:!0};function Z(t,e,A,n,i){var s,a={},o=null,l=null;for(s in void 0!==A&&(G(A),o=""+A),function(t){if(P.call(t,"key")){var e=Object.getOwnPropertyDescriptor(t,"key").get;if(e&&e.isReactWarning)return!1}return void 0!==t.key}(e)&&(G(e.key),o=""+e.key),function(t){if(P.call(t,"ref")){var e=Object.getOwnPropertyDescriptor(t,"ref").get;if(e&&e.isReactWarning)return!1}return void 0!==t.ref}(e)&&(l=e.ref,function(t,e){if("string"==typeof t.ref&&J.current&&e&&J.current.stateNode!==e){var A=B(J.current.type);Y[A]||(v('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',B(J.current.type),t.ref),Y[A]=!0)}}(e,i)),e)P.call(e,s)&&!$.hasOwnProperty(s)&&(a[s]=e[s]);if(t&&t.defaultProps){var c=t.defaultProps;for(s in c)void 0===a[s]&&(a[s]=c[s])}if(o||l){var u="function"==typeof t?t.displayName||t.name||"Unknown":t;o&&function(t,e){var A=function(){q||(q=!0,v("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",e))};A.isReactWarning=!0,Object.defineProperty(t,"key",{get:A,configurable:!0})}(a,u),l&&function(t,e){var A=function(){X||(X=!0,v("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",e))};A.isReactWarning=!0,Object.defineProperty(t,"ref",{get:A,configurable:!0})}(a,u)}return function(t,e,A,n,i,s,a){var o={$$typeof:r,type:t,key:e,ref:A,props:a,_owner:s,_store:{}};return Object.defineProperty(o._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(o,"_self",{configurable:!1,enumerable:!1,writable:!1,value:n}),Object.defineProperty(o,"_source",{configurable:!1,enumerable:!1,writable:!1,value:i}),Object.freeze&&(Object.freeze(o.props),Object.freeze(o)),o}(t,o,l,i,n,J.current,a)}Y={};var tt,et=m.ReactCurrentOwner,At=m.ReactDebugCurrentFrame;function rt(t){if(t){var e=t._owner,A=H(t.type,t._source,e?e.type:null);At.setExtraStackFrame(A)}else At.setExtraStackFrame(null)}function nt(t){return"object"==typeof t&&null!==t&&t.$$typeof===r}function it(){if(et.current){var t=B(et.current.type);if(t)return"\n\nCheck the render method of `"+t+"`."}return""}tt=!1;var st={};function at(t,e){if(t._store&&!t._store.validated&&null==t.key){t._store.validated=!0;var A=function(t){var e=it();if(!e){var A="string"==typeof t?t:t.displayName||t.name;A&&(e="\n\nCheck the top-level render call using <"+A+">.")}return e}(e);if(!st[A]){st[A]=!0;var r="";t&&t._owner&&t._owner!==et.current&&(r=" It was passed a child from "+B(t._owner.type)+"."),rt(t),v('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',A,r),rt(null)}}}function ot(t,e){if("object"==typeof t)if(V(t))for(var A=0;A<t.length;A++){var r=t[A];nt(r)&&at(r,e)}else if(nt(t))t._store&&(t._store.validated=!0);else if(t){var n=function(t){if(null===t||"object"!=typeof t)return null;var e=g&&t[g]||t["@@iterator"];return"function"==typeof e?e:null}(t);if("function"==typeof n&&n!==t.entries)for(var i,s=n.call(t);!(i=s.next()).done;)nt(i.value)&&at(i.value,e)}}function lt(t){var e,A=t.type;if(null!=A&&"string"!=typeof A){if("function"==typeof A)e=A.propTypes;else{if("object"!=typeof A||A.$$typeof!==c&&A.$$typeof!==d)return;e=A.propTypes}if(e){var r=B(A);!function(t,e,A,r,n){var i=Function.call.bind(P);for(var s in t)if(i(t,s)){var a=void 0;try{if("function"!=typeof t[s]){var o=Error((r||"React class")+": "+A+" type `"+s+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof t[s]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw o.name="Invariant Violation",o}a=t[s](e,s,r,A,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(t){a=t}!a||a instanceof Error||(R(n),v("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",r||"React class",A,s,typeof a),R(null)),a instanceof Error&&!(a.message in D)&&(D[a.message]=!0,R(n),v("Failed %s type: %s",A,a.message),R(null))}}(e,t.props,"prop",r,t)}else void 0===A.PropTypes||tt||(tt=!0,v("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",B(A)||"Unknown"));"function"!=typeof A.getDefaultProps||A.getDefaultProps.isReactClassApproved||v("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}var ct={};function ut(t,A,n,g,m,w){var b=function(t){return"string"==typeof t||"function"==typeof t||t===i||t===a||t===s||t===u||t===h||t===p||"object"==typeof t&&null!==t&&(t.$$typeof===f||t.$$typeof===d||t.$$typeof===o||t.$$typeof===l||t.$$typeof===c||t.$$typeof===e||void 0!==t.getModuleId)}(t);if(!b){var y="";(void 0===t||"object"==typeof t&&null!==t&&0===Object.keys(t).length)&&(y+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var C,x=function(t){return void 0!==t?"\n\nCheck your code at "+t.fileName.replace(/^.*[\\\/]/,"")+":"+t.lineNumber+".":""}(m);y+=x||it(),null===t?C="null":V(t)?C="array":void 0!==t&&t.$$typeof===r?(C="<"+(B(t.type)||"Unknown")+" />",y=" Did you accidentally export a JSX literal instead of a component?"):C=typeof t,v("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",C,y)}var F=Z(t,A,n,m,w);if(null==F)return F;if(b){var Q=A.children;if(void 0!==Q)if(g)if(V(Q)){for(var U=0;U<Q.length;U++)ot(Q[U],t);Object.freeze&&Object.freeze(Q)}else v("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else ot(Q,t)}if(P.call(A,"key")){var E=B(t),N=Object.keys(A).filter(function(t){return"key"!==t}),S=N.length>0?"{key: someKey, "+N.join(": ..., ")+": ...}":"{key: someKey}";ct[E+S]||(v('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',S,E,N.length>0?"{"+N.join(": ..., ")+": ...}":"{}",E),ct[E+S]=!0)}return t===i?function(t){for(var e=Object.keys(t.props),A=0;A<e.length;A++){var r=e[A];if("children"!==r&&"key"!==r){rt(t),v("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",r),rt(null);break}}null!==t.ref&&(rt(t),v("Invalid attribute `ref` supplied to `React.Fragment`."),rt(null))}(F):lt(F),F}var ht=function(t,e,A){return ut(t,e,A,!1)},dt=function(t,e,A){return ut(t,e,A,!0)};W.Fragment=i,W.jsx=ht,W.jsxs=dt}()),W);var X=z.exports;class Y{constructor(){}static getInstance(){return Y.instance||(Y.instance=new Y),Y.instance}getAvailableComponentsForConditional(t,e){if(!t||!Array.isArray(t))return[];const A=t.filter(t=>!e||t.id!==e).map(t=>{var e;return{id:t.id,label:(null===(e=t.basic)||void 0===e?void 0:e.label)||t.id,type:t.name,key:t.id}}).sort((t,e)=>t.label.localeCompare(e.label));return A}getApplicableOperators(t){switch(t){case"text-input":case"email-input":case"textarea":return["equals","notEquals","contains","notContains","isEmpty","isNotEmpty"];case"number-input":case"date-picker":case"datetime-picker":return["equals","notEquals","greaterThan","lessThan","greaterThanOrEqual","lessThanOrEqual","isEmpty","isNotEmpty"];case"select":case"radio":case"segment":default:return["equals","notEquals","isEmpty","isNotEmpty"];case"checkbox":return["contains","notContains","isEmpty","isNotEmpty"]}}validateConditionalLogic(t,e){const A=[];return t?(["show","hide","always"].includes(t.action)||A.push("Invalid conditional action"),["all","any"].includes(t.when)||A.push("Invalid when condition"),t.conditions&&0!==t.conditions.length?t.conditions.forEach((t,r)=>{let n=e.find(e=>{var A;return(null===(A=e.basic)||void 0===A?void 0:A.label)===t.when});if(n||(n=e.find(e=>e.id===t.when)),!n)return void A.push(`Condition ${r+1}: Component not found`);this.getApplicableOperators(n.name).includes(t.operator)||A.push(`Condition ${r+1}: Operator not applicable for component type`),this.isValidConditionValue(t.value,n.name,t.operator)||A.push(`Condition ${r+1}: Invalid condition value`)}):A.push("At least one condition is required"),{isValid:0===A.length,errors:A}):{isValid:!0,errors:[]}}evaluateConditionalLogic(t,e,A){if("always"===t.action)return{shouldShow:!0,evaluatedConditions:[]};if(!t||!t.conditions||0===t.conditions.length)return{shouldShow:!0,evaluatedConditions:[]};const r=t.conditions.map(t=>{const r=this.getComponentValue(t.when,e,A);return{condition:t,result:this.evaluateCondition(t,r),componentValue:r}});return{shouldShow:this.determineFinalResult(t,r),evaluatedConditions:r}}getComponentValue(t,e,A){if(A&&void 0!==A[t])return A[t];let r=e.find(e=>{var A;return(null===(A=e.basic)||void 0===A?void 0:A.label)===t});return r||(r=e.find(e=>e.id===t)),r&&"defaultValue"in r.basic?r.basic.defaultValue:void 0}evaluateCondition(t,e){const{operator:A,value:r}=t;if("checked"===r||"notChecked"===r)return this.evaluateCheckboxCondition(e,r);switch(A){case"equals":return this.isEqual(e,r);case"notEquals":return!this.isEqual(e,r);case"isEmpty":return this.isEmpty(e);case"isNotEmpty":return!this.isEmpty(e);case"contains":return this.contains(e,r);case"notContains":return!this.contains(e,r);case"greaterThan":return this.isGreaterThan(e,r);case"lessThan":return this.isLessThan(e,r);case"greaterThanOrEqual":return this.isGreaterThanOrEqual(e,r);case"lessThanOrEqual":return this.isLessThanOrEqual(e,r);default:return!1}}evaluateCheckboxCondition(t,e){const A=this.isCheckboxChecked(t);return"checked"===e?A:"notChecked"===e&&!A}isCheckboxChecked(t){return null!=t&&("boolean"==typeof t?t:"string"==typeof t?"true"===t.toLowerCase()||"1"===t:Array.isArray(t)?t.length>0:"number"==typeof t&&t>0)}determineFinalResult(t,e){let A,r;return A="all"===t.when?e.every(t=>t.result):"any"===t.when&&e.some(t=>t.result),r="show"===t.action?A:"hide"===t.action?!A:(t.action,!0),r}isEqual(t,e){if(t===e)return!0;if(null==t||null==e)return!1;if(Array.isArray(t)&&Array.isArray(e))return t.length===e.length&&t.every((t,A)=>this.isEqual(t,e[A]));if("object"==typeof t&&"object"==typeof e){const A=Object.keys(t),r=Object.keys(e);return A.length===r.length&&A.every(A=>this.isEqual(t[A],e[A]))}return!1}isEmpty(t){return null==t||void 0===t||("string"==typeof t?""===t.trim():Array.isArray(t)?0===t.length:"object"==typeof t&&0===Object.keys(t).length)}contains(t,e){return null!=t&&null!=e&&("string"==typeof t?t.toLowerCase().includes(String(e).toLowerCase()):!!Array.isArray(t)&&t.some(t=>this.isEqual(t,e)))}isGreaterThan(t,e){const A=Number(t),r=Number(e);return!isNaN(A)&&!isNaN(r)&&A>r}isLessThan(t,e){const A=Number(t),r=Number(e);return!isNaN(A)&&!isNaN(r)&&A<r}isGreaterThanOrEqual(t,e){const A=Number(t),r=Number(e);return!isNaN(A)&&!isNaN(r)&&A>=r}isLessThanOrEqual(t,e){const A=Number(t),r=Number(e);return!isNaN(A)&&!isNaN(r)&&A<=r}isValidConditionValue(t,e,A){if(null==t)return["isEmpty","isNotEmpty"].includes(A);switch(e){case"number-input":return!isNaN(Number(t))||["isEmpty","isNotEmpty"].includes(A);case"date-picker":case"datetime-picker":return!isNaN(Date.parse(t))||["isEmpty","isNotEmpty"].includes(A);case"checkbox":return Array.isArray(t)||"string"==typeof t||"number"==typeof t;default:return!0}}createDefaultConditionalLogic(){return{action:"show",when:"all",conditions:[]}}getOperatorDisplayText(t){return{equals:"Is Equal To",notEquals:"Is Not Equal To",contains:"Contains",notContains:"Does Not Contain",isEmpty:"Is Empty",isNotEmpty:"Is Not Empty",greaterThan:"Is Greater Than",lessThan:"Is Less Than",greaterThanOrEqual:"Is Greater Than Or Equal To",lessThanOrEqual:"Is Less Than Or Equal To"}[t]||t}getActionDisplayText(t){return{show:"Show this field when",hide:"Hide this field when",always:"Always show this field"}[t]||t}getConditionalLogicSummary(t,e){if(!t||0===t.conditions.length)return"No conditions";if("always"===t.action)return"Always show";const A=this.getActionDisplayText(t.action),r=t.conditions.map(t=>{let A=e.find(e=>{var A;return(null===(A=e.basic)||void 0===A?void 0:A.label)===t.when});A||(A=e.find(e=>e.id===t.when));return`${(null==A?void 0:A.basic.label)||t.when||"Unknown component"} ${this.getOperatorDisplayText(t.operator)} ${this.formatConditionValue(t.value)}`}),n="all"===t.when?" and ":" or ";return`${A} ${r.join(n)}`}formatConditionValue(t){return null==t?"empty":Array.isArray(t)?`[${t.join(", ")}]`:"string"==typeof t?`"${t}"`:String(t)}}const J=Y.getInstance();const $=new class{constructor(){this.toasts=[],this.listeners=[],this.defaultDuration=3e3,this.timeouts={}}generateId(){return Date.now().toString(36)+Math.random().toString(36).substr(2)}notifyListeners(){this.listeners.forEach(t=>t([...this.toasts]))}addToast(t){try{this.toasts.push(t),this.notifyListeners(),this.timeouts[t.id]=setTimeout(()=>{this.removeToast(t.id)},t.duration||this.defaultDuration)}catch(t){console.error("Error displaying toast message:",t)}}removeToast(t){this.timeouts[t]&&(clearTimeout(this.timeouts[t]),delete this.timeouts[t]),this.toasts=this.toasts.filter(e=>e.id!==t),this.notifyListeners()}showSuccess(t,e=3e3){const A={id:this.generateId(),message:t,type:"success",duration:e};this.addToast(A)}showError(t,e=5e3){const A={id:this.generateId(),message:t,type:"danger",duration:e};this.addToast(A)}showWarning(t,e){const A={id:this.generateId(),message:t,type:"warning",duration:e};this.addToast(A)}showInfo(t,e){const A={id:this.generateId(),message:t,type:"info",duration:e};this.addToast(A)}show(t,e="success",A){const r={id:this.generateId(),message:t,type:e,duration:A};this.addToast(r)}clearAll(){Object.values(this.timeouts).forEach(t=>clearTimeout(t)),this.timeouts={},this.toasts=[],this.notifyListeners()}subscribe(t){return this.listeners.push(t),()=>{this.listeners=this.listeners.filter(e=>e!==t)}}getToasts(){return[...this.toasts]}},Z=({validationErrors:t,fieldId:e,touchedFields:A,formSubmitted:r,properties:n,localValidation:i,isTouched:s,mode:a})=>{const o=t=>{var e,A;const r=n.basic.label||"This field",i=n.name||"",s=null===(e=n.validation)||void 0===e?void 0:e.customValidationMessage;if("number-input"===i)switch(t){case"required":return`${r} is required`;case"lowerLimit":return"Number is below the lower limit";case"upperLimit":return"Number is above the upper limit";default:return""}if(s)return s;const a="date-picker"===i||"datetime-picker"===i?(null===(A=n.basic)||void 0===A?void 0:A.dateTimeMode)||("datetime-picker"===i?"datetime":"date"):null;switch(t){case"required":return`${r} is required`;case"invalidDate":return"time"===a?"Please select a valid time":"datetime"===a?"Please select a valid date and time":"date"===a?"Please select a valid date":`${r} is invalid`;case"minLength":return`${r} must be at least ${n.validation.minLength} characters long`;case"maxLength":return`${r} must be no more than ${n.validation.maxLength} characters long`;case"min":return`${r} must be at least ${n.validation.min}`;case"max":return`${r} must be no more than ${n.validation.max}`;case"lowerLimit":const t=n.validation;return`You are under the limit. ${r} must be at least ${null==t?void 0:t.lowerLimit}`;case"upperLimit":const e=n.validation;return`You crossed the limit. ${r} must be no more than ${null==e?void 0:e.upperLimit}`;case"pattern":return`${r} format is invalid`;case"email":return`${r} must be a valid email address`;default:return`${r} is invalid`}},l=(()=>{var l;if("test"!==a)return"";if(!(s||A[e]||r))return"";if(i&&i.isValid)return"";if(i&&!i.isValid&&Object.keys(i.errors).length>0){const t=Object.keys(i.errors).filter(t=>!0===i.errors[t]);if(t.length>0){const e=t[0],A=n.name||"";return"pattern"===e&&"number-input"===A?"":o(e)}}const c=t[e];if(c&&"string"==typeof c&&""!==c.trim()){const t=n.name||"";if("number-input"===t&&i){const t=n.validation,e=t&&"lowerLimit"in t&&void 0!==t.lowerLimit&&null!==t.lowerLimit&&0!==t.lowerLimit,A=t&&"upperLimit"in t&&void 0!==t.upperLimit&&null!==t.upperLimit&&0!==t.upperLimit;return!c.includes("limit")&&!c.includes("Limit")||e||A?(i.isValid,""):""}if(("date-picker"===t||"datetime-picker"===t)&&c.includes("valid date")){const e=(null===(l=n.basic)||void 0===l?void 0:l.dateTimeMode)||("datetime-picker"===t?"datetime":"date");if("time"===e)return"Please select a valid time";if("datetime"===e)return"Please select a valid date and time"}return c}return""})();return l?X.jsx("div",{className:"form-error-msg",children:l}):null};function tt(t,e,A,r){return new(A||(A=Promise))(function(n,i){function s(t){try{o(r.next(t))}catch(t){i(t)}}function a(t){try{o(r.throw(t))}catch(t){i(t)}}function o(t){var e;t.done?n(t.value):(e=t.value,e instanceof A?e:new A(function(t){t(e)})).then(s,a)}o((r=r.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const et=t=>{if(null==t||""===t)return null;if(t instanceof Date)return isNaN(t.getTime())?null:t;if("number"==typeof t){const e=new Date(t);return isNaN(e.getTime())?null:e}if("string"==typeof t){let e=t.trim();e.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}/)&&(e=e.replace(" ","T"));const A=new Date(e);return isNaN(A.getTime())?null:A}return null};var At;!function(t){t.OPEN="Open",t.IN_PROGRESS="In-Progress",t.REJECTED="Rejected",t.RESOLVE="Resolve"}(At||(At={}));const rt=({isOpen:r,onClose:n,onSuccess:i,component:d,formTemplateId:f,notes:p="",attachments:g=null,issue:m=null,onCreateIssue:v,onUpdateIssue:w,user:B,availableUsers:b=["Priya Das","Maria Garcia","John Smith","Sarah Johnson"],workOrderNumber:y,assetNumber:C,isStandalone:x,isEdit:F})=>{var Q,U,E,N,S,L;const[I,O]=e(""),[k,T]=e(""),[j,H]=e(""),[P,D]=e(""),[M,R]=e("Medium"),[K,V]=e(At.OPEN),[z,G]=e(""),[q,W]=e(""),[Y,J]=e(!1),[Z,rt]=e(g||[]),[nt,it]=e(!1),st=t.useRef(null),at=void 0!==F?F:!!m;A(()=>{(null==m?void 0:m.attachments)&&m.attachments.length>0?rt(m.attachments):g&&rt(g)},[g,m]);const ot=t=>{if(!t)return"Attachment";if(t instanceof File)return t.name;if("string"==typeof t){if(t.startsWith("data:"))return"Attachment";const e=t.split("/");return e[e.length-1]||"Attachment"}return t.fileName||t.filename||t.name||"Attachment"},lt=t=>{if(!t)return null;const e=t=>/\.(jpg|jpeg|png|gif|webp)$/i.test(t),A=t=>t.startsWith("data:image");return t instanceof File?t.type.startsWith("image/")?URL.createObjectURL(t):null:"string"==typeof t?A(t)||e(t)?t:null:t.data&&A(t.data)||t.fileName&&e(t.fileName)&&t.data?t.data:null};A(()=>{var t;if(r)if(m||at){O((null==m?void 0:m.title)||""),T((null==m?void 0:m.description)||""),H((null==m?void 0:m.workOrderNumber)||y||""),D((null==m?void 0:m.assetNumber)||C||""),R((null==m?void 0:m.priority)||"Medium");const t=(null==m?void 0:m.status)||At.OPEN,e=t===At.OPEN||t===At.IN_PROGRESS||t===At.REJECTED||t===At.RESOLVE?t:At.OPEN;V(e),G((null==m?void 0:m.assignTo)||(null==m?void 0:m.assignee)||""),W((null==m?void 0:m.comments)||"")}else d&&(null===(t=d.basic)||void 0===t||t.label,O(""),T(""),W(p||""),y&&H(y),C&&D(C))},[r,d,p,m,y,C]);const ct=t.useMemo(()=>{if(!I.trim())return!1;if(!k.trim())return!1;if(!K)return!1;if(!z)return!1;if(!x){if(!j.trim())return!1;if(!P.trim())return!1}return!0},[I,k,K,z,x,j,P]),ut=t=>tt(void 0,void 0,void 0,function*(){var e;if(m){J(!0);try{const e={title:String(I||"").trim(),description:String(k||"").trim(),workOrderNumber:String(j||"").trim()||void 0,assetNumber:String(P||"").trim()||void 0,formTemplateId:m.formTemplateId||"",component:m.component||{},priority:M,assignee:String(z||"").trim()||void 0,status:t,comments:String(q||"").trim()||""};w&&m._id&&(yield w(m._id,e)),V(t);const A={[At.IN_PROGRESS]:"Issue accepted and moved to In-Progress",[At.RESOLVE]:"Issue resolved successfully",[At.REJECTED]:"Issue rejected"};$.showSuccess(A[t]||"Issue status updated successfully"),i&&i(),n()}catch(t){const A=(null==t?void 0:t.message)||(null===(e=null==t?void 0:t.error)||void 0===e?void 0:e.message)||"Failed to update issue status. Please try again.";$.showError(A)}finally{J(!1)}}});if(!r)return null;const ht=X.jsx("div",{className:"raise-issue-modal-overlay",onClick:n,children:X.jsxs("div",{className:"raise-issue-modal",onClick:t=>t.stopPropagation(),children:[X.jsxs("div",{className:"raise-issue-modal-header",children:[X.jsxs("div",{className:"raise-issue-modal-header-left",children:[X.jsx(s,{className:"raise-issue-modal-icon",size:20}),X.jsx("div",{className:"raise-issue-modal-header-text",children:X.jsx("div",{className:"raise-issue-modal-title-main",children:at?"Edit Issue":"Create Issue"})})]}),X.jsx("button",{className:"raise-issue-modal-close",onClick:n,"aria-label":"Close",children:X.jsx(a,{size:18})})]}),X.jsx("div",{className:"raise-issue-modal-content",children:X.jsxs("div",{className:"raise-issue-fields-grid",children:[at&&(null==m?void 0:m.issueNumber)&&X.jsxs("div",{className:"raise-issue-field",children:[X.jsx("label",{className:"raise-issue-field-label",children:"Issue ID"}),X.jsx("input",{type:"text",className:"raise-issue-field-input raise-issue-field-readonly",value:m.issueNumber,readOnly:!0})]}),X.jsxs("div",{className:"raise-issue-field",children:[X.jsx("label",{className:"raise-issue-field-label",children:"Task"}),X.jsx("input",{type:"text",className:"raise-issue-field-input raise-issue-field-readonly",value:at?(null===(U=null===(Q=null==m?void 0:m.component)||void 0===Q?void 0:Q.basic)||void 0===U?void 0:U.label)||"":(null===(E=null==d?void 0:d.basic)||void 0===E?void 0:E.label)||"",readOnly:!0})]}),X.jsxs("div",{className:"raise-issue-field",children:[X.jsx("label",{className:"raise-issue-field-label",children:"Task Value"}),X.jsx("input",{type:"text",className:"raise-issue-field-input raise-issue-field-readonly",value:at?(null===(S=null===(N=null==m?void 0:m.component)||void 0===N?void 0:N.basic)||void 0===S?void 0:S.value)||"":(null===(L=null==d?void 0:d.basic)||void 0===L?void 0:L.value)||"",readOnly:!0})]}),X.jsxs("div",{className:"raise-issue-field",children:[X.jsxs("label",{className:"raise-issue-field-label",children:["Title ",X.jsx("span",{className:"raise-issue-required",children:"*"})]}),X.jsx("input",{type:"text",className:"raise-issue-field-input "+(at?"raise-issue-field-readonly":""),value:I,onChange:t=>O(t.target.value),placeholder:"Enter issue title",readOnly:at})]}),!x&&X.jsxs("div",{className:"raise-issue-field",children:[X.jsxs("label",{className:"raise-issue-field-label",children:["Work Order ",X.jsx("span",{className:"raise-issue-required",children:"*"})]}),X.jsx("input",{type:"text",className:"raise-issue-field-input "+(at?"raise-issue-field-readonly":""),value:j,onChange:t=>H(t.target.value),placeholder:"N/A",readOnly:at})]}),!x&&X.jsxs("div",{className:"raise-issue-field",children:[X.jsxs("label",{className:"raise-issue-field-label",children:["Asset Number ",X.jsx("span",{className:"raise-issue-required",children:"*"})]}),X.jsx("input",{type:"text",className:"raise-issue-field-input "+(at?"raise-issue-field-readonly":""),value:P,onChange:t=>D(t.target.value),placeholder:"Enter asset number",readOnly:at})]}),X.jsxs("div",{className:"raise-issue-field",children:[X.jsxs("label",{className:"raise-issue-field-label",children:["Raised By ",X.jsx("span",{className:"raise-issue-required",children:"*"})]}),X.jsxs("div",{className:"raise-issue-field-value-with-icon",children:[X.jsx(o,{size:16}),X.jsx("span",{children:B&&`${B.firstName||""} ${B.lastName||""}`.trim()||"User"})]})]}),X.jsxs("div",{className:"raise-issue-field",children:[X.jsx("label",{className:"raise-issue-field-label",children:"Created On"}),X.jsxs("div",{className:"raise-issue-field-value-with-icon",children:[X.jsx(l,{size:16}),X.jsx("span",{children:at&&(null==m?void 0:m.createdAt)?(et(m.createdAt)||new Date).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!0}):(new Date).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!0})})]})]}),X.jsxs("div",{className:"raise-issue-field raise-issue-field-full-width",children:[X.jsxs("label",{className:"raise-issue-field-label",children:["Description ",X.jsx("span",{className:"raise-issue-required",children:"*"})]}),X.jsx("textarea",{className:"raise-issue-field-textarea "+(at?"raise-issue-field-readonly":""),value:k,onChange:t=>T(t.target.value),placeholder:"Enter issue description",rows:4,readOnly:at})]}),X.jsxs("div",{className:"raise-issue-field",children:[X.jsxs("label",{className:"raise-issue-field-label",children:["Status ",X.jsx("span",{className:"raise-issue-required",children:"*"})]}),X.jsxs("select",{className:"raise-issue-field-select "+(at?"":"raise-issue-field-readonly"),value:K,onChange:t=>V(t.target.value),disabled:!at,children:[X.jsx("option",{value:At.OPEN,children:At.OPEN}),X.jsx("option",{value:At.IN_PROGRESS,children:At.IN_PROGRESS}),X.jsx("option",{value:At.REJECTED,children:At.REJECTED}),X.jsx("option",{value:At.RESOLVE,children:At.RESOLVE})]})]}),X.jsxs("div",{className:"raise-issue-field",children:[X.jsxs("label",{className:"raise-issue-field-label",children:["Assign to ",X.jsx("span",{className:"raise-issue-required",children:"*"})]}),X.jsxs("select",{className:"raise-issue-field-select",value:z,onChange:t=>G(t.target.value),children:[X.jsx("option",{value:"",children:"Unassigned"}),b.map(t=>X.jsx("option",{value:t,children:t},t))]})]}),X.jsxs("div",{className:"raise-issue-field raise-issue-field-full-width",children:[X.jsxs("label",{className:"raise-issue-field-label",children:["Priority ",X.jsx("span",{className:"raise-issue-required",children:"*"})]}),X.jsxs("div",{className:"raise-issue-priority-buttons",children:[X.jsx("button",{type:"button",className:"priority-button priority-low "+("Low"===M?"active":""),onClick:()=>R("Low"),children:"Low"}),X.jsx("button",{type:"button",className:"priority-button priority-medium "+("Medium"===M?"active":""),onClick:()=>R("Medium"),children:"Medium"}),X.jsx("button",{type:"button",className:"priority-button priority-high "+("High"===M?"active":""),onClick:()=>R("High"),children:"High"})]})]}),X.jsxs("div",{className:"raise-issue-field raise-issue-field-full-width",children:[X.jsxs("label",{className:"raise-issue-field-label-with-icon",children:[X.jsx(c,{size:16}),X.jsx("span",{children:"Comments"})]}),!q&&X.jsx("div",{className:"raise-issue-no-comments",children:"No comments yet"}),X.jsx("textarea",{className:"raise-issue-field-textarea raise-issue-comments-textarea "+(at?"raise-issue-field-readonly":""),value:q,onChange:t=>W(t.target.value),placeholder:"Add a comment...",rows:4,readOnly:at})]}),X.jsxs("div",{className:"raise-issue-field raise-issue-field-full-width",style:{marginTop:"1rem"},children:[X.jsx("label",{className:"raise-issue-field-label",children:"Attachments"}),X.jsxs("div",{className:"raise-issue-attachments-container",children:[!at&&X.jsxs("div",{className:"raise-issue-dropzone "+(nt?"dragging":""),onDragOver:t=>{t.preventDefault(),it(!0)},onDragLeave:t=>{t.preventDefault(),it(!1)},onDrop:t=>{if(t.preventDefault(),it(!1),t.dataTransfer.files&&t.dataTransfer.files.length>0){const e=Array.from(t.dataTransfer.files);rt(t=>[...t,...e])}},onClick:()=>{var t;return null===(t=st.current)||void 0===t?void 0:t.click()},children:[X.jsx("input",{type:"file",ref:st,style:{display:"none"},onChange:t=>{if(t.target.files&&t.target.files.length>0){const e=Array.from(t.target.files);rt(t=>[...t,...e]),st.current&&(st.current.value="")}},multiple:!0}),X.jsx("div",{className:"raise-issue-dropzone-icon",children:X.jsx(u,{size:24})}),X.jsx("div",{className:"raise-issue-dropzone-text",children:"Click to upload or drag and drop"}),X.jsx("div",{className:"raise-issue-dropzone-hint",children:"PNG, JPG up to 10MB"})]}),Z.length>0&&X.jsx("div",{className:"raise-issue-attachments-list",children:Z.map((t,e)=>X.jsxs("div",{className:"raise-issue-attachment-item",children:[X.jsx("div",{className:"raise-issue-attachment-thumbnail",children:lt(t)?X.jsx("img",{src:lt(t),alt:"Thumbnail"}):X.jsx(h,{size:20,color:"#9ca3af"})}),X.jsxs("div",{className:"raise-issue-attachment-info",children:[X.jsx("span",{className:"attachment-name",title:ot(t),children:ot(t)}),t instanceof File&&X.jsxs("span",{className:"attachment-size",children:[(t.size/1024).toFixed(1)," KB"]})]}),!at&&X.jsx("button",{type:"button",className:"attachment-remove-btn",onClick:()=>(t=>{rt(e=>e.filter((e,A)=>A!==t))})(e),title:"Remove",children:X.jsx(a,{size:12})})]},e))})]})]})]})}),X.jsx("div",{className:"raise-issue-modal-actions",children:X.jsxs("div",{className:"raise-issue-modal-actions-buttons",children:[at&&m&&X.jsxs(X.Fragment,{children:[K===At.OPEN&&X.jsx("button",{className:"raise-issue-modal-button raise-issue-modal-button-accept",onClick:()=>tt(void 0,void 0,void 0,function*(){yield ut(At.IN_PROGRESS)}),disabled:Y,children:Y?"Processing...":"Accept"}),K===At.IN_PROGRESS&&X.jsx("button",{className:"raise-issue-modal-button raise-issue-modal-button-resolve",onClick:()=>tt(void 0,void 0,void 0,function*(){yield ut(At.RESOLVE)}),disabled:Y,children:Y?"Processing...":"Resolve"}),(K===At.OPEN||K===At.IN_PROGRESS)&&X.jsx("button",{className:"raise-issue-modal-button raise-issue-modal-button-reject",onClick:()=>tt(void 0,void 0,void 0,function*(){yield ut(At.REJECTED)}),disabled:Y,children:Y?"Processing...":"Reject"})]}),!at&&X.jsx("button",{className:"raise-issue-modal-button raise-issue-modal-button-save "+(ct?"":"disabled"),onClick:()=>tt(void 0,void 0,void 0,function*(){var t,e,A,r,s,a,o;if(String(I||"").trim())if(String(k||"").trim())if(x||String(j||"").trim())if(x||String(P||"").trim())if(String(z||"").trim()){J(!0);try{if(at&&m){const s={title:String(I||"").trim(),description:String(k||"").trim(),workOrderNumber:String(j||"").trim()||void 0,assetNumber:String(P||"").trim()||void 0,formTemplateId:m.formTemplateId||"",component:m.component||{},priority:M,assignTo:String(z||"").trim()||void 0,status:K,comments:String(q||"").trim()||"",task:(null===(e=null===(t=m.component)||void 0===t?void 0:t.basic)||void 0===e?void 0:e.label)||"",taskValue:(null===(r=null===(A=m.component)||void 0===A?void 0:A.basic)||void 0===r?void 0:r.value)||""};w&&m._id&&(yield w(m._id,s)),$.showSuccess("Issue updated successfully"),i&&i(),n()}else{if(!d)return $.showError("Component is required"),void J(!1);if(!f||""===String(f||"").trim())return $.showError("Form template is required"),void J(!1);const t=Object.assign(Object.assign({},d),{basic:Object.assign(Object.assign({},d.basic),{comments:String(p||"")})}),e=B?`${B.firstName||""} ${B.lastName||""}`.trim():"User",A={title:String(I||"").trim(),workOrderNumber:String(j||"").trim()||void 0,assetNumber:String(P||"").trim()||void 0,component:t,description:String(k||"").trim(),formTemplateId:f,assignTo:String(z||"").trim()||void 0,priority:M,status:K,comments:String(q||"").trim()||"",createdBy:e,task:(null===(s=null==d?void 0:d.basic)||void 0===s?void 0:s.label)||"",taskValue:(null===(a=null==d?void 0:d.basic)||void 0===a?void 0:a.value)||""};let r;if(v&&(r=yield v(A,Z)),$.showSuccess("Issue raised successfully"),i){const t=Object.assign({_id:(null==r?void 0:r._id)||"temp-id",issueNumber:(null==r?void 0:r.issueNumber)||"",title:A.title,description:A.description,status:A.status,priority:A.priority,createdAt:(null==r?void 0:r.createdAt)||(new Date).toISOString(),updatedAt:(null==r?void 0:r.updatedAt)||(new Date).toISOString(),component:A.component,workOrderNumber:A.workOrderNumber,assetNumber:A.assetNumber,assignee:A.assignTo,comments:A.comments,attachments:(null==r?void 0:r.attachments)||Z},r);i(t)}n()}}catch(t){const e=(null==t?void 0:t.message)||(null===(o=null==t?void 0:t.error)||void 0===o?void 0:o.message)||(at?"Failed to update issue. Please try again.":"Failed to raise issue. Please try again.");$.showError(e)}finally{J(!1)}}else $.showError("Assignee is required");else $.showError("Asset Number is required");else $.showError("Work Order is required");else $.showError("Description is required");else $.showError("Title is required")}),disabled:Y||!ct,children:Y?"Creating...":"Create Issue"})]})})]})});return _(ht,document.body)},nt=({component:t,condition:n,currentValue:i,thresholdValue:a,formTemplateId:o,workOrderNumber:l,assetNumber:c,user:u,onIssueRaised:h,isIssueRaised:d=!1,compact:f=!1})=>{const[p,g]=e(!1),[m,v]=e(null),[w,B]=e(!1),[b,y]=e(!1);A(()=>{d&&y(!0)},[d]),A(()=>{y(!1)},[null==n?void 0:n.id]);const C=t=>({greaterThan:">",lessThan:"<",greaterThanOrEqual:"≥",lessThanOrEqual:"≤",equals:"=",notEquals:"≠"}[t]||t),x=r(()=>tt(void 0,void 0,void 0,function*(){if(d||b){if(m)return void g(!0);B(!0);try{v(null),g(!0)}catch(t){console.error("Error fetching issue:",t),$.showError("Failed to load issue details")}finally{B(!1)}}else v(null),g(!0)}),[d,b,o,t,m]),F=r(()=>{g(!1),d||b||v(null)},[d,b]),Q=r(t=>{g(!1),v(t||null),y(!0),h&&(null==n?void 0:n.id)&&h(n.id)},[h,n]);return d||b?X.jsx(X.Fragment,{children:p&&X.jsx(rt,{isOpen:p,onClose:F,onSuccess:Q,component:t,formTemplateId:o,workOrderNumber:l,assetNumber:c,user:u,notes:"",attachments:null,issue:m})}):f?X.jsxs(X.Fragment,{children:[X.jsxs("div",{className:"threshold-alert threshold-alert-unresolved threshold-alert-compact",children:[X.jsx("div",{className:"threshold-alert-border"}),X.jsxs("div",{className:"threshold-alert-content-compact",children:[X.jsx(s,{className:"threshold-alert-icon-compact",size:14}),X.jsx("span",{className:"threshold-alert-message-compact",children:`Threshold ${C(n.operator)} ${a}`}),X.jsx("button",{type:"button",onClick:x,className:"threshold-alert-raise-issue-btn-compact",title:"Raise Issue",children:"Raise Issue"})]})]}),p&&X.jsx(rt,{isOpen:p,onClose:F,onSuccess:Q,component:t,formTemplateId:o,workOrderNumber:l,assetNumber:c,user:u,notes:"",attachments:null,issue:m})]}):X.jsxs(X.Fragment,{children:[X.jsxs("div",{className:"threshold-alert threshold-alert-unresolved",children:[X.jsx("div",{className:"threshold-alert-border"}),X.jsxs("div",{className:"threshold-alert-content",children:[X.jsx("div",{className:"threshold-alert-header",children:X.jsxs("div",{className:"threshold-alert-title-group",children:[X.jsx(s,{className:"threshold-alert-icon",size:20}),X.jsx("span",{className:"threshold-alert-title",children:"Threshold Condition Met - Action Required"})]})}),X.jsxs("div",{className:"threshold-alert-message",children:[(()=>{var e;const A=C(n.operator);return`${(null===(e=t.basic)||void 0===e?void 0:e.label)||"Value"}: Value ${i} exceeds threshold ${A} ${a}`})(),X.jsx("span",{className:"threshold-alert-warning",children:" You must raise an issue before submitting the form."})]}),X.jsx("div",{className:"threshold-alert-buttons",children:X.jsx("button",{type:"button",onClick:x,className:"threshold-alert-raise-issue-btn",children:"Raise Issue Now"})})]})]}),p&&X.jsx(rt,{isOpen:p,onClose:F,onSuccess:Q,component:t,formTemplateId:o,workOrderNumber:l,assetNumber:c,user:u,notes:"",attachments:null,issue:m})]})},it=({id:t,properties:s,validationErrors:a={},formValue:o="",inputType:l="text",readonly:c=!1,disabled:u=!1,touchedFields:h={},formSubmitted:d=!1,mode:f="test",onValueChange:p,onBlur:g,onFocus:m,className:v="",hideLabel:w=!1,formTemplateId:B,onThresholdIssueRaised:b,raisedThresholdIssues:y=new Set,workOrderNumber:C,assetNumber:x,user:F})=>{var Q,U,E,N,S;const L=t=>null==t?"":"string"==typeof t?t:"number"==typeof t||"boolean"==typeof t?String(t):"object"==typeof t?Array.isArray(t)?"":"value"in t?L(t.value):"label"in t?L(t.label):"":String(t||""),I=n(t),_=n(null);A(()=>{t!==I.current&&(console.warn(`[DfFormInput] Component ID changed from ${I.current} to ${t}`),I.current=t)},[t]);const O=L(o||(null===(Q=null==s?void 0:s.basic)||void 0===Q?void 0:Q.defaultValue)||""),[k,T]=e(O),[j,H]=e(!1),[P,D]=e(!1),[M,R]=e(new Set),[K,V]=e(O),z=()=>{if(l)return l;const t=null==s?void 0:s.name;return"text-input"===t?"text":"number-input"===t?"number":"email-input"===t?"email":"text"},G=r(t=>{const e=(()=>{var t;const e={};if((null===(t=null==s?void 0:s.validation)||void 0===t?void 0:t.required)&&(e.required=!0),"email"===z()&&(e.email=!0),"text"===z()){const t=s.validation;(null==t?void 0:t.minLength)&&(e.minLength=t.minLength),(null==t?void 0:t.maxLength)&&(e.maxLength=t.maxLength)}if("number"===z()){const t=s.validation;t&&"lowerLimit"in t&&void 0!==t.lowerLimit&&null!==t.lowerLimit&&0!==t.lowerLimit&&(e.lowerLimit=t.lowerLimit),t&&"upperLimit"in t&&void 0!==t.upperLimit&&null!==t.upperLimit&&0!==t.upperLimit&&(e.upperLimit=t.upperLimit)}return e})(),A={};let r=!0;const n="string"==typeof t?t:null!=t?String(t):"";if(!e.required||n&&""!==n.trim()||(A.required=!0,r=!1),e.email&&n&&!/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(n)&&(A.email=!0,r=!1),e.minLength&&n&&n.length<e.minLength&&(A.minLength=!0,r=!1),e.maxLength&&n&&n.length>e.maxLength&&(A.maxLength=!0,r=!1),"number"===z())if(delete A.pattern,delete A.min,delete A.max,n&&""!==n.trim()){const t=n.trim(),i=parseFloat(t);isNaN(i)||("lowerLimit"in e&&void 0!==e.lowerLimit&&null!==e.lowerLimit&&0!==e.lowerLimit&&i<e.lowerLimit&&(A.lowerLimit=!0,r=!1),"upperLimit"in e&&void 0!==e.upperLimit&&null!==e.upperLimit&&0!==e.upperLimit&&i>e.upperLimit&&(A.upperLimit=!0,r=!1))}else delete A.lowerLimit,delete A.upperLimit;return{isValid:r,errors:A}},[s,z]),q=r(e=>{const A="string"==typeof e?e:null!=e?String(e):"";if(T(A),p){const e=G(A),r=I.current,n={id:r,value:A,isValid:e.isValid,errors:e.errors};r!==t&&console.error(`[DfFormInput] ID mismatch in handleValueChange! ref: ${r}, prop: ${t}`),p(n)}},[t,p,G,I]);A(()=>{j&&(h[t]=!0)},[j,t,h]),A(()=>{var t;if("edit"===f){H(!1);const e=(null===(t=null==s?void 0:s.basic)||void 0===t?void 0:t.defaultValue)||"";T(e)}else"test"===f&&(H(!1),T(""))},[f,null===(U=null==s?void 0:s.basic)||void 0===U?void 0:U.defaultValue]),A(()=>{var e;const A=I.current,r=L(o||(null===(e=null==s?void 0:s.basic)||void 0===e?void 0:e.defaultValue)||"");r===k||P||""===r&&""!==String(k||"").trim()?""===r&&String(k||"").trim():null!=o&&(A===t?T(r):console.error(`[DfFormInput] ID mismatch! componentIdRef: ${A}, prop id: ${t}`))},[o,k,P,null===(E=null==s?void 0:s.basic)||void 0===E?void 0:E.defaultValue,t]),A(()=>{d&&H(!0)},[d]),A(()=>{"test"!==f&&T("")},[f]);const W=r((t,e)=>{if(!e||""===e)return!1;const A="string"==typeof e?parseFloat(e):e,r="string"==typeof t.value?parseFloat(t.value):t.value;if(isNaN(A)||isNaN(r))return!1;switch(t.operator){case"greaterThan":return A>r;case"lessThan":return A<r;case"greaterThanOrEqual":return A>=r;case"lessThanOrEqual":return A<=r;case"equals":return A===r;case"notEquals":return A!==r;default:return!1}},[]),Y=i(()=>{var t;return(null===(t=null==s?void 0:s.condition)||void 0===t?void 0:t.conditions)||[]},[null==s?void 0:s.condition]);A(()=>{k!==K&&(R(new Set),V(k))},[k,K]);const J=i(()=>{if("test"!==f||!k||""===k)return null;const t=Y.filter(t=>W(t,k));if(0===t.length)return null;for(const e of t)if(!M.has(e.id))return e;return null},[k,Y,M,f,W,y]),$=r(t=>{R(e=>new Set(e).add(t))},[]),tt=z(),et=u||c||(null===(N=null==s?void 0:s.validation)||void 0===N?void 0:N.readonly);return X.jsxs(X.Fragment,{children:[X.jsxs("div",{className:`form-group ${(()=>{var t;return"left"===(null===(t=null==s?void 0:s.styles)||void 0===t?void 0:t.labelAlignment)?"label-left":"label-top"})()}`,children:[!w&&s.basic.label&&X.jsxs("label",{htmlFor:t,className:"form-label",children:[s.basic.label,s.validation.required&&X.jsx("span",{className:"required-indicator",children:"*"})]}),X.jsxs("div",{className:"input-wrapper",ref:_,children:[X.jsx("input",{type:tt,id:t,value:k,onChange:t=>{const e=t.target.value;q(e)},onFocus:()=>{D(!0),m&&m()},onBlur:()=>{if(D(!1),H(!0),"test"===f&&p){const e="string"==typeof k?k:null!=k?String(k):"",A=G(e),r={id:t,value:e,isValid:A.isValid,errors:A.errors};p(r)}g&&g()},placeholder:s.basic.placeholder,disabled:et,readOnly:c||(null===(S=null==s?void 0:s.validation)||void 0===S?void 0:S.readonly),className:(()=>{const e="form-control";if("test"===f){const A="string"==typeof k?k:null!=k?String(k):"",r=G(A);if(r.isValid)return`${e} ${v}`.trim();const n=!r.isValid&&j,i=a[t]&&(j||d)&&!r;return`${e} ${n||i?"is-invalid":""} ${v}`.trim()}return`${e} ${v}`.trim()})()}),X.jsx(Z,{validationErrors:a,fieldId:t,touchedFields:h,formSubmitted:d,properties:s,localValidation:G(k),isTouched:j,mode:f})]})]}),J&&"test"===f&&(()=>{var t,e,A,r;const n=(null==y?void 0:y.has(J.id))||!1,i=null!==(null===(t=_.current)||void 0===t?void 0:t.closest(".table-cell"))||null!==(null===(e=_.current)||void 0===e?void 0:e.closest(".cell-content"))||null!==(null===(A=_.current)||void 0===A?void 0:A.closest(".datagrid-table-view"))||null!==(null===(r=_.current)||void 0===r?void 0:r.closest(".datagrid-list-view"))||v.includes("table-cell")||v.includes("cell-content");return X.jsx(nt,{component:s,condition:J,currentValue:k,thresholdValue:J.value,formTemplateId:B,workOrderNumber:C,assetNumber:x,user:F,onDismiss:()=>$(J.id),onIssueRaised:b,isIssueRaised:n,compact:i},`${J.id}-${n}`)})()]})},st=({id:t,properties:n,validationErrors:i={},formValue:s="",readonly:a=!1,disabled:o=!1,touchedFields:l={},formSubmitted:c=!1,mode:u="preview",onValueChange:h,onBlur:d,onFocus:f,className:p="",hideLabel:g=!1})=>{var m,v,w;const[B,b]=e(s),[y,C]=e(!1),x=r(t=>{var e,A,r;const i={};let s=!0;return!(null===(e=null==n?void 0:n.validation)||void 0===e?void 0:e.required)||t&&""!==t.trim()||(i.required=!0,s=!1),(null===(A=null==n?void 0:n.validation)||void 0===A?void 0:A.minLength)&&t&&t.length<n.validation.minLength&&(i.minLength=!0,s=!1),(null===(r=null==n?void 0:n.validation)||void 0===r?void 0:r.maxLength)&&t&&t.length>n.validation.maxLength&&(i.maxLength=!0,s=!1),{isValid:s,errors:i}},[n]),F=r(e=>{if(b(e),h){const A=x(e),r={id:t,value:e,isValid:A.isValid,errors:A.errors};h(r)}},[t,h,x]);A(()=>{y&&(l[t]=!0)},[y,t,l]),A(()=>{""===B&&""!==s&&b(s)},[s]),A(()=>{c&&C(!0)},[c]),A(()=>{"test"!==u&&b("")},[u]);const Q=o||a||(null===(m=null==n?void 0:n.validation)||void 0===m?void 0:m.readonly),U=(null===(v=null==n?void 0:n.validation)||void 0===v?void 0:v.rows)||4;return X.jsxs("div",{className:`form-group ${(()=>{var t;return"left"===(null===(t=null==n?void 0:n.styles)||void 0===t?void 0:t.labelAlignment)?"label-left":"label-top"})()}`,children:[!g&&n.basic.label&&X.jsxs("label",{htmlFor:t,className:"form-label",children:[n.basic.label,n.validation.required&&X.jsx("span",{className:"required-indicator",children:"*"})]}),X.jsxs("div",{className:"input-wrapper",children:[X.jsx("textarea",{id:t,value:B,onChange:t=>{const e=t.target.value;F(e)},onFocus:()=>{f&&f()},onBlur:()=>{C(!0),d&&d()},placeholder:n.basic.placeholder,disabled:Q,readOnly:a||(null===(w=null==n?void 0:n.validation)||void 0===w?void 0:w.readonly),rows:U,className:`form-textarea ${!x(B).isValid&&y?"is-invalid":""} ${p}`.trim()}),X.jsx(Z,{validationErrors:i,fieldId:t,touchedFields:l,formSubmitted:c,properties:n,localValidation:x(B),isTouched:y,mode:u})]})]})},at=({id:t,properties:n,validationErrors:i={},formValue:s="",readonly:a=!1,disabled:o=!1,touchedFields:l={},formSubmitted:c=!1,mode:u="preview",onValueChange:h,onBlur:d,onFocus:f,className:p="",hideLabel:g=!1})=>{var m,v;const[w,B]=e(s),[b,y]=e(!1),C=(null===(m=null==n?void 0:n.validation)||void 0===m?void 0:m.multiple)||!1,x=r(t=>{var e;const A={};let r=!0;return(null===(e=null==n?void 0:n.validation)||void 0===e?void 0:e.required)&&(C?Array.isArray(t)&&0!==t.length||(A.required=!0,r=!1):(!t||"string"==typeof t&&""===t.trim())&&(A.required=!0,r=!1)),{isValid:r,errors:A}},[n,C]),F=r(e=>{if(B(e),h){const A=x(e),r={id:t,value:e,isValid:A.isValid,errors:A.errors};h(r)}},[t,h,x]);A(()=>{b&&(l[t]=!0)},[b,t,l]),A(()=>{JSON.stringify(s)!==JSON.stringify(w)&&B(s)},[s,w]),A(()=>{c&&y(!0)},[c]);const Q=o||a||(null===(v=null==n?void 0:n.validation)||void 0===v?void 0:v.readonly);return X.jsxs("div",{className:`form-group ${(()=>{var t;return"left"===(null===(t=null==n?void 0:n.styles)||void 0===t?void 0:t.labelAlignment)?"label-left":"label-top"})()}`,children:[!g&&n.basic.label&&X.jsxs("label",{htmlFor:t,className:"form-label",children:[n.basic.label,n.validation.required&&X.jsx("span",{className:"required-indicator",children:"*"})]}),X.jsxs("div",{className:"input-wrapper",children:[X.jsxs("select",{id:t,value:w,onChange:t=>{if(C){const e=Array.from(t.target.selectedOptions,t=>t.value);F(e)}else F(t.target.value)},onFocus:()=>{f&&f()},onBlur:()=>{y(!0),d&&d()},disabled:Q,multiple:C,className:`form-select ${!x(w).isValid&&b?"is-invalid":""} ${p}`.trim(),children:[!C&&X.jsx("option",{value:"",children:n.basic.placeholder||"Select an option"}),(n.options||[]).map((t,e)=>X.jsx("option",{value:t.value,disabled:t.disabled,children:t.label},e))]}),X.jsx(Z,{validationErrors:i,fieldId:t,touchedFields:l,formSubmitted:c,properties:n,localValidation:x(w),isTouched:b,mode:u})]})]})},ot=({id:t,properties:n,validationErrors:i={},formValue:s=[],readonly:a=!1,disabled:o=!1,touchedFields:l={},formSubmitted:c=!1,mode:u="preview",onValueChange:h,onBlur:d,onFocus:f,className:p="",hideLabel:g=!1})=>{var m,v,w;const[B,b]=e(!1),y=Array.isArray(s)?s:[],C=r(t=>{var e;const A={};let r=!0;return(null===(e=null==n?void 0:n.validation)||void 0===e?void 0:e.required)&&0===t.length&&(A.required=!0,r=!1),{isValid:r,errors:A}},[n]),x=r(e=>{if(h){const A=C(e),r={id:t,value:e,isValid:A.isValid,errors:A.errors};h(r)}},[t,h,C,y]),F=(t,e)=>{let A;A=e?[...y,t]:y.filter(e=>e!==t),x(A)},Q=()=>{f&&f()},U=()=>{b(!0),d&&d()};A(()=>{B&&(l[t]=!0)},[B,t,l]),A(()=>{},[s,t,y]),A(()=>{c&&b(!0)},[c]);const E=o||a||(null===(m=null==n?void 0:n.validation)||void 0===m?void 0:m.readonly);return X.jsx(X.Fragment,{children:X.jsx("div",{className:`form-group checkbox-group ${(()=>{var t;return"left"===(null===(t=null==n?void 0:n.styles)||void 0===t?void 0:t.labelAlignment)?"label-left":"label-top"})()} ${(()=>{var t;return(null===(t=null==n?void 0:n.basic)||void 0===t?void 0:t.inlineLayout)?"inline-layout":"vertical-layout"})()} ${p}`,children:!g&&n.basic.label?X.jsxs(X.Fragment,{children:[X.jsxs("label",{className:"form-label",children:[n.basic.label,n.validation.required&&X.jsx("span",{className:"required-indicator",children:"*"})]}),X.jsxs("div",{className:"input-wrapper",children:[X.jsx("div",{className:"mt-2 "+((null===(v=null==n?void 0:n.basic)||void 0===v?void 0:v.inlineLayout)?"inline-options-grid":"space-y-2"),children:(n.options||[]).map((e,A)=>X.jsxs("div",{className:"form-check",children:[X.jsx("input",{type:"checkbox",id:`${t}-${A}`,name:t,value:e.value,checked:y.includes(e.value),onChange:t=>{F(e.value,t.target.checked)},onFocus:Q,onBlur:U,disabled:E||e.disabled,className:"form-check-input"}),X.jsx("label",{htmlFor:`${t}-${A}`,className:"form-check-label",children:e.label})]},A))}),X.jsx(Z,{validationErrors:i,fieldId:t,touchedFields:l,formSubmitted:c,properties:n,localValidation:C(y),isTouched:B,mode:u})]})]}):X.jsxs("div",{className:"input-wrapper",children:[X.jsx("div",{className:"mt-2 "+((null===(w=null==n?void 0:n.basic)||void 0===w?void 0:w.inlineLayout)?"inline-options-grid":"space-y-2"),children:(n.options||[]).map((e,A)=>X.jsxs("div",{className:"form-check",children:[X.jsx("input",{type:"checkbox",id:`${t}-${A}`,name:t,value:e.value,checked:y.includes(e.value),onChange:t=>{F(e.value,t.target.checked)},onFocus:Q,onBlur:U,disabled:E||e.disabled,className:"form-check-input"}),X.jsx("label",{htmlFor:`${t}-${A}`,className:"form-check-label",children:e.label})]},A))}),X.jsx(Z,{validationErrors:i,fieldId:t,touchedFields:l,formSubmitted:c,properties:n,localValidation:C(y),isTouched:B,mode:u})]})})})},lt=({id:t,properties:n,validationErrors:i={},formValue:s="",readonly:a=!1,disabled:o=!1,touchedFields:l={},formSubmitted:c=!1,mode:u="preview",onValueChange:h,onBlur:d,onFocus:f,className:p="",hideLabel:g=!1})=>{var m,v,w;const[B,b]=e(s),[y,C]=e(!1),x=r(t=>{var e;const A={};let r=!0;return!(null===(e=null==n?void 0:n.validation)||void 0===e?void 0:e.required)||t&&""!==t.trim()||(A.required=!0,r=!1),{isValid:r,errors:A}},[n]),F=r(e=>{if(b(e),h){const A=x(e),r={id:t,value:e,isValid:A.isValid,errors:A.errors};h(r)}},[t,h,x]),Q=t=>{F(t)},U=()=>{f&&f()},E=()=>{C(!0),d&&d()};A(()=>{y&&(l[t]=!0)},[y,t,l]),A(()=>{s!==B&&b(s)},[s,B]),A(()=>{c&&C(!0)},[c]);const N=o||a||(null===(m=null==n?void 0:n.validation)||void 0===m?void 0:m.readonly);return X.jsx(X.Fragment,{children:X.jsx("div",{className:`form-group radio-group ${(()=>{var t;return"left"===(null===(t=null==n?void 0:n.styles)||void 0===t?void 0:t.labelAlignment)?"label-left":"label-top"})()} ${(()=>{var t;return(null===(t=null==n?void 0:n.basic)||void 0===t?void 0:t.inlineLayout)?"inline-layout":"vertical-layout"})()} ${p}`,children:!g&&n.basic.label?X.jsxs(X.Fragment,{children:[X.jsxs("label",{className:"form-label",children:[n.basic.label,n.validation.required&&X.jsx("span",{className:"required-indicator",children:"*"})]}),X.jsxs("div",{className:"input-wrapper",children:[X.jsx("div",{className:"mt-2 "+((null===(v=null==n?void 0:n.basic)||void 0===v?void 0:v.inlineLayout)?"inline-options-grid":"space-y-2"),children:(n.options||[]).map((e,A)=>X.jsxs("div",{className:"form-check",children:[X.jsx("input",{type:"radio",id:`${t}-${A}`,name:t,value:e.value,checked:B===e.value,onChange:()=>Q(e.value),onFocus:U,onBlur:E,disabled:N||e.disabled,className:"form-check-input"}),X.jsx("label",{htmlFor:`${t}-${A}`,className:"form-check-label",children:e.label})]},A))}),X.jsx(Z,{validationErrors:i,fieldId:t,touchedFields:l,formSubmitted:c,properties:n,localValidation:x(B),isTouched:y,mode:u})]})]}):X.jsxs("div",{className:"input-wrapper",children:[X.jsx("div",{className:"mt-2 "+((null===(w=null==n?void 0:n.basic)||void 0===w?void 0:w.inlineLayout)?"inline-options-grid":"space-y-2"),children:(n.options||[]).map((e,A)=>X.jsxs("div",{className:"form-check",children:[X.jsx("input",{type:"radio",id:`${t}-${A}`,name:t,value:e.value,checked:B===e.value,onChange:()=>Q(e.value),onFocus:U,onBlur:E,disabled:N||e.disabled,className:"form-check-input"}),X.jsx("label",{htmlFor:`${t}-${A}`,className:"form-check-label",children:e.label})]},A))}),X.jsx(Z,{validationErrors:i,fieldId:t,touchedFields:l,formSubmitted:c,properties:n,localValidation:x(B),isTouched:y,mode:u})]})})})},ct=({id:t,properties:n,validationErrors:i={},formValue:s="",readonly:a=!1,disabled:o=!1,touchedFields:l={},formSubmitted:c=!1,mode:u="preview",onValueChange:h,onBlur:d,onFocus:f,className:p="",hideLabel:g=!1})=>{var m;const[v,w]=e(s),[B,b]=e(!1),y=r(t=>{var e;const A={};let r=!0;return!(null===(e=null==n?void 0:n.validation)||void 0===e?void 0:e.required)||t&&""!==t.trim()||(A.required=!0,r=!1),{isValid:r,errors:A}},[n]),C=r(e=>{if(w(e),b(!0),h){const A=y(e),r={id:t,value:e,isValid:A.isValid,errors:A.errors};h(r)}},[t,h,y]),x=()=>{f&&f()},F=()=>{b(!0),d&&d()};A(()=>{B&&(l[t]=!0)},[B,t,l]),A(()=>{s!==v&&w(s)},[s,v]),A(()=>{c&&b(!0)},[c]);const Q=()=>{var t;return(null===(t=null==n?void 0:n.basic)||void 0===t?void 0:t.inlineLayout)?"inline-layout":"grid-layout"},U=t=>{const e=null==t?void 0:t.toLowerCase();return"pass"===e||"yes"===e?"pass":"fail"===e||"no"===e?"fail":"pass"},E=t=>{if(void 0!==(null==t?void 0:t.icon)&&""!==t.icon)return t.icon;return"pass"===U((null==t?void 0:t.value)||t)?"✓":"×"},N=(t,e)=>(null==t?void 0:t.color)||(null==t?void 0:t.backgroundColor)?{color:e?"#ffffff":t.color||"#00814b",backgroundColor:e?t.color||"#00814b":t.backgroundColor||"#34bd4914",borderColor:t.color||"#00814b"}:{},S=t=>{if((null==t?void 0:t.color)||(null==t?void 0:t.backgroundColor))return"segment-button-label segment-button-custom";return"segment-button-label "+("pass"===U((null==t?void 0:t.value)||t)?"pass-button":"fail-button")},L=o||a||(null===(m=null==n?void 0:n.validation)||void 0===m?void 0:m.readonly);return X.jsxs(X.Fragment,{children:[X.jsx("div",{className:`form-group segment-group ${(()=>{var t;return"left"===(null===(t=null==n?void 0:n.styles)||void 0===t?void 0:t.labelAlignment)?"label-left":"label-top"})()} ${p}`,children:!g&&n.basic.label?X.jsxs(X.Fragment,{children:[X.jsxs("label",{className:"form-label",children:[n.basic.label,n.validation.required&&X.jsx("span",{className:"required-indicator",children:"*"})]}),X.jsx("div",{className:"form-segment-wrapper",children:X.jsx("div",{className:`form-segment-container ${Q()}`,children:(n.options||[]).map((e,A)=>{const r=v===e.value,n=N(e,r),i=S(e),s=E(e);return X.jsxs("div",{className:"form-segment-option "+(r?"selected":""),children:[X.jsx("input",{type:"radio",id:`${t}_option_${A}`,name:t,value:e.value,checked:r,onChange:()=>!L&&!e.disabled&&C(e.value),onFocus:x,onBlur:F,disabled:L||e.disabled,className:"form-segment-radio"}),X.jsxs("label",{htmlFor:`${t}_option_${A}`,className:i,style:Object.keys(n).length>0?n:void 0,children:[s&&X.jsx("span",{className:"segment-icon",children:s}),X.jsx("span",{className:"segment-text",children:e.value})]})]},A)})})})]}):X.jsx("div",{className:"form-segment-wrapper",children:X.jsx("div",{className:`form-segment-container ${Q()}`,children:(n.options||[]).map((e,A)=>{const r=v===e.value,n=N(e,r),i=S(e),s=E(e);return X.jsxs("div",{className:"form-segment-option "+(r?"selected":""),children:[X.jsx("input",{type:"radio",id:`${t}_option_${A}`,name:t,value:e.value,checked:r,onChange:()=>!L&&!e.disabled&&C(e.value),onFocus:x,onBlur:F,disabled:L||e.disabled,className:"form-segment-radio"}),X.jsxs("label",{htmlFor:`${t}_option_${A}`,className:i,style:Object.keys(n).length>0?n:void 0,children:[s&&X.jsx("span",{className:"segment-icon",children:s}),X.jsx("span",{className:"segment-text",children:e.value})]})]},A)})})})}),X.jsx(Z,{validationErrors:i,fieldId:t,touchedFields:l,formSubmitted:c,properties:n,localValidation:y(v),isTouched:B,mode:u})]})},ut=({id:t,properties:n,validationErrors:i={},formValue:s="",readonly:a=!1,disabled:o=!1,touchedFields:l={},formSubmitted:c=!1,mode:u="preview",onValueChange:h,onBlur:d,onFocus:f,className:p="",hideLabel:g=!1})=>{var m,v,w,B,b;const y=r(t=>{var e,A;if(!t)return"";if("string"==typeof t){if(/^\d{4}-\d{2}-\d{2}$/.test(t))return t;if(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/.test(t))return t;const A=et(t);if(A&&!isNaN(A.getTime())){const t=n.name||"",r=(null===(e=n.basic)||void 0===e?void 0:e.dateTimeMode)||("datetime-picker"===t?"datetime":"date");if("datetime"===r){return`${A.getFullYear()}-${String(A.getMonth()+1).padStart(2,"0")}-${String(A.getDate()).padStart(2,"0")}T${String(A.getHours()).padStart(2,"0")}:${String(A.getMinutes()).padStart(2,"0")}`}if("time"===r){return`${String(A.getHours()).padStart(2,"0")}:${String(A.getMinutes()).padStart(2,"0")}`}return`${A.getFullYear()}-${String(A.getMonth()+1).padStart(2,"0")}-${String(A.getDate()).padStart(2,"0")}`}return t}if(t instanceof Date){if(isNaN(t.getTime()))return"";const e=n.name||"",r=(null===(A=n.basic)||void 0===A?void 0:A.dateTimeMode)||("datetime-picker"===e?"datetime":"date");if("datetime"===r){return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}T${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}if("time"===r){return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`}if("object"==typeof t&&null!==t){if("value"in t&&t.value)return y(t.value);if("date"in t&&t.date)return y(t.date);try{const e=String(t),A=et(e);if(A&&!isNaN(A.getTime()))return y(A)}catch(t){}return""}return""},[n]),C=y(s),[x,F]=e(C),[Q,U]=e(!1),[E,N]=e(!1),S=r(t=>{var e,A,r,i,s,a;const o={};let l=!0;const c=n.name||"",u=(null===(e=n.basic)||void 0===e?void 0:e.dateTimeMode)||("datetime-picker"===c?"datetime":"date"),h=t?String(t).trim():"";if((null===(A=null==n?void 0:n.validation)||void 0===A?void 0:A.required)&&(!h||""===h))return o.required=!0,l=!1,{isValid:l,errors:o};if(h&&""!==h)if("time"===u){if(!/^([0-1][0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?$/.test(h))return o.invalidDate=!0,l=!1,{isValid:l,errors:o}}else if("datetime"===u){const t=et(h);if(!t||isNaN(t.getTime()))return o.invalidDate=!0,l=!1,{isValid:l,errors:o};if(null===(r=null==n?void 0:n.validation)||void 0===r?void 0:r.minDate){const e=et(n.validation.minDate);e&&t<e&&(o.minDate=!0,o.minDateMessage=`Date and time must be on or after ${e.toLocaleDateString()}`,l=!1)}if(null===(i=null==n?void 0:n.validation)||void 0===i?void 0:i.maxDate){const e=et(n.validation.maxDate);e&&t>e&&(o.maxDate=!0,o.maxDateMessage=`Date and time must be on or before ${e.toLocaleDateString()}`,l=!1)}}else{const t=et(h);if(!t||isNaN(t.getTime()))return o.invalidDate=!0,l=!1,{isValid:l,errors:o};if(null===(s=null==n?void 0:n.validation)||void 0===s?void 0:s.minDate){const e=et(n.validation.minDate);e&&t<e&&(o.minDate=!0,o.minDateMessage=`Date must be on or after ${e.toLocaleDateString()}`,l=!1)}if(null===(a=null==n?void 0:n.validation)||void 0===a?void 0:a.maxDate){const e=et(n.validation.maxDate);e&&t>e&&(o.maxDate=!0,o.maxDateMessage=`Date must be on or before ${e.toLocaleDateString()}`,l=!1)}}return{isValid:l,errors:o}},[n]),L=r(e=>{if(F(e),h){const A=S(e),r={id:t,value:e,isValid:A.isValid,errors:A.errors};h(r)}},[t,h,S]);A(()=>{Q&&(l[t]=!0)},[Q,t,l]),A(()=>{const t=y(s);t===x||E||F(t)},[s,x,E,y]),A(()=>{c&&U(!0)},[c]);const I=o||a||(null===(m=null==n?void 0:n.validation)||void 0===m?void 0:m.readonly),_=n.name||"",O=(null===(v=n.basic)||void 0===v?void 0:v.dateTimeMode)||("datetime-picker"===_?"datetime":"date"),k=(()=>{switch(O){case"time":return"time";case"datetime":return"datetime-local";default:return"date"}})();return X.jsxs("div",{className:`form-group ${(()=>{var t;return"left"===(null===(t=null==n?void 0:n.styles)||void 0===t?void 0:t.labelAlignment)?"label-left":"label-top"})()}`,children:[!g&&n.basic.label&&X.jsxs("label",{htmlFor:t,className:"form-label",children:[n.basic.label,n.validation.required&&X.jsx("span",{className:"required-indicator",children:"*"})]}),X.jsxs("div",{className:"input-wrapper",children:[X.jsx("input",{type:k,id:t,value:x,onChange:t=>{const e=t.target.value;L(e)},onFocus:()=>{N(!0),f&&f()},onBlur:()=>{if(N(!1),U(!0),h){const e=S(x),A={id:t,value:x,isValid:e.isValid,errors:e.errors};h(A)}d&&d()},disabled:I,readOnly:a||(null===(w=null==n?void 0:n.validation)||void 0===w?void 0:w.readonly),min:null===(B=null==n?void 0:n.validation)||void 0===B?void 0:B.minDate,max:null===(b=null==n?void 0:n.validation)||void 0===b?void 0:b.maxDate,className:`form-date ${!S(x).isValid&&Q?"is-invalid":""} ${p}`.trim()}),X.jsx(Z,{validationErrors:i,fieldId:t,touchedFields:l,formSubmitted:c,properties:n,localValidation:S(x),isTouched:Q,mode:u})]})]})},ht=({id:t,properties:i,validationErrors:s={},formValue:a="",readonly:o=!1,disabled:l=!1,touchedFields:c={},formSubmitted:u=!1,mode:h="preview",onValueChange:d,onBlur:f,onFocus:p,className:g="",hideLabel:m=!1})=>{var v;const w=n(null),[B,b]=e(!1),[y,C]=e(!1),[x,F]=e(a),[Q,U]=e(!1),E=r(t=>{var e;const A={};let r=!0;return!(null===(e=null==i?void 0:i.validation)||void 0===e?void 0:e.required)||t&&""!==t.trim()||(A.required=!0,r=!1),{isValid:r,errors:A}},[i]),N=r(e=>{if(F(e),d){const A=E(e),r={id:t,value:e,isValid:A.isValid,errors:A.errors};d(r)}},[t,d,E]),S=r(()=>{const t=document.documentElement.classList.contains("dark")||"dark"===document.documentElement.getAttribute("data-theme");let e=getComputedStyle(document.documentElement).getPropertyValue("--df-color-fb-input-bg").trim();e||(e=t?"#2c2e34":"#ffffff");return{strokeColor:t?"#ffffff":"#000000",backgroundColor:e}},[]),L=r(e=>{if(!e)return;const A=w.current;if(!A)return;const r=A.getContext("2d");if(!r)return;const n=new Image;n.onload=()=>{r.clearRect(0,0,A.width,A.height);const t=S();r.fillStyle=t.backgroundColor,r.fillRect(0,0,A.width,A.height);const e=A.width/A.height,i=n.width/n.height;let s=A.width,a=A.height,o=0,l=0;i>e?(a=A.width/i,l=(A.height-a)/2):(s=A.height*i,o=(A.width-s)/2),r.drawImage(n,o,l,s,a)},n.onerror=A=>{console.error("DfFormSignature: error loading image",{id:t,error:A,dataURL:e.substring(0,50)+"..."})},n.src=e},[S,t]),I=r(()=>{const t=w.current;if(!t)return;const e=t.getContext("2d");if(!e)return;const A=t.getBoundingClientRect();t.width=A.width,t.height=A.height,t.style.width=A.width+"px",t.style.height=A.height+"px";const r=S();e.strokeStyle=r.strokeColor,e.lineWidth=2,e.lineCap="round",e.lineJoin="round",x?L(x):(e.fillStyle=r.backgroundColor,e.fillRect(0,0,t.width,t.height))},[x,S,L]),_=r(()=>{setTimeout(()=>{I()},100)},[I]);A(()=>{const t=()=>{_()},e=new MutationObserver(t=>{t.forEach(t=>{if("attributes"===t.type&&"class"===t.attributeName){const e=t.target;e.classList.contains("form-canvas-container")&&(e.classList.contains("mobile-view")||e.classList.contains("tablet-view")||e.classList.contains("desktop-view"))&&_()}})});return e.observe(document.body,{attributes:!0,attributeFilter:["class"],subtree:!0}),window.addEventListener("resize",t),()=>{e.disconnect(),window.removeEventListener("resize",t)}},[_]);const O=r(t=>{const e=w.current;if(!e)return{x:0,y:0};const A=e.getBoundingClientRect(),r=e.width/A.width,n=e.height/A.height,i=t.type.includes("mouse")?t.clientX:t.touches[0].clientX,s=t.type.includes("mouse")?t.clientY:t.touches[0].clientY;return{x:(i-A.left)*r,y:(s-A.top)*n}},[]),k=t=>{var e;if(o||l||(null===(e=null==i?void 0:i.validation)||void 0===e?void 0:e.readonly))return;if(t.target.closest(".clear-signature-btn"))return;t.preventDefault(),t.stopPropagation(),b(!0),C(!0);const A=w.current;if(!A)return;const r=A.getContext("2d");if(!r)return;const{x:n,y:s}=O(t),a=S();r.strokeStyle=a.strokeColor,r.lineWidth=2,r.lineCap="round",r.lineJoin="round",r.beginPath(),r.moveTo(n,s)},T=t=>{if(!B)return;t.preventDefault(),t.stopPropagation();const e=w.current;if(!e)return;const A=e.getContext("2d");if(!A)return;const{x:r,y:n}=O(t);A.lineTo(r,n),A.stroke()},j=()=>{if(!B)return;b(!1),U(!0);const t=w.current;if(t){(t=>{const e=t.getContext("2d");if(!e)return!1;const A=e.getImageData(0,0,t.width,t.height).data;for(let t=0;t<A.length;t+=4){const e=A[t],r=A[t+1],n=A[t+2];if(A[t+3]>0&&(e<255||r<255||n<255))return!0}})(t);const e=t.toDataURL("image/png");F(e),N(e),setTimeout(()=>{U(!1)},100)}else U(!1)},H=r(()=>{const t=w.current;if(!t)return;const e=t.getContext("2d");if(!e)return;const A=S();if(e.strokeStyle=A.strokeColor,x){const r=x,n=t.getBoundingClientRect();e.fillStyle=A.backgroundColor,e.fillRect(0,0,n.width,n.height),r&&L(r)}else{const r=t.getBoundingClientRect();e.fillStyle=A.backgroundColor,e.fillRect(0,0,r.width,r.height)}},[S,x,L]);A(()=>{const t=new MutationObserver(t=>{t.forEach(t=>{"attributes"!==t.type||"class"!==t.attributeName&&"data-theme"!==t.attributeName||H()})});return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-theme"]}),()=>{t.disconnect()}},[H]);A(()=>{y&&(c[t]=!0)},[y,t,c]),A(()=>{if(!(a===x||B||Q||""!==x&&""===a)){if(a===x)return;F(a),a&&L(a)}},[a,x,B,Q]),A(()=>{u&&C(!0)},[u]),A(()=>{if("test"!==h){F("");const t=w.current;if(t){const e=t.getContext("2d");if(e){const A=t.getBoundingClientRect();t.width=A.width,t.height=A.height;const r=S();e.fillStyle=r.backgroundColor,e.fillRect(0,0,A.width,A.height)}}}},[h]),A(()=>{I()},[h]);const P=l||o||(null===(v=null==i?void 0:i.validation)||void 0===v?void 0:v.readonly);return X.jsxs("div",{className:`form-group ${(()=>{var t;return"left"===(null===(t=null==i?void 0:i.styles)||void 0===t?void 0:t.labelAlignment)?"label-left":"label-top"})()}`,children:[!m&&i.basic.label&&X.jsxs("label",{htmlFor:t,className:"form-label",children:[i.basic.label,i.validation.required&&X.jsx("span",{className:"required-indicator",children:"*"})]}),X.jsxs("div",{className:"input-wrapper",children:[X.jsxs("div",{className:"signature-container",style:{position:"relative",width:"100%",maxWidth:"100%",overflow:"hidden"},children:[X.jsx("canvas",{ref:w,id:t,className:`form-signature ${!E(x).isValid&&y?"is-invalid":""} ${g}`.trim(),onMouseDown:k,onMouseMove:T,onMouseUp:j,onMouseLeave:j,onTouchStart:k,onTouchMove:T,onTouchEnd:j,onFocus:()=>{p&&p()},onBlur:()=>{f&&f()},style:{width:"100%",height:"150px",border:"2px solid var(--df-color-primary-border)",borderRadius:"6px",cursor:P?"not-allowed":"crosshair",backgroundColor:"var(--df-color-fb-input-bg)",touchAction:"none",userSelect:"none"}}),!P&&X.jsx("button",{type:"button",onClick:t=>(t=>{null==t||t.preventDefault(),null==t||t.stopPropagation();const e=w.current;if(!e)return;const A=e.getBoundingClientRect();e.width=A.width,e.height=A.height;const r=e.getContext("2d");if(!r)return;const n=S();r.fillStyle=n.backgroundColor,r.fillRect(0,0,A.width,A.height),r.strokeStyle=n.strokeColor,r.lineWidth=2,r.lineCap="round",r.lineJoin="round",F(""),N("")})(t),className:"clear-signature-btn",style:{position:"absolute",bottom:"8px",right:"8px",padding:"4px 8px",backgroundColor:"var(--df-color-error-primary)",color:"white",border:"none",borderRadius:"4px",cursor:"pointer",fontSize:"0.75rem",fontWeight:"500",zIndex:10,transition:"all 0.2s ease",minWidth:"60px",minHeight:"28px"},onMouseEnter:t=>{t.currentTarget.style.backgroundColor="var(--df-color-error-dark, #dc2626)",t.currentTarget.style.transform="scale(1.05)"},onMouseLeave:t=>{t.currentTarget.style.backgroundColor="var(--df-color-error-primary)",t.currentTarget.style.transform="scale(1)"},children:"Clear"})]}),X.jsx(Z,{validationErrors:s,fieldId:t,touchedFields:c,formSubmitted:u,properties:i,localValidation:E(x),isTouched:y,mode:h})]})]})},dt=({id:t,properties:i,validationErrors:s={},formValue:a=null,readonly:o=!1,disabled:l=!1,touchedFields:c={},formSubmitted:u=!1,mode:h="test",onValueChange:d,onBlur:f,onFocus:p,className:g="",hideLabel:m=!1})=>{var v,w,B,b,y,C,x,F;const[Q,U]=e([]),[E,N]=e(!1),[S,L]=e(!1),I=n(null),_=r(e=>{if(!e)return[];const A=Array.isArray(e)?e:Array.from(e),r=[];return A.forEach((e,A)=>{if(e&&"object"==typeof e&&!(e instanceof File)&&!(e instanceof Blob)){const n=e;if(n.data||n.url||n.name&&n.type){const e=n.name||n.fileName||`file-${A}`,i=n.size||n.fileSize||0,s=n.type||n.fileType||n.mimeType||"";let a;if(n.url)a=n.url;else if(n.data){const t=n.data;if("string"==typeof t)if(t.startsWith("data:"))a=t;else{const e=t.replace(/\s/g,"");if(/^[A-Za-z0-9+/=]+$/.test(e)&&e.length>10){let t=s;t||(t=e.startsWith("/9j/")||e.startsWith("iVBORw0KGgoAAAANSUhEUgAA")?"image/jpeg":e.startsWith("iVBORw0KGgo")?"image/png":e.startsWith("R0lGOD")?"image/gif":e.startsWith("UklGR")?"image/webp":"image/png"),a=`data:${t};base64,${e}`}else a=t}}const o=new File([],e,{type:s});return void r.push({file:o,id:`${t}-file-${A}`,size:i,type:s,name:e,preview:a})}}let n,i,s=0,a="",o="";if(e instanceof File||e instanceof Blob){const t=e;if(s=t.size||0,a=t.type||"",o=t.name||`file-${A}`,i=t,a.startsWith("image/"))try{n=URL.createObjectURL(t)}catch(t){console.error("Error creating object URL:",t),n=void 0}}else if("string"==typeof e){const t=e,r=t.replace(/\s/g,""),s=r.length>50&&/^[A-Za-z0-9+/=]+$/.test(r)&&!t.startsWith("http")&&!t.startsWith("https")&&!t.startsWith("data:")&&!t.startsWith("blob:")&&!t.startsWith("/");let l=t;if(s){let t="image/png";r.startsWith("/9j/")||r.startsWith("iVBORw0KGgoAAAANSUhEUgAA")?t="image/jpeg":r.startsWith("iVBORw0KGgo")?t="image/png":r.startsWith("R0lGOD")?t="image/gif":r.startsWith("UklGR")&&(t="image/webp"),l=`data:${t};base64,${r}`}let c="";if(l.startsWith("data:")){const t=l.match(/filename=([^;]+)/i);if(t)c=decodeURIComponent(t[1]);else{const t=l.match(/data:([^;]+)/);if(t){const e=t[1];c=`file-${A+1}.${e.includes("image")?e.includes("jpeg")?"jpg":"png":e.includes("pdf")?"pdf":e.includes("word")?"doc":e.includes("excel")?"xls":"file"}`}else c=`file-${A+1}`}}else if(l.startsWith("http://")||l.startsWith("https://")||l.startsWith("blob:"))try{const e=new URL(t),r=e.pathname.split("/").pop()||"";if(r&&r.includes("."))c=decodeURIComponent(r);else{const t=e.searchParams.get("filename")||e.searchParams.get("name");c=t?decodeURIComponent(t):`file-${A+1}`}}catch(e){const r=t.lastIndexOf("/"),n=r>=0?t.substring(r+1):t,i=n.indexOf("?"),s=i>=0?n.substring(0,i):n;c=s&&s.includes(".")?decodeURIComponent(s):`file-${A+1}`}else c=`file-${A+1}`;if(o=c||`file-${A+1}`,l.startsWith("data:")){const t=l.indexOf(";");a=t>5?l.substring(5,t):"application/octet-stream"}else{const t=l.match(/\.(jpg|jpeg|png|gif|webp|svg|pdf|doc|docx|xls|xlsx|zip|rar)$/i)||o.match(/\.(jpg|jpeg|png|gif|webp|svg|pdf|doc|docx|xls|xlsx|zip|rar)$/i);if(t){a={jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",pdf:"application/pdf",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",xls:"application/vnd.ms-excel",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",zip:"application/zip",rar:"application/x-rar-compressed"}[t[1].toLowerCase()]||"application/octet-stream"}else a=s?"image/png":"application/octet-stream"}(l.startsWith("data:image")||l.startsWith("http://")||l.startsWith("https://")||l.startsWith("blob:"))&&(n=l),i=new File([],o,{type:a})}else{if(!e||"object"!=typeof e)return;{const t=e;if(o=t.name||t.fileName||`file-${A}`,s=t.size||t.fileSize||0,a=t.type||t.fileType||t.mimeType||"",t.url||t.path)n=t.url||t.path;else if(a.startsWith("image/")&&t.data){const e=t.data;if("string"==typeof e)if(e.startsWith("data:"))n=e;else{const t=e.replace(/\s/g,"");n=/^[A-Za-z0-9+/=]+$/.test(t)&&t.length>50?`data:${a};base64,${t}`:e}else n=void 0}i=new File([],o,{type:a})}}r.push({file:i,id:`${t}-file-${A}`,size:s,type:a,name:o,preview:n})}),r},[t]),O=r(()=>({isValid:!0,errors:{}}),[]),k=r(e=>{var A;if(o||l)return;const r=_(e),n=Q.length>0?[...Q,...r]:r,s=(null===(A=null==i?void 0:i.validation)||void 0===A?void 0:A.maxFiles)||1/0,a=n.slice(0,s);if(U(a),L(!0),d){const e=O(),A={id:t,value:a.map(t=>t.file),isValid:e.isValid,errors:e.errors};d(A)}},[Q,i,o,l,d,O,_,t]),T=t=>{if(0===t)return"0 Bytes";const e=Math.floor(Math.log(t)/Math.log(1024));return parseFloat((t/Math.pow(1024,e)).toFixed(2))+" "+["Bytes","KB","MB","GB"][e]},j=t=>t.startsWith("image/")?"🖼️":t.startsWith("video/")?"🎥":t.startsWith("audio/")?"🎵":t.includes("pdf")?"📄":t.includes("word")||t.includes("document")?"📝":t.includes("excel")||t.includes("spreadsheet")?"📊":t.includes("zip")||t.includes("rar")?"📦":"📁";A(()=>{S&&(c[t]=!0)},[S,t,c]),A(()=>{("edit"===h||"test"===h)&&L(!1)},[h]),A(()=>{const t=_(a);null!=a&&(Array.isArray(a)&&a.length>0||"string"==typeof a&&""!==String(a).trim()||"object"==typeof a&&!Array.isArray(a)&&Object.keys(a).length>0)||0===Q.length&&null!=a?U(t):(null==a||Array.isArray(a)&&0===a.length)&&Q.length>0&&U([])},[a,_,Q.length]),A(()=>{u&&L(!0)},[u]),A(()=>()=>{Q.forEach(t=>{if(t.preview&&t.preview.startsWith("blob:"))try{URL.revokeObjectURL(t.preview)}catch(t){console.error("Error revoking object URL:",t)}})},[Q]);const H=()=>{var t;return"left"===(null===(t=null==i?void 0:i.styles)||void 0===t?void 0:t.labelAlignment)?"label-left":"label-top"},P=l||o||(null===(v=null==i?void 0:i.validation)||void 0===v?void 0:v.readonly),D=(null===(w=null==i?void 0:i.validation)||void 0===w?void 0:w.multiple)||!1,M=(null===(B=null==i?void 0:i.validation)||void 0===B?void 0:B.accept)||"*/*",R=(null===(b=null==i?void 0:i.validation)||void 0===b?void 0:b.maxFiles)||1/0,K=Q.length<R&&(D||R>1),V="edit"===h,z="preview"===h||"test"===h,G=Q.filter(t=>t.type.startsWith("image/")),q=Q.filter(t=>!t.type.startsWith("image/")),W=G.length>0;return z&&W?X.jsxs("div",{className:`form-group ${H()}`,children:[!m&&X.jsxs("label",{htmlFor:t,className:"form-label",children:[(null===(y=i.basic)||void 0===y?void 0:y.label)||"Attachments",(null===(C=i.validation)||void 0===C?void 0:C.required)&&X.jsx("span",{className:"required-indicator",children:"*"})]}),X.jsxs("div",{className:"file-upload-wrapper",children:[X.jsxs("div",{className:"file-image-display",children:[G.map(t=>X.jsxs("div",{className:"file-image-container",children:[t.preview&&X.jsx("img",{src:t.preview,alt:t.name,className:"file-image-preview"}),X.jsxs("div",{className:"file-image-info",children:[X.jsx("div",{className:"file-name",title:t.name,children:t.name}),X.jsx("div",{className:"file-size",children:T(t.size)})]})]},t.id)),q.length>0&&X.jsxs("div",{className:"file-other-files",children:[X.jsx("div",{className:"file-other-files-label",children:"Other Files:"}),q.map(t=>X.jsxs("div",{className:"file-item-minimal",children:[X.jsx("div",{className:"file-icon",children:j(t.type)}),X.jsxs("div",{className:"file-info",children:[X.jsx("div",{className:"file-name",title:t.name,children:t.name}),X.jsx("div",{className:"file-size",children:T(t.size)})]})]},t.id))]})]}),X.jsx(Z,{validationErrors:s,fieldId:t,touchedFields:c,formSubmitted:u,properties:i,localValidation:O(),isTouched:S,mode:h})]})]}):X.jsxs("div",{className:`form-group ${H()}`,children:[!m&&X.jsxs("label",{htmlFor:t,className:"form-label",children:[(null===(x=i.basic)||void 0===x?void 0:x.label)||"Attachments",(null===(F=i.validation)||void 0===F?void 0:F.required)&&X.jsx("span",{className:"required-indicator",children:"*"})]}),X.jsxs("div",{className:"file-upload-wrapper",children:[X.jsxs("div",{className:`file-upload-area ${E?"drag-over":""} ${o?"readonly":""} ${l?"disabled":""} ${g}`.trim(),onDragOver:t=>{t.preventDefault(),o||l||N(!0)},onDragLeave:t=>{t.preventDefault(),N(!1)},onDrop:t=>{if(t.preventDefault(),N(!1),o||l)return;const e=t.dataTransfer.files;e.length>0&&k(e)},onClick:t=>{var e;const A=t.target,r=null!==A.closest(".file-item"),n=null!==A.closest(".file-remove");!V||P||0!==Q.length||r||n||null===(e=I.current)||void 0===e||e.click()},onFocus:()=>{p&&p()},onBlur:()=>{if(L(!0),"test"===h&&d){const e=O(),A={id:t,value:Q.map(t=>t.file),isValid:e.isValid,errors:e.errors};d(A)}f&&f()},tabIndex:P?-1:0,children:[X.jsx("input",{ref:I,type:"file",id:t,multiple:D,accept:M,onChange:t=>{const e=t.target.files;e&&e.length>0&&(k(e),t.target.value="")},disabled:P,style:{display:"none"}}),0===Q.length?X.jsxs("div",{className:"upload-placeholder",onClick:t=>{var e;t.stopPropagation(),V&&!P&&(null===(e=I.current)||void 0===e||e.click())},children:[X.jsx("div",{className:"upload-icon",children:"📁"}),X.jsx("div",{className:"upload-text",children:i.basic.placeholder&&X.jsx("p",{className:"upload-hint",children:i.basic.placeholder})})]}):X.jsx("div",{className:"file-list",children:Q.map(e=>X.jsxs("div",{className:"file-item",children:[X.jsx("div",{className:"file-preview",children:e.preview?X.jsx("img",{src:e.preview,alt:e.name,className:"file-image"}):X.jsx("div",{className:"file-icon",children:j(e.type)})}),X.jsxs("div",{className:"file-info",children:[X.jsx("div",{className:"file-name",title:e.name,children:e.name}),X.jsx("div",{className:"file-size",children:T(e.size)})]}),V&&!P&&X.jsx("button",{type:"button",className:"file-remove",onClick:A=>{A.stopPropagation(),(e=>{if(o||l)return;const A=Q.filter(t=>t.id!==e);if(U(A),L(!0),d){const e=O(),r={id:t,value:A.map(t=>t.file),isValid:e.isValid,errors:e.errors};d(r)}})(e.id)},"aria-label":`Remove ${e.name}`,children:"✕"})]},e.id))})]}),Q.length>0&&K&&!P&&V&&X.jsxs("button",{type:"button",className:"file-add-more",onClick:t=>{t.stopPropagation(),!P&&I.current&&V&&(I.current.value="",I.current.click())},"aria-label":"Add more files",children:[X.jsx("svg",{className:"file-add-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:X.jsx("path",{d:"M12 5v14M5 12h14"})}),X.jsx("span",{className:"file-add-text",children:"Add More Files"})]}),X.jsx(Z,{validationErrors:s,fieldId:t,touchedFields:c,formSubmitted:u,properties:i,localValidation:O(),isTouched:S,mode:h})]})]})},ft=({id:t,properties:i,validationErrors:s={},formValue:o=null,readonly:l=!1,disabled:c=!1,touchedFields:u={},formSubmitted:h=!1,mode:g="test",onValueChange:m,onBlur:v,onFocus:w,className:B="",hideLabel:b=!1})=>{var y,C,x,F;const[Q,U]=e(o),[E,N]=e(!1),[S,L]=e(""),[I,_]=e(!1),[O,k]=e(!1),[T,j]=e({lat:40.7128,lng:-74.006}),[H,P]=e(null),[D,M]=e(10),[R,K]=e(""),[V,z]=e(!1),G=n(null),[q,W]=e(!1),[Y,J]=e(null),[$,At]=e(!1);A(()=>{if(o&&o.latitude&&o.longitude){40.7128===o.latitude&&-74.006===o.longitude||(U(o),P({lat:o.latitude,lng:o.longitude,isCurrentLocation:!1}),j({lat:o.latitude,lng:o.longitude}))}else null==o&&(U(null),P(null))},[o]),A(()=>{O&&40.7128===T.lat&&T.lng},[O,T]),A(()=>{(l||c)&&(O&&k(!1),R&&K(""),q&&(W(!1),J(null)))},[l,c]);const rt=r((t,e)=>tt(void 0,void 0,void 0,function*(){At(!0);try{const A=yield fetch(`https://nominatim.openstreetmap.org/reverse?format=json&lat=${t}&lon=${e}&addressdetails=1&zoom=18`),r=yield A.json();if(r&&r.address){const t=r.address;return{placeName:r.display_name||"",city:t.city||t.town||t.village||t.municipality||"",country:t.country||""}}}catch(t){console.error("Reverse geocoding failed:",t)}finally{At(!1)}return{placeName:"",city:"",country:""}}),[]),nt=r((e,A,r)=>tt(void 0,void 0,void 0,function*(){const n=yield rt(e,A),i=Object.assign({latitude:e,longitude:A,timestamp:Date.now(),placeName:n.placeName,city:n.city,country:n.country,address:n.placeName},r);if(U(i),P({lat:e,lng:A,isCurrentLocation:!1}),_(!0),m){m({id:t,value:i,isValid:!0,errors:{}})}}),[rt,t,m]),it=r(()=>tt(void 0,void 0,void 0,function*(){var t,e,A,r,n,s,a,o,u,h,d,f,p,g,m;if(l||c)return;N(!0),L("");if(void 0!==window.Capacitor)try{const{Geolocation:l}=window.Capacitor.Plugins;if(l)try{if("granted"!==(yield l.requestPermissions()).location)return N(!1),void L("Location permission is required. Please enable location access in your device settings.");const a=yield l.getCurrentPosition({enableHighAccuracy:null===(e=null===(t=i.validation)||void 0===t?void 0:t.enableHighAccuracy)||void 0===e||e,timeout:null!==(r=null===(A=i.validation)||void 0===A?void 0:A.timeout)&&void 0!==r?r:1e4,maximumAge:null!==(s=null===(n=i.validation)||void 0===n?void 0:n.maximumAge)&&void 0!==s?s:3e5}),o=a.coords.latitude,c=a.coords.longitude;return P({lat:o,lng:c,isCurrentLocation:!0}),j({lat:o,lng:c}),_(!0),yield nt(o,c,{accuracy:a.coords.accuracy,timestamp:Date.now()}),N(!1),void L("")}catch(t){return N(!1),void((null===(a=t.message)||void 0===a?void 0:a.includes("permission"))||(null===(o=t.message)||void 0===o?void 0:o.includes("denied"))?L("Location permission is required. Please enable location access in your device settings."):(null===(u=t.message)||void 0===u?void 0:u.includes("timeout"))?L("Location request timed out. Please try again."):L("Unable to retrieve your location. Please try again."))}}catch(t){console.warn("Capacitor Geolocation not available, falling back to web geolocation")}if(!navigator.geolocation)return N(!1),void L("Geolocation is not supported by this browser.");const v={enableHighAccuracy:null===(d=null===(h=i.validation)||void 0===h?void 0:h.enableHighAccuracy)||void 0===d||d,timeout:null!==(p=null===(f=i.validation)||void 0===f?void 0:f.timeout)&&void 0!==p?p:1e4,maximumAge:null!==(m=null===(g=i.validation)||void 0===g?void 0:g.maximumAge)&&void 0!==m?m:3e5};navigator.geolocation.getCurrentPosition(t=>tt(void 0,void 0,void 0,function*(){const e=t.coords.latitude,A=t.coords.longitude;P({lat:e,lng:A,isCurrentLocation:!0}),j({lat:e,lng:A}),_(!0),yield nt(e,A,{accuracy:t.coords.accuracy,timestamp:t.timestamp}),N(!1),L("")}),t=>{N(!1);let e="Unable to retrieve your location.";switch(t.code){case t.PERMISSION_DENIED:e="Location access denied by user. Please enable location access in your browser/device settings.";break;case t.POSITION_UNAVAILABLE:e="Location information is unavailable.";break;case t.TIMEOUT:e="Location request timed out. Please try again."}L(e)},v)}),[l,c,i,nt]),st=r(()=>{if(!l&&!c&&(U(null),P(null),L(""),_(!0),m)){m({id:t,value:null,isValid:!0,errors:{}})}},[l,c,t,m]),at=r(()=>{l||c||k(!O)},[l,c,O]),ot=r((t,e,A,r,n,i)=>{const s=t-n/2,a=e-i/2,o=156543.03392*Math.cos(A.lat*Math.PI/180)/Math.pow(2,r),l=s*o,c=a*o;return{lat:A.lat+c/111320,lng:A.lng+l/(111320*Math.cos(A.lat*Math.PI/180))}},[]),lt=r(t=>{l||c||!G.current||0===t.button&&(W(!0),J({x:t.clientX,y:t.clientY}),t.preventDefault())},[l,c]),ct=r(t=>{if(!q||!Y||!G.current)return;const e=t.clientX-Y.x,A=t.clientY-Y.y,r=156543.03392*Math.cos(T.lat*Math.PI/180)/Math.pow(2,D),n=-A*r/111320,i=e*r/(111320*Math.cos(T.lat*Math.PI/180));j({lat:T.lat+n,lng:T.lng+i}),J({x:t.clientX,y:t.clientY})},[q,Y,T,D]),ut=r(t=>tt(void 0,void 0,void 0,function*(){if(!G.current)return;if(q&&Y){const e=Math.abs(t.clientX-Y.x),A=Math.abs(t.clientY-Y.y);if(e>5||A>5)return W(!1),void J(null)}if(l||c)return W(!1),void J(null);const e=G.current.getBoundingClientRect(),A=t.clientX-e.left,r=t.clientY-e.top,{lat:n,lng:i}=ot(A,r,T,D,e.width,e.height);yield nt(n,i),W(!1),J(null)}),[l,c,G,T,D,ot,nt,q,Y]),ht=r(e=>tt(void 0,void 0,void 0,function*(){if(e.trim()&&!l&&!c){z(!0),L("");try{const A=yield fetch(`https://nominatim.openstreetmap.org/search?format=json&q=${encodeURIComponent(e)}&limit=5&addressdetails=1`),r=yield A.json();if(r&&r.length>0){const e=r[0],A=parseFloat(e.lat),n=parseFloat(e.lon),i=e.address||{},s={latitude:A,longitude:n,address:e.display_name,placeName:e.display_name,city:i.city||i.town||i.village||i.municipality||"",country:i.country||"",timestamp:Date.now()};if(U(s),P({lat:A,lng:n,isCurrentLocation:!1}),j({lat:A,lng:n}),_(!0),m){m({id:t,value:s,isValid:!0,errors:{}})}}else L("No locations found for your search.")}catch(t){L("Failed to search for location. Please try again.")}finally{z(!1)}}}),[l,c,t,m]),dt=()=>{w&&w()},ft=()=>{_(!0),v&&v()},pt=c||l||(null===(y=null==i?void 0:i.validation)||void 0===y?void 0:y.readonly),gt=(null===(C=null==i?void 0:i.basic)||void 0===C?void 0:C.label)||"Location",mt=(null===(x=null==i?void 0:i.basic)||void 0===x?void 0:x.description)||"";return X.jsxs("div",{className:`form-group ${b?"no-label":""} ${B}`,children:[!b&&X.jsxs("label",{htmlFor:t,className:"form-label",children:[gt,(null===(F=null==i?void 0:i.validation)||void 0===F?void 0:F.required)&&X.jsx("span",{className:"required-indicator",children:"*"})]}),mt&&X.jsx("div",{className:"form-group-description",children:mt}),X.jsxs("div",{className:"location-wrapper",children:[!(l&&Q)&&X.jsxs("div",{className:"location-controls",children:[X.jsx("button",{type:"button",className:"location-btn "+(E?"loading":""),onClick:it,disabled:pt||E,onFocus:dt,onBlur:ft,tabIndex:pt?-1:0,children:E?X.jsxs(X.Fragment,{children:[X.jsx(d,{size:16,className:"loading-spinner"}),"Getting Location..."]}):X.jsxs(X.Fragment,{children:[X.jsx(f,{size:16}),"Get Current Location"]})}),X.jsxs("button",{type:"button",className:"location-btn secondary",onClick:at,disabled:pt,onFocus:dt,onBlur:ft,tabIndex:pt?-1:0,children:[X.jsx(p,{size:16}),O?"Hide Map":"Choose on Map"]})]}),Q&&X.jsxs("div",{className:"location-display",children:[!l&&X.jsx("button",{type:"button",className:"location-clear-btn",onClick:st,disabled:pt,title:"Clear location",children:X.jsx(a,{size:16})}),Q.placeName&&X.jsxs("div",{className:"location-place-name",children:[X.jsx("strong",{children:"Place:"})," ",Q.placeName]}),(Q.city||Q.country)&&X.jsxs("div",{className:"location-address",children:[X.jsx("strong",{children:"Address:"})," ",[Q.city,Q.country].filter(Boolean).join(", ")]}),X.jsxs("div",{className:"location-coordinates",children:[X.jsx("strong",{children:"Coordinates:"})," ",(wt=Q.latitude,Bt=Q.longitude,void 0===wt||void 0===Bt||isNaN(wt)||isNaN(Bt)?"":`${Number(wt).toFixed(6)}, ${Number(Bt).toFixed(6)}`)]}),Q.accuracy&&X.jsxs("div",{className:"location-accuracy",children:[X.jsx("strong",{children:"Accuracy:"})," ",(vt=Q.accuracy,vt?`±${Math.round(vt)}m`:"")]}),Q.timestamp&&X.jsxs("div",{className:"location-timestamp",children:[X.jsx("strong",{children:"Captured:"})," ",(et(Q.timestamp)||new Date).toLocaleString()]})]}),O&&!l&&X.jsxs("div",{className:"location-map-container",children:[X.jsxs("div",{className:"location-map-header",children:[X.jsx("h4",{children:"Select Location on Map"}),X.jsx("p",{children:"Search for a place or click on the map to select a location"})]}),X.jsx("div",{className:"location-search",children:X.jsx("form",{onSubmit:t=>{t.preventDefault(),R.trim()&&ht(R)},className:"search-form",children:X.jsxs("div",{className:"search-input-group",children:[X.jsx("input",{type:"text",value:R,onChange:t=>{K(t.target.value)},placeholder:"Search for a place (e.g., New York, Paris, Tokyo)",className:"search-input",disabled:pt||V}),X.jsx("button",{type:"submit",className:"search-btn",disabled:pt||V||!R.trim(),children:V?X.jsx(d,{size:16,className:"loading-spinner"}):"Search"})]})})}),X.jsxs("div",{ref:G,className:"location-map "+(q?"dragging":""),onMouseDown:lt,onMouseMove:ct,onMouseUp:ut,onMouseLeave:()=>{W(!1),J(null)},style:{position:"relative",height:"400px",border:"2px solid var(--df-color-fb-border)",borderRadius:"8px",overflow:"hidden",cursor:q?"grabbing":"grab",background:`url(https://tile.openstreetmap.org/${D}/${Math.floor((T.lng+180)/360*Math.pow(2,D))}/${Math.floor((1-Math.log(Math.tan(T.lat*Math.PI/180)+1/Math.cos(T.lat*Math.PI/180))/Math.PI)/2*Math.pow(2,D))}.png) center/cover no-repeat`,userSelect:"none"},children:[H&&X.jsx("div",{className:"map-marker "+(H.isCurrentLocation?"current-location":"selected-location"),style:{position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -100%)",zIndex:10},children:X.jsx(p,{size:24})}),X.jsx("div",{className:"map-center-indicator",style:{position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)",width:"4px",height:"4px",backgroundColor:"var(--df-color-primary)",borderRadius:"50%",zIndex:5}}),X.jsxs("div",{className:"map-controls",children:[X.jsx("button",{type:"button",className:"map-zoom-btn",onClick:()=>M(t=>Math.min(18,t+1)),disabled:D>=18,children:"+"}),X.jsx("button",{type:"button",className:"map-zoom-btn",onClick:()=>M(t=>Math.max(1,t-1)),disabled:D<=1,children:"−"})]})]}),X.jsxs("div",{className:"location-map-instructions",children:[X.jsx("p",{children:X.jsx("strong",{children:"Instructions:"})}),X.jsxs("ul",{children:[X.jsx("li",{children:"Search for a place using the search box above"}),X.jsx("li",{children:"Click anywhere on the map to select a location"}),X.jsx("li",{children:"Drag the map to pan around"}),X.jsx("li",{children:"Use the zoom buttons (+/−) to zoom in/out"}),X.jsx("li",{children:'Use "Get Current Location" to automatically detect your position'})]})]}),$&&X.jsxs("div",{className:"location-loading",children:[X.jsx(d,{size:16,className:"loading-spinner"}),X.jsx("span",{children:"Loading address details..."})]})]}),S&&X.jsx("div",{className:"location-error",children:S})]}),X.jsx(Z,{validationErrors:s,fieldId:t,touchedFields:u,formSubmitted:h,properties:i,localValidation:{isValid:!0,errors:{}},isTouched:I,mode:g})]});var vt,wt,Bt},pt=({id:t,properties:e,className:A="",hideLabel:r=!1})=>{var n,i,s;const a=null!==(s=null!==(i=null===(n=e.styles)||void 0===n?void 0:n.level)&&void 0!==i?i:e.basic.level)&&void 0!==s?s:1,o=e.basic.label,l=()=>{var t;return`form-heading ${`h${a}`} ${(null===(t=null==e?void 0:e.styles)||void 0===t?void 0:t.textAlign)?`text-${e.styles.textAlign}`:""} ${A}`.trim()},c=()=>{var t,A;const r={};return(null===(t=null==e?void 0:e.styles)||void 0===t?void 0:t.fontSize)&&(r.fontSize=e.styles.fontSize),(null===(A=null==e?void 0:e.styles)||void 0===A?void 0:A.color)&&(r.color=e.styles.color),r};return r?null:(()=>{const e={id:t,className:l(),style:c()};switch(a){case 1:default:return X.jsx("h1",Object.assign({},e,{children:o}));case 2:return X.jsx("h2",Object.assign({},e,{children:o}));case 3:return X.jsx("h3",Object.assign({},e,{children:o}));case 4:return X.jsx("h4",Object.assign({},e,{children:o}));case 5:return X.jsx("h5",Object.assign({},e,{children:o}));case 6:return X.jsx("h6",Object.assign({},e,{children:o}))}})()},gt=({id:t,properties:i,mode:s="preview",formValue:a,onValueChange:o,className:l="",hideLabel:c=!1})=>{var u,h,d;const[f,p]=e(""),[b,y]=e((null===(u=i.validation)||void 0===u?void 0:u.listStyle)||"numbers"),[C,x]=e("#000000"),F=n(null),Q=n(null),U=n(!1),E="edit"===s,N=n({instructions:[],listStyle:"numbers",formValue:void 0}),S=n(s);A(()=>{var t,e,A,r,n;let o=[],l="numbers";if(null!=a&&("object"==typeof a&&a.instructions?(Array.isArray(a.instructions)?o=a.instructions:"string"==typeof a.instructions&&(o=[a.instructions]),a.listStyle&&(l=a.listStyle)):Array.isArray(a)?o=a:"string"==typeof a&&(o=[a])),0===o.length&&(null===(t=i.basic)||void 0===t?void 0:t.value)){const t=i.basic.value;t&&"object"==typeof t&&!Array.isArray(t)&&t.instructions?(Array.isArray(t.instructions)?o=t.instructions:"string"==typeof t.instructions&&(o=[t.instructions]),t.listStyle&&"string"==typeof t.listStyle&&(l=t.listStyle)):Array.isArray(t)?o=t:"string"==typeof t&&(o=[t])}0===o.length&&(null===(e=i.basic)||void 0===e?void 0:e.instructions)&&(Array.isArray(i.basic.instructions)?o=i.basic.instructions:"string"==typeof i.basic.instructions&&(o=[i.basic.instructions])),l&&"numbers"!==l||(l=(null===(A=i.validation)||void 0===A?void 0:A.listStyle)||(null===(n=null===(r=i.basic)||void 0===r?void 0:r.value)||void 0===n?void 0:n.listStyle)||"numbers");const c=JSON.stringify(o)!==JSON.stringify(N.current.instructions)||l!==N.current.listStyle,u=s!==S.current,h=JSON.stringify(a)!==JSON.stringify(N.current.formValue),d=!N.current.formValue||Array.isArray(N.current.formValue)&&0===N.current.formValue.length||"string"==typeof N.current.formValue&&""===N.current.formValue.trim(),f=null!=a&&(Array.isArray(a)&&a.length>0||"string"==typeof a&&""!==a.trim()||"object"==typeof a&&Object.keys(a).length>0);if(c||u||h||d&&f){const t=t=>"string"!=typeof t?t:t.replace(/\\u([0-9a-fA-F]{4})/g,(t,e)=>String.fromCharCode(parseInt(e,16))),e=o.map(e=>"string"==typeof e?t(e):e),A=e.some(t=>"string"==typeof t&&/<[^>]+>/.test(t));let r="";if(e.length>0)if(A)r=e.join("");else{const t="numbers"===l?"ol":"bullets"===l?"ul":"div",A=e.filter(t=>t&&"string"==typeof t).map(t=>`<li>${t.replace(/\n/g,"<br>")}</li>`).join("");r="div"===t?e.filter(t=>t&&"string"==typeof t).map(t=>`<div>${t.replace(/\n/g,"<br>")}</div>`).join(""):`<${t}>${A}</${t}>`}y(l),p(r),E&&F.current&&(u||c&&F.current.innerHTML.trim()!==r.trim())&&(F.current.innerHTML=r),N.current={instructions:o,listStyle:l,formValue:a},S.current=s}},[a,null===(h=i.basic)||void 0===h?void 0:h.instructions,null===(d=i.validation)||void 0===d?void 0:d.listStyle,s,E]),A(()=>{if(E&&F.current){const t=F.current.innerHTML.trim();f.trim()===t||U.current||(F.current.innerHTML=f)}if(U.current){const t=setTimeout(()=>{U.current=!1},200);return()=>clearTimeout(t)}},[f,E]);const L=r(()=>{if(!F.current)return;U.current=!0;const e=F.current.innerHTML.trim();if(o){o({id:t,value:{instructions:e?[e]:[],listStyle:b},isValid:!0,errors:{}})}e!==f&&p(e)},[t,b,o,f]),I=r(()=>{if(!F.current)return;const e=F.current.innerHTML.trim();if(o){o({id:t,value:{instructions:e?[e]:[],listStyle:b},isValid:!0,errors:{}})}p(e),U.current=!1},[t,b,o]),_=r((t,e)=>{var A;document.execCommand(t,!1,e),null===(A=F.current)||void 0===A||A.focus(),L()},[L]),O=r(()=>{_("bold")},[_]),k=r(()=>{_("italic")},[_]),T=r(t=>{const e=t.target.value;x(e),_("foreColor",e)},[_]),j=r(e=>{if(y(e),!F.current)return;const A=window.getSelection(),r=A&&A.rangeCount>0?A.getRangeAt(0):null;let n=F.current.innerHTML;if("numbers"===e){if(n=n.replace(/<ul>/gi,"<ol>").replace(/<\/ul>/gi,"</ol>"),!n.includes("<ol>")&&!n.includes("<ul>")){const t=n.split(/<br\s*\/?>/i).filter(t=>t.trim());t.length>0&&(n="<ol>"+t.map(t=>`<li>${t}</li>`).join("")+"</ol>")}}else if("bullets"===e){if(n=n.replace(/<ol>/gi,"<ul>").replace(/<\/ol>/gi,"</ul>"),!n.includes("<ol>")&&!n.includes("<ul>")){const t=n.split(/<br\s*\/?>/i).filter(t=>t.trim());t.length>0&&(n="<ul>"+t.map(t=>`<li>${t}</li>`).join("")+"</ul>")}}else n=n.replace(/<\/?[ou]l>/gi,"").replace(/<li>/gi,"<div>").replace(/<\/li>/gi,"</div>");if(F.current.innerHTML=n,p(n),r&&A)try{A.removeAllRanges(),A.addRange(r)}catch(t){}if(L(),o){o({id:t,value:{instructions:n?[n]:[],listStyle:e},isValid:!0,errors:{}})}},[t,L,o]),H=r(t=>{var e;const A=null===(e=t.target.files)||void 0===e?void 0:e[0];if(!A||!A.type.startsWith("image/"))return;const r=new FileReader;r.onload=t=>{var e;const A=null===(e=t.target)||void 0===e?void 0:e.result;if(A&&F.current){const t=document.createElement("img");t.src=A,t.style.maxWidth="100%",t.style.height="auto";const e=window.getSelection();if(e&&e.rangeCount>0){const A=e.getRangeAt(0);A.deleteContents(),A.insertNode(t)}else F.current.appendChild(t);L()}},r.readAsDataURL(A),Q.current&&(Q.current.value="")},[L]),P=r(t=>{t.preventDefault();const e=t.clipboardData.getData("text/plain"),A=window.getSelection();if(A&&A.rangeCount>0){const t=A.getRangeAt(0);t.deleteContents();const r=document.createTextNode(e);t.insertNode(r),t.setStartAfter(r),t.collapse(!0),A.removeAllRanges(),A.addRange(t)}L()},[L]),D=r(t=>document.queryCommandState(t),[]);return X.jsxs("div",{className:`form-group instruction-group ${l}`,children:[!c&&X.jsx("label",{htmlFor:t,className:"instruction-label",children:"Instructions"}),E?X.jsxs("div",{className:"instruction-rich-editor",children:[X.jsxs("div",{className:"instruction-toolbar",children:[X.jsxs("div",{className:"toolbar-group",children:[X.jsx("button",{type:"button",className:"toolbar-btn "+(D("bold")?"active":""),onClick:O,title:"Bold","aria-label":"Bold",children:X.jsx(g,{size:16})}),X.jsx("button",{type:"button",className:"toolbar-btn "+(D("italic")?"active":""),onClick:k,title:"Italic","aria-label":"Italic",children:X.jsx(m,{size:16})})]}),X.jsx("div",{className:"toolbar-separator"}),X.jsx("div",{className:"toolbar-group",children:X.jsxs("div",{className:"color-picker-wrapper",children:[X.jsx("input",{type:"color",value:C,onChange:T,className:"color-picker-input",title:"Text Color"}),X.jsx("label",{className:"color-picker-label",title:"Text Color",children:X.jsx("span",{style:{color:C},children:"A"})})]})}),X.jsx("div",{className:"toolbar-separator"}),X.jsxs("div",{className:"toolbar-group",children:[X.jsx("button",{type:"button",className:"toolbar-btn "+("bullets"===b?"active":""),onClick:()=>j("bullets"),title:"Bullet List","aria-label":"Bullet List",children:X.jsx(v,{size:16})}),X.jsx("button",{type:"button",className:"toolbar-btn "+("numbers"===b?"active":""),onClick:()=>j("numbers"),title:"Numbered List","aria-label":"Numbered List",children:X.jsx(w,{size:16})})]}),X.jsx("div",{className:"toolbar-separator"}),X.jsxs("div",{className:"toolbar-group",children:[X.jsx("button",{type:"button",className:"toolbar-btn",onClick:()=>{var t;return null===(t=Q.current)||void 0===t?void 0:t.click()},title:"Insert Image","aria-label":"Insert Image",children:X.jsx(B,{size:16})}),X.jsx("input",{ref:Q,type:"file",accept:"image/*",onChange:H,style:{display:"none"}})]})]}),X.jsx("div",{ref:F,contentEditable:!0,className:"instruction-editor-content",onInput:L,onBlur:I,onPaste:P,"data-placeholder":"Enter instructions (press Enter for a new line)...",suppressContentEditableWarning:!0})]}):X.jsx("div",{className:"instruction-preview-wrapper "+("numbers"===b?"instruction-list-numbers":"bullets"===b?"instruction-list-bullets":""),children:f?X.jsx("div",{className:"instruction-preview-content",dangerouslySetInnerHTML:{__html:f}}):X.jsx("div",{className:"instruction-empty",children:X.jsx("p",{children:"No instructions provided"})})})]})},mt=({attachments:t,onRemove:r})=>{const[n,i]=e(new Map);return A(()=>{if(!t)return void i(t=>(t.forEach(t=>URL.revokeObjectURL(t)),new Map));const e=new Map;return t.forEach((t,A)=>{if(t&&t.type&&"string"==typeof t.type&&t.type.startsWith("image/")){const r=URL.createObjectURL(t);e.set(A,r)}}),i(t=>(t.forEach((t,A)=>{e.has(A)||URL.revokeObjectURL(t)}),e)),()=>{e.forEach(t=>URL.revokeObjectURL(t))}},[t]),t&&0!==t.length?X.jsx("div",{className:"attachment-thumbnails-container",children:t.map((t,e)=>{const A=t&&t.type&&"string"==typeof t.type&&t.type.startsWith("image/"),i=n.get(e);return X.jsx("div",{className:"attachment-thumbnail",children:A&&i?X.jsxs(X.Fragment,{children:[X.jsx("img",{src:i,alt:t?t.name:"Attachment"}),X.jsx("button",{type:"button",className:"thumbnail-remove-btn",onClick:()=>r(e),title:"Remove attachment",children:X.jsx(a,{size:14})})]}):X.jsxs(X.Fragment,{children:[X.jsx("div",{className:"file-icon-placeholder",children:X.jsx(h,{size:20})}),X.jsx("span",{className:"file-name",children:t?t.name:"Unknown File"}),X.jsx("button",{type:"button",className:"thumbnail-remove-btn",onClick:()=>r(e),title:"Remove attachment",children:X.jsx(a,{size:14})})]})},e)})}):null},vt=({component:t,mode:i,formTemplateId:s,formValue:a,formData:o,onNotesChange:l,onAttachmentChange:u,notes:d="",attachments:f=null,onThresholdActionCompletion:p,onThresholdIssueRaised:g,onBasicPropertyActionCompletion:m,workOrderNumber:v,assetNumber:w,isStandalone:B,user:Q,onCreateIssue:U,onUpdateIssue:E})=>{var N;const S=void 0!==a?a:o?o[t.id]:void 0,[L,I]=e(d||""),[_,O]=e(f||null),[k,T]=e(!1),[j,H]=e(!1),[P,D]=e(!1),[M,R]=e(!1),[K,V]=e(null),[z,G]=e(!1),q=n(null),W=n(S),Y=n(!1),J=n(!1);A(()=>{d&&d!==L&&!Y.current&&(I(d),Y.current=!0)},[d,L]),A(()=>{f&&f!==_&&!J.current&&(O(f),J.current=!0)},[f,_]),A(()=>{if(Y.current&&!k&&null!=d){const t="string"==typeof d?d:String(d||"");L&&""!==String(L||"").trim()||!t||""===t.trim()?t&&""!==t.trim()&&t!==L&&I(t):I(t)}},[d,k,L]),A(()=>{J.current&&void 0!==f&&(!_||f&&f.length>0&&f!==_)&&O(f)},[f,_]),A(()=>{const e=["select","radio","checkbox","segment"].includes(t.name||"");if(e){const e=W.current,A=S;let r=!1;if("checkbox"===t.name){const t=Array.isArray(e)?e:e?[e]:[],n=Array.isArray(A)?A:A?[A]:[];r=JSON.stringify(t.sort())!==JSON.stringify(n.sort())}else r=e!==A&&void 0!==e;r&&(D(!1),R(!1),V(null),H(!1),T(!1),G(!1),d&&""!==d.trim()||I(""),f&&0!==f.length||O(null)),W.current=A}e||(W.current=S)},[S,t.name,d,f]);const $=r((t,e)=>{const{operator:A,value:r}=t,n=String(e).toLowerCase(),i=String(r).toLowerCase();switch(A){case"equals":return n===i||String(e)===String(r);case"notEquals":return n!==i&&String(e)!==String(r);case"greaterThan":return Number(e)>Number(r);case"lessThan":return Number(e)<Number(r);case"greaterThanOrEqual":return Number(e)>=Number(r);case"lessThanOrEqual":return Number(e)<=Number(r);default:return!1}},[]),Z=r(()=>{if(!(null!=S&&""!==S&&!(Array.isArray(S)&&0===S.length)))return[];const e=t.condition;if(!e||!e.conditions||0===e.conditions.length)return[];const A=[];if("checkbox"===t.name&&Array.isArray(S))S.forEach(t=>{const r=e.conditions.find(e=>$(e,t));r&&!A.find(t=>t.id===r.id)&&A.push(r)});else{const t=e.conditions.find(t=>$(t,S));t&&A.push(t)}return A},[t,S,$]),tt=r(e=>{const A=e.target.value;I(A),l&&l(A);const r=Z(),n=A.trim().length>0;r.forEach(t=>{!0===t.enableNotes&&p&&p(t.id,"notes",n)});const i=t.condition;!(i&&i.conditions&&i.conditions.length>0)&&m&&m("notes",n)},[l,Z,p,t,m]),et=r(()=>{if(l){const t="string"==typeof L?L:String(L||"");l(t),setTimeout(()=>{T(!1)},0)}else T(!1)},[L,l]),At=r(()=>{et()},[et]),nt=r(t=>{(t.ctrlKey||t.metaKey)&&"Enter"===t.key&&(t.preventDefault(),et())},[et]),it=r(()=>{T(!0)},[]),st=r(()=>{T(!0)},[]),at=r(()=>{var t;null===(t=q.current)||void 0===t||t.click()},[]),ot=r(e=>{const A=e.target.files;if(A&&A.length>0){const e=Array.from(A);O(e),u&&u(e);Z().forEach(t=>{!0===t.enableAttachment&&p&&p(t.id,"attachments",!0)});const r=t.condition;!(r&&r.conditions&&r.conditions.length>0)&&m&&m("attachments",!0)}q.current&&(q.current.value="")},[u,Z,p,t,m]),lt=r(e=>{if(_){const A=_.filter((t,A)=>A!==e);if(0===A.length){O(null),u&&u(null);Z().forEach(t=>{!0===t.enableAttachment&&p&&p(t.id,"attachments",!1)});const e=t.condition;!(e&&e.conditions&&e.conditions.length>0)&&m&&m("attachments",!1)}else O(A),u&&u(A)}},[_,u,Z,p,t,m]),ct=r(()=>{D(!0);Z().forEach(t=>{!0===t.enableSendEmail&&p&&p(t.id,"email",!0)});const e=t.condition;!(e&&e.conditions&&e.conditions.length>0)&&m&&m("email",!0),setTimeout(()=>{D(!1)},3e3)},[Z,p,t,m]),ut=r(()=>{M||H(!0)},[M]),ht=r(()=>{H(!1)},[]),dt=r(e=>{H(!1),R(!0),e&&V(e);const A=t.condition;if(A&&A.conditions&&A.conditions.length>0){Z().forEach(t=>{!0===t.enableRaiseIssue&&g&&g(t.id)})}else m&&m("issue",!0)},[t,m,Z,g]);if("test"!==i)return null;const ft=["select","radio","checkbox","segment"].includes(t.name||""),pt=(null===(N=t.basic)||void 0===N?void 0:N.options)||t.options||[];let gt=!1,vt=!1,wt=!1,Bt=!1,bt=null;const yt=null!=S&&""!==S&&!(Array.isArray(S)&&0===S.length),Ct=t.condition,xt=Ct&&Ct.conditions&&Ct.conditions.length>0;if(xt&&yt)if("checkbox"===t.name&&Array.isArray(S)){const t=S;for(const e of t){const t=Ct.conditions.find(t=>$(t,e));t&&(gt=gt||!0===t.enableNotes,vt=vt||!0===t.enableAttachment,wt=wt||!0===t.enableRaiseIssue,Bt=Bt||!0===t.enableSendEmail)}}else if(ft){const t=Ct.conditions.find(t=>$(t,S));t&&(gt=!0===t.enableNotes,vt=!0===t.enableAttachment,wt=!0===t.enableRaiseIssue,Bt=!0===t.enableSendEmail)}else{const t=Ct.conditions.find(t=>$(t,S));t&&(gt=!0===t.enableNotes,vt=!0===t.enableAttachment,wt=!0===t.enableRaiseIssue,Bt=!0===t.enableSendEmail)}if(!xt){const e=t.basic,A=!0===(null==e?void 0:e.enableNotes),r=!0===(null==e?void 0:e.enableAttachment),n=!0===(null==e?void 0:e.enableRaiseIssue),i=!0===(null==e?void 0:e.enableSendEmail);if(ft)if(yt)if("checkbox"===t.name){(Array.isArray(S)?S:[S]).forEach(t=>{const e=pt.find(e=>!(!e||!e.value)&&(e.value===t||(String(e.value)===String(t)||(e.label===t||String(e.label)===String(t)))));e&&(gt=gt||!0===e.enableNotes,vt=vt||!0===e.enableAttachment,wt=wt||!0===e.enableRaiseIssue,Bt=Bt||!0===e.enableSendEmail,bt||(bt=e))}),gt=gt||A,vt=vt||r,wt=wt||n,Bt=Bt||i}else if(bt=pt.find(t=>!(!t||!t.value)&&(t.value===S||(String(t.value)===String(S)||(t.label===S||String(t.label)===String(S))))),bt){const t=!0===bt.enableNotes,e=!0===bt.enableAttachment,s=!0===bt.enableRaiseIssue,a=!0===bt.enableSendEmail;gt=t||A,vt=e||r,wt=s||n,Bt=a||i}else gt=A,vt=r,wt=n,Bt=i;else gt=A,vt=r,wt=n,Bt=i;else gt=A,vt=r,wt=n,Bt=i}if(!(gt||vt||wt||Bt))return null;const Ft=Z(),Qt=t.condition,Ut=Qt&&Qt.conditions&&Qt.conditions.length>0,Et=!!Ut&&Ft.some(t=>!0===t.enableNotes),Nt=!!Ut&&Ft.some(t=>!0===t.enableAttachment),St=!!Ut&&Ft.some(t=>!0===t.enableSendEmail),Lt=!!Ut&&Ft.some(t=>!0===t.enableRaiseIssue),It=L.trim().length>0,_t=_&&_.length>0,Ot=_?_.length:0;return X.jsxs(X.Fragment,{children:[X.jsxs("div",{className:"component-action-features",children:[X.jsxs("div",{className:"action-icons-toolbar",children:[gt&&X.jsxs("button",{type:"button",className:`action-icon-button ${It?"active":""} ${Et?"mandatory":""}`,onClick:it,title:"Add Notes",children:[X.jsx(c,{size:14,fill:It?"currentColor":"none"}),Et&&X.jsx("span",{className:"mandatory-indicator",children:"*"})]}),vt&&X.jsxs("button",{type:"button",className:`action-icon-button ${_t?"active":""} ${Nt?"mandatory":""}`,onClick:at,title:"Add Attachment",children:[X.jsx(h,{size:14,fill:_t?"currentColor":"none"}),Ot>0&&X.jsx("span",{className:"attachment-count-badge",children:Ot}),Nt&&X.jsx("span",{className:"mandatory-indicator",children:"*"})]}),Bt&&X.jsxs("button",{type:"button",className:`action-icon-button ${P?"active sent":""} ${St?"mandatory":""}`,onClick:ct,disabled:P,title:"Send Email",children:[P?X.jsx(X.Fragment,{children:X.jsx(b,{size:14})}):X.jsx(y,{size:14,fill:P?"currentColor":"none"}),St&&X.jsx("span",{className:"mandatory-indicator",children:"*"})]}),wt&&X.jsxs("button",{type:"button",className:`action-icon-button ${M?"active":""} ${Lt?"mandatory":""}`,onClick:ut,title:"Raise an Issue",children:[X.jsx(C,{size:14,fill:M?"currentColor":"none"}),Lt&&X.jsx("span",{className:"mandatory-indicator",children:"*"})]}),(It&&gt||_t&&vt)&&X.jsx("button",{type:"button",className:"action-icon-button accordion-toggle",onClick:()=>G(!z),title:z?"Collapse":"Expand",children:z?X.jsx(x,{size:14}):X.jsx(F,{size:14})})]}),k&&gt&&X.jsxs("div",{className:"notes-input-overlay",children:[X.jsx("textarea",{className:"action-notes-textarea",value:L,onChange:tt,onBlur:At,onKeyDown:nt,placeholder:"Explain which protocols were not followed (Press Ctrl+Enter to save)",rows:4,autoFocus:!0}),X.jsxs("div",{className:"notes-input-actions",children:[X.jsx("button",{type:"button",className:"notes-save-button",onClick:et,title:"Save notes (Ctrl+Enter)",children:"Save"}),X.jsx("button",{type:"button",className:"notes-cancel-button",onClick:()=>{T(!1)},title:"Cancel",children:"Cancel"})]})]}),z&&X.jsxs("div",{className:"actions-content",children:[!k&&It&&gt&&X.jsx("div",{className:"notes-summary-section",children:X.jsxs("div",{className:"notes-full-text",onClick:st,children:[X.jsx("span",{className:"notes-label",children:"Notes:"})," ",L]})}),_t&&vt&&X.jsx("div",{className:"attachments-section",children:X.jsx(mt,{attachments:_,onRemove:lt})})]}),vt&&X.jsx("input",{ref:q,type:"file",multiple:!0,accept:"image/*,.pdf",onChange:ot,style:{display:"none"}})]}),j&&X.jsx(rt,{isOpen:j,onClose:ht,onSuccess:dt,issue:K,component:(()=>{var e,A;const r=null!=S?Array.isArray(S)?S.join(", "):String(S):(null===(e=t.basic)||void 0===e?void 0:e.value)||"",n=Object.assign(Object.assign({},t),{basic:Object.assign(Object.assign({},t.basic||{}),{value:r})});return bt&&(n.basic.label=`${(null===(A=t.basic)||void 0===A?void 0:A.label)||"Component"} - ${bt.label||bt.value}`,n.basic.value=bt.value||r),n})(),formTemplateId:s||"",notes:L,attachments:_,isStandalone:B,workOrderNumber:v,assetNumber:w,user:Q,onCreateIssue:U,onUpdateIssue:E})]})},wt=({attachments:t})=>t&&0!==t.length?X.jsx("div",{className:"attachment-thumbnails-container",children:t.map((t,e)=>{var A;const r=(null===(A=t.type)||void 0===A?void 0:A.startsWith("image/"))||!1,n=r?(t=>t.data?t.data.startsWith("data:")?t.data:`data:${t.type||"image/png"};base64,${t.data}`:"")(t):"";return X.jsx("div",{className:"attachment-thumbnail",children:r&&n?X.jsx("img",{src:n,alt:t.name||`Attachment ${e+1}`}):X.jsxs("div",{className:"file-icon-placeholder",children:[X.jsx(h,{size:20}),X.jsx("span",{className:"file-name",children:t.name||`File ${e+1}`})]})},e)})}):null,Bt=({component:t})=>{var e,A;const r=(null===(e=t.basic)||void 0===e?void 0:e.notes)||"",n=(null===(A=t.basic)||void 0===A?void 0:A.attachments)||[],i=r&&r.trim().length>0,s=n&&n.length>0;return i||s?X.jsx("div",{className:"component-submission-actions",children:X.jsxs("div",{className:"actions-content",children:[i&&X.jsx("div",{className:"notes-summary-section",children:X.jsxs("div",{className:"notes-full-text",children:[X.jsx("span",{className:"notes-label",children:"Notes:"})," ",r]})}),s&&X.jsx("div",{className:"attachments-section",children:X.jsx(wt,{attachments:n})})]})}):null},bt=({child:t,selectedChild:e,mode:A,onChildSelect:r,onChildDelete:n,renderFormComponent:i,isOverlay:s=!1,isChildrenEditMode:a=!1,formData:o={},formTemplateId:l,onThresholdActionCompletion:c,onThresholdIssueRaised:u,onNotesChange:h,onAttachmentChange:d,workOrderNumber:f,assetNumber:p,user:g,onCreateIssue:m,onUpdateIssue:v})=>{var w,B;const b=o[t.id],y="preview"===A&&((null===(w=t.basic)||void 0===w?void 0:w.notes)&&t.basic.notes.trim().length>0||(null===(B=t.basic)||void 0===B?void 0:B.attachments)&&Array.isArray(t.basic.attachments)&&t.basic.attachments.length>0),{attributes:C,listeners:x,setNodeRef:F,transform:Q,transition:S,isDragging:L,isSorting:I}=j({id:t.id,disabled:s||"edit"!==A}),_={transform:P.Transform.toString(Q),transition:S,zIndex:L?1e3:"auto"};return X.jsxs("div",{ref:F,style:_,className:`form-component section-child ${(null==e?void 0:e.id)===t.id?"selected":""} ${L?"dragging":""} ${I?"sorting":""} ${a?"children-edit-active":""}`,onClick:()=>!L&&r(t),role:"button",tabIndex:0,children:[("edit"===A||a)&&X.jsx("div",Object.assign({className:"child-drag-handle"},x,C,{onClick:t=>t.stopPropagation(),onMouseDown:t=>t.stopPropagation(),children:X.jsx(U,{size:14})})),X.jsxs("div",{className:"form-component-content section-child-content",children:[("edit"===A||a)&&X.jsxs("div",{className:"component-actions child-actions",children:[X.jsx("button",{className:"btn edit-btn",onClick:e=>{e.stopPropagation(),r(t)},onMouseDown:t=>t.stopPropagation(),title:"Edit properties",children:X.jsx(E,{size:12})}),X.jsx("button",{className:"btn delete-btn",onClick:e=>n(t,e),onMouseDown:t=>t.stopPropagation(),title:"Delete component",children:X.jsx(N,{size:12})})]}),X.jsxs("div",{className:"component-preview child-preview",children:[i(t),!["section","table","heading","file","instructions","signature","location","datagrid"].includes(t.name)&&X.jsx(vt,{component:t,mode:"test",formTemplateId:l,formValue:b,formData:o,onThresholdActionCompletion:c,onThresholdIssueRaised:u,onNotesChange:h?e=>h(t.id,e):void 0,onAttachmentChange:d?e=>d(t.id,e):void 0,workOrderNumber:f,assetNumber:p,user:g,onCreateIssue:m,onUpdateIssue:v}),y&&X.jsx(Bt,{component:t})]})]})]})},yt=({id:t,properties:n,mode:i="edit",formData:s={},onValueChange:a,onSelect:o,isSelected:l=!1,className:c="",onSectionSelect:u,onChildSelect:h,onChildDelete:d,selectedChild:f,renderFormComponent:p,formTemplateId:g,onThresholdActionCompletion:m,onThresholdIssueRaised:v,onNotesChange:w,onAttachmentChange:B,workOrderNumber:b,assetNumber:y,user:C,onCreateIssue:x,onUpdateIssue:U})=>{var E,N,S,L,I,_;const[j,H]=e(n.basic.collapsed),[P,D]=e(!1),[M,R]=e(!1),[K,V]=e(n.basic.label),[z,G]=e(n.basic.description),[q,W]=e(n.children||[]),[Y,J]=e(!1);A(()=>{W(n.children||[])},[n.children]),A(()=>{V(n.basic.label),G(n.basic.description)},[n.basic.label,n.basic.description]);const{setNodeRef:$,isOver:Z}=O({id:`section-${t}`,disabled:"edit"!==i}),tt=!("preview"!==i&&"test"!==i||n.children&&n.children.length>0),et=r(e=>{V(e),null==a||a({id:t,value:Object.assign(Object.assign({},n),{basic:Object.assign(Object.assign({},n.basic),{label:e})})})},[t,n,a]),At=r(e=>{G(e),null==a||a({id:t,value:Object.assign(Object.assign({},n),{basic:Object.assign(Object.assign({},n.basic),{description:e})})})},[t,n,a]),rt=r(t=>{null==h||h(t)},[h]),nt=r((t,e)=>{e.stopPropagation();const A=q.filter(e=>e.id!==t.id);W(A),null==d||d(t.id)},[d,q,t]),ct=r(()=>{null==u||u(n),null==o||o()},[u,o,n]),dt=r(t=>{t.stopPropagation(),"edit"===i&&q.length>0&&J(!Y)},[i,q.length,Y]),ft=r(e=>{e.stopPropagation(),H(!j),null==a||a({id:t,value:Object.assign(Object.assign({},n),{basic:Object.assign(Object.assign({},n.basic),{collapsed:!j})})})},[j,t,n,a]),gt=p||r(t=>{var e,A,r;const n=s[t.id]||"defaultValue"in t.basic&&t.basic.defaultValue||"";let o=n;"number-input"===t.name&&"number"==typeof n?o=String(n):"number-input"===t.name&&null==n&&(o="");const l={id:t.id,properties:t,validationErrors:{},formValue:o,touchedFields:{},formSubmitted:!1,mode:i,onValueChange:a,onBlur:()=>{},onFocus:()=>{}};switch(t.name){case"text-input":case"email-input":case"number-input":return X.jsx(it,Object.assign({},l,{properties:t,inputType:"text-input"===t.name?"text":"number-input"===t.name?"number":"email",readonly:!1,disabled:!1}));case"textarea":return X.jsx(st,Object.assign({},l,{properties:t,readonly:!1,disabled:!1}));case"select":const n=Object.assign(Object.assign({},t),{options:(null===(e=t.basic)||void 0===e?void 0:e.options)||[]});return X.jsx(at,Object.assign({},l,{properties:n,disabled:!1}));case"checkbox":const i=Object.assign(Object.assign({},t),{options:(null===(A=t.basic)||void 0===A?void 0:A.options)||[]});return X.jsx(ot,Object.assign({},l,{properties:i,formValue:[],disabled:!1}));case"radio":const s=Object.assign(Object.assign({},t),{options:(null===(r=t.basic)||void 0===r?void 0:r.options)||[]});return X.jsx(lt,Object.assign({},l,{properties:s,readonly:!1,disabled:!1}));case"date":case"date-picker":case"datetime-picker":return X.jsx(ut,Object.assign({},l,{properties:t,readonly:!1,disabled:!1}));case"signature":return X.jsx(ht,Object.assign({},l,{properties:t}));case"heading":return X.jsx(pt,Object.assign({},l,{properties:t}));default:return X.jsx("div",{className:"form-group",children:X.jsxs("div",{className:"form-group-label",children:["Unsupported Component: ",t.name]})})}},[i,a,s]);if(tt)return null;const mt={backgroundColor:(null===(E=n.styles)||void 0===E?void 0:E.backgroundColor)||"var(--df-color-fb-container)",borderColor:(null===(N=n.styles)||void 0===N?void 0:N.borderColor)||"var(--df-color-fb-border)",borderWidth:(null===(S=n.styles)||void 0===S?void 0:S.borderWidth)||"2px",borderRadius:(null===(L=n.styles)||void 0===L?void 0:L.borderRadius)||"8px",padding:(null===(I=n.styles)||void 0===I?void 0:I.padding)||"16px",margin:(null===(_=n.styles)||void 0===_?void 0:_.margin)||"16px 0"};return X.jsxs("div",{ref:$,className:`df-form-section ${l?"selected":""} ${Z?"drag-over":""} ${c}`,style:mt,children:[X.jsxs("div",{className:"section-header "+(Y?"children-edit-mode":""),onClick:ct,onDoubleClick:dt,children:[X.jsx("div",{className:"section-header-content",children:X.jsxs("div",{className:"section-title",children:[X.jsx("span",{className:"section-toggle",title:j?"Expand section":"Collapse section",role:"button",tabIndex:0,onClick:t=>{t.stopPropagation(),ft(t)},onKeyDown:t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),ft(t))},style:{marginRight:"8px",display:"inline-flex",alignItems:"center"},children:j?X.jsx(Q,{size:18}):X.jsx(F,{size:18})}),"edit"===i&&P?X.jsx("input",{type:"text",value:K,onChange:t=>V(t.target.value),onBlur:()=>{D(!1),et(K)},onKeyDown:t=>{"Enter"===t.key&&(D(!1),et(K))},className:"section-title-input",autoFocus:!0}):X.jsx("h3",{className:"section-title-text",onDoubleClick:()=>"edit"===i&&D(!0),style:{display:"inline",margin:0},children:K||"Untitled Section"})]})}),(z||"edit"===i)&&X.jsx("div",{className:"section-description",children:"edit"===i&&M?X.jsx("textarea",{value:z,onChange:t=>G(t.target.value),onBlur:()=>{R(!1),At(z)},onKeyDown:t=>{"Enter"===t.key&&t.ctrlKey&&(R(!1),At(z))},className:"section-description-input",placeholder:"Section description (optional)",autoFocus:!0}):X.jsx("p",{className:"section-description-text",onDoubleClick:()=>"edit"===i&&R(!0),children:z||"Section description"})})]}),!j&&X.jsx("div",{className:`section-content ${Z?"drag-over":""} ${0===q.length?"empty":"has-children"}`,onClick:t=>{t.target===t.currentTarget&&ct()},children:X.jsx(k,{items:q.map(t=>t.id),strategy:T,children:0===q.length?X.jsxs("div",{className:"section-empty-state",onClick:ct,style:{textAlign:"center",color:"#6b7280",fontSize:"14px",padding:"40px 20px",display:"flex",flexDirection:"column",alignItems:"center",gap:"8px",cursor:"pointer",border:"2px dotted #d1d5db",borderRadius:"8px",backgroundColor:"var(--df-color-fb-container)",transition:"all 0.3s ease",margin:"16px 0"},children:[X.jsx("div",{style:{fontWeight:"500",color:Z?"#3b82f6":"#374151"},children:Z?"Drop components here":"Empty Section"}),X.jsx("div",{style:{fontSize:"12px",color:"#9ca3af"},children:"Drag and drop components here to create your section"})]}):q.map(t=>X.jsx(bt,{child:t,selectedChild:f||null,mode:i,onChildSelect:rt,onChildDelete:nt,renderFormComponent:gt,isChildrenEditMode:Y,formData:s,formTemplateId:g,onNotesChange:w,onAttachmentChange:B,onThresholdActionCompletion:m,onThresholdIssueRaised:v,workOrderNumber:b,assetNumber:y,user:C,onCreateIssue:x,onUpdateIssue:U},t.id))})})]})},Ct=({component:t,selectedComponent:e,mode:A,onComponentSelect:r,onComponentDelete:n,onComponentEdit:i,renderFormComponent:s,isOverlay:a=!1,formData:o={},formTemplateId:l,onThresholdActionCompletion:c,onThresholdIssueRaised:u,onNotesChange:h,onAttachmentChange:d,workOrderNumber:f,assetNumber:p,user:g,onCreateIssue:m,onUpdateIssue:v})=>{var w,B;const b=o[t.id],y="preview"===A&&((null===(w=t.basic)||void 0===w?void 0:w.notes)&&t.basic.notes.trim().length>0||(null===(B=t.basic)||void 0===B?void 0:B.attachments)&&Array.isArray(t.basic.attachments)&&t.basic.attachments.length>0),{attributes:C,listeners:x,setNodeRef:F,transform:Q,transition:S,isDragging:L,isSorting:I}=j({id:t.id,disabled:a}),_={transform:P.Transform.toString(Q),transition:S,opacity:L?.3:1,zIndex:L?1e3:"auto"};return X.jsxs("div",{ref:F,style:Object.assign(Object.assign({},_),{border:(null==e?void 0:e.id)===t.id?"2px solid #3b82f6":"1px solid var(--df-color-fb-border)",borderRadius:"8px",backgroundColor:"var(--df-color-fb-container)",padding:"12px",position:"relative",minHeight:"80px",transition:"all 0.2s ease",boxShadow:(null==e?void 0:e.id)===t.id?"0 4px 12px rgba(59, 130, 246, 0.15)":"0 1px 3px rgba(0, 0, 0, 0.1)",cursor:"pointer"}),className:`form-component grid-component ${(null==e?void 0:e.id)===t.id?"selected":""} ${L?"dragging":""} ${I?"sorting":""}`,onClick:()=>!L&&r(t),role:"button",tabIndex:0,children:["edit"===A&&X.jsx("div",Object.assign({className:"component-drag-handle"},x,C,{onClick:t=>t.stopPropagation(),style:{position:"absolute",top:"50%",left:"4px",transform:"translateY(-50%)",padding:"4px",backgroundColor:"#f3f4f6",borderRadius:"4px",cursor:"grab",opacity:1,zIndex:10,display:"flex",alignItems:"center",justifyContent:"center"},children:X.jsx(U,{size:12,color:"var(--df-color-text-light)"})})),X.jsxs("div",{className:"component-content",style:{paddingTop:"edit"===A?"24px":"0",paddingLeft:"edit"===A?"28px":"0",minHeight:"60px"},children:[s(t),!["section","table","heading","file","instructions","signature","location","datagrid"].includes(t.name)&&X.jsx(vt,{component:t,mode:"test",formTemplateId:l,formValue:b,formData:o,onThresholdActionCompletion:c,onThresholdIssueRaised:u,onNotesChange:h?e=>h(t.id,e):void 0,onAttachmentChange:d?e=>d(t.id,e):void 0,workOrderNumber:f,assetNumber:p,user:g,onCreateIssue:m,onUpdateIssue:v}),y&&X.jsx(Bt,{component:t})]}),"edit"===A&&X.jsxs("div",{className:"component-actions",style:{position:"absolute",top:"4px",right:"4px",display:"flex",gap:"4px",opacity:1,zIndex:10},children:[i&&X.jsx("button",{className:"component-edit-btn",onClick:e=>{e.stopPropagation(),i(t)},type:"button",title:"Edit Component",style:{padding:"4px",backgroundColor:"#3b82f6",color:"#ffffff",border:"none",borderRadius:"4px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s ease"},onMouseEnter:t=>{t.currentTarget.style.backgroundColor="#2563eb"},onMouseLeave:t=>{t.currentTarget.style.backgroundColor="#3b82f6"},children:X.jsx(E,{size:12})}),X.jsx("button",{className:"component-delete-btn",onClick:e=>{e.stopPropagation(),n(t,e)},type:"button",title:"Delete Component",style:{padding:"4px",backgroundColor:"#ef4444",color:"#ffffff",border:"none",borderRadius:"4px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s ease"},onMouseEnter:t=>{t.currentTarget.style.backgroundColor="#dc2626"},onMouseLeave:t=>{t.currentTarget.style.backgroundColor="#ef4444"},children:X.jsx(N,{size:12})})]})]})},xt=({gridComponents:t,mode:e,onComponentSelect:A,onComponentDelete:r,onComponentEdit:n,onComponentUpdate:i,selectedComponent:s,renderFormComponent:a,gridId:o,formData:l={},formTemplateId:c,onThresholdActionCompletion:u,onThresholdIssueRaised:h,onNotesChange:d,onAttachmentChange:f,workOrderNumber:p,assetNumber:g,user:m,onCreateIssue:v,onUpdateIssue:w})=>{const{setNodeRef:B,isOver:b}=O({id:`grid-drop-zone-${o}`,disabled:"edit"!==e});return X.jsx("div",{ref:B,className:"grid-drop-zone",style:{border:b?"2px dashed #3b82f6":"2px dashed #d1d5db",borderRadius:"8px",padding:"16px",backgroundColor:b?"var(--df-color-primary-light)":"var(--df-color-fb-container)",minHeight:"120px",transition:"all 0.2s ease",position:"relative"},children:t.length>0?X.jsxs(X.Fragment,{children:[X.jsx(k,{items:t.map(t=>t.id),strategy:H,children:X.jsx("div",{style:{display:"flex",flexDirection:"row",flexWrap:"nowrap",gap:"12px",alignItems:"start",marginBottom:t.length>0?"12px":"0",overflowX:"auto",width:"100%"},children:t.map(t=>X.jsx("div",{style:{flex:"1 1 0",minWidth:"200px",maxWidth:"100%"},children:X.jsx(Ct,{component:t,selectedComponent:s,mode:e,onComponentSelect:A,onComponentDelete:r,onComponentEdit:n,onComponentUpdate:i,renderFormComponent:a,formData:l,formTemplateId:c,onThresholdActionCompletion:u,onThresholdIssueRaised:h,onNotesChange:d,onAttachmentChange:f,workOrderNumber:p,assetNumber:g,user:m,onCreateIssue:v,onUpdateIssue:w})},t.id))})}),X.jsx("div",{style:{border:b?"2px dashed #3b82f6":"1px dashed var(--df-color-fb-border)",borderRadius:"6px",padding:"12px",backgroundColor:b?"var(--df-color-primary-light)":"var(--df-color-fb-container)",textAlign:"center",color:"var(--df-color-text-light)",fontSize:"12px",transition:"all 0.2s ease",minHeight:"40px",display:"flex",alignItems:"center",justifyContent:"center"},children:b?X.jsx("span",{style:{color:"#3b82f6",fontWeight:"500"},children:"Drop component here to add to grid"}):X.jsx("span",{children:"+ Drop more components here"})})]}):X.jsxs("div",{style:{textAlign:"center",color:"var(--df-color-text-light)",fontSize:"14px",padding:"40px 20px",display:"flex",flexDirection:"column",alignItems:"center",gap:"8px",backgroundColor:"var(--df-color-fb-container)",border:"1px dashed var(--df-color-fb-border)",borderRadius:"8px"},children:[X.jsx("div",{style:{fontWeight:"500",color:b?"var(--df-color-primary)":"var(--df-color-text-dark)"},children:b?"Drop components here":"Empty DataGrid"}),X.jsx("div",{style:{fontSize:"12px",color:"#9ca3af"},children:"Drag and drop components here to create your grid"})]})})},Ft=({templateComponents:t,dataEntries:e,renderFormComponent:A,renderComponent:r,mode:n="preview",allowAddRemoveEntries:i=!0,addAnotherText:s="Add Another",removeText:a="Remove",maxEntries:o=10,minEntries:l=1,displayAsGrid:c=!0,onAddEntry:u,onRemoveEntry:h,formData:d={},formTemplateId:f,onThresholdActionCompletion:p,onThresholdIssueRaised:g,onNotesChange:m,onAttachmentChange:v,datagridId:w="",workOrderNumber:B,assetNumber:b,user:y,onCreateIssue:C,onUpdateIssue:x})=>0===t.length?X.jsxs("div",{style:{textAlign:"center",padding:"40px",color:"var(--df-color-text-light)",border:"1px dashed #d1d5db",borderRadius:"8px",backgroundColor:"var(--df-color-fb-container)"},children:["No components defined. Add components to see the ",c?"table":"list"," view."]}):c?X.jsxs("div",{className:"datagrid-table-view",style:{border:"1px solid var(--df-color-fb-border)",borderRadius:"8px",overflow:"hidden",backgroundColor:"var(--df-color-fb-container)",maxWidth:"100%"},children:[X.jsx("div",{style:{position:"absolute",top:"8px",right:"8px",zIndex:10,fontSize:"12px",color:"var(--df-color-text-light)",backgroundColor:"var(--df-color-fb-container)",padding:"4px 8px",borderRadius:"4px",border:"1px solid var(--df-color-fb-border)",opacity:t.length>4?1:0,transition:"opacity 0.2s ease"},children:"← Scroll →"}),X.jsxs("div",{className:"table-scroll-container",style:{overflowX:"auto",overflowY:"hidden",maxWidth:"100%",scrollbarWidth:"thin",scrollbarColor:"var(--df-color-fb-border) var(--df-color-fb-icon-bg)",position:"relative"},children:[X.jsx("div",{className:"table-headers",style:{display:"grid",gridTemplateColumns:`repeat(${t.length}, minmax(150px, 1fr))`,backgroundColor:"var(--df-color-fb-container)",borderBottom:"2px solid var(--df-color-fb-border)",minWidth:150*t.length+"px"},children:t.map((e,A)=>{var r;return X.jsx("div",{style:{padding:"12px 16px",fontWeight:"600",color:"var(--df-color-text-dark)",borderRight:A<t.length-1?"1px solid var(--df-color-fb-border)":"none",fontSize:"14px",minWidth:"150px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:(null===(r=e.basic)||void 0===r?void 0:r.label)||`Column ${A+1}`},`header-${e.id}`)})}),e.length>0?e.map((s,o)=>X.jsxs("div",{className:"table-row",style:{display:"grid",gridTemplateColumns:`repeat(${t.length}, minmax(150px, 1fr))`,borderBottom:o<e.length-1?"1px solid var(--df-color-fb-border)":"none",backgroundColor:o%2==0?"var(--df-color-fb-container)":"var(--df-color-fb-bg)",position:"relative",minWidth:150*t.length+"px",isolation:"isolate"},children:[t.map((e,i)=>{var a,l,c,u,h,F,Q;let U=null===(a=s.components)||void 0===a?void 0:a[i];const E=`${e.id||`component-${i}`}-entry-${w}-${o}-${i}`;return U=U?U.id!==E?Object.assign(Object.assign({},U),{id:E,basic:Object.assign(Object.assign({},U.basic),{showLabel:!1})}):Object.assign(Object.assign({},U),{id:U.id,basic:Object.assign(Object.assign({},U.basic),{showLabel:!1})}):Object.assign(Object.assign({},e),{id:E,basic:Object.assign(Object.assign({},e.basic),{showLabel:!1,defaultValue:void 0,value:void 0})}),X.jsxs("div",{style:{padding:"12px 16px",borderRight:i<t.length-1?"1px solid var(--df-color-fb-border)":"none",minHeight:"60px",minWidth:"150px",display:"flex",flexDirection:"column",alignItems:"flex-start",justifyContent:"center",overflow:"visible",position:"relative",zIndex:1},children:[X.jsx("div",{style:{width:"100%",minWidth:"120px",overflow:"hidden",position:"relative",zIndex:1},children:r?r(U,!0):A(U,!0)}),!["section","table","heading","file","instructions","signature","location","datagrid"].includes(U.name)&&X.jsxs("div",{style:{marginTop:"8px",width:"100%"},children:[X.jsx(vt,{component:U,mode:"test",formTemplateId:f,formValue:d[U.id],formData:d,onThresholdActionCompletion:p,onThresholdIssueRaised:g,onNotesChange:m?t=>m(U.id,t):void 0,onAttachmentChange:v?t=>v(U.id,t):void 0,notes:(null===(l=U.basic)||void 0===l?void 0:l.notes)||(null===(c=d[U.id])||void 0===c?void 0:c.notes),attachments:(null===(u=U.basic)||void 0===u?void 0:u.attachments)||(null===(h=d[U.id])||void 0===h?void 0:h.attachments),workOrderNumber:B,assetNumber:b,user:y,onCreateIssue:C,onUpdateIssue:x}),"preview"===n&&((null===(F=U.basic)||void 0===F?void 0:F.notes)||(null===(Q=U.basic)||void 0===Q?void 0:Q.attachments))&&X.jsx(Bt,{component:U})]})]},`${s.id}-${i}`)}),i&&e.length>l&&X.jsx("button",{type:"button",onClick:t=>{if(t.preventDefault(),t.stopPropagation(),!(e.length<=l)&&h)try{h(o)}catch(t){console.error("Error removing entry:",t)}},disabled:e.length<=l,style:{position:"absolute",top:"8px",right:"8px",padding:"4px 8px",backgroundColor:e.length<=l?"#f3f4f6":"#ef4444",color:e.length<=l?"#9ca3af":"#ffffff",border:"none",borderRadius:"4px",fontSize:"12px",fontWeight:"500",cursor:e.length<=l?"not-allowed":"pointer",display:"flex",alignItems:"center",gap:"4px",zIndex:1e3,minWidth:"24px",height:"24px",justifyContent:"center",transition:"all 0.2s ease",pointerEvents:"auto"},title:a,onMouseEnter:t=>{e.length>l&&(t.currentTarget.style.backgroundColor="#dc2626")},onMouseLeave:t=>{e.length>l&&(t.currentTarget.style.backgroundColor="#ef4444")},children:X.jsx("span",{style:{fontSize:"14px"},children:"×"})})]},s.id)):X.jsxs("div",{style:{padding:"40px",textAlign:"center",color:"var(--df-color-text-light)",backgroundColor:"var(--df-color-fb-container)",borderTop:"1px solid var(--df-color-fb-border)"},children:["No data entries. ",i?'Click "Add Another" to add entries.':"Use the properties panel to add entries."]})]}),i&&X.jsx("div",{style:{padding:"16px",backgroundColor:"var(--df-color-fb-bg)",borderTop:"1px solid var(--df-color-fb-border)",display:"flex",justifyContent:"center",position:"sticky",bottom:0,zIndex:5},children:X.jsxs("button",{type:"button",onClick:t=>{if(t.preventDefault(),t.stopPropagation(),!(e.length>=o)&&u)try{u()}catch(t){console.error("Error adding entry:",t)}},disabled:e.length>=o,style:{padding:"8px 16px",backgroundColor:e.length>=o?"#f3f4f6":"#10b981",color:e.length>=o?"#9ca3af":"#ffffff",border:"none",borderRadius:"6px",fontSize:"14px",fontWeight:"500",cursor:e.length>=o?"not-allowed":"pointer",display:"flex",alignItems:"center",gap:"6px",transition:"all 0.2s ease",pointerEvents:"auto",zIndex:1e3},onMouseEnter:t=>{e.length<o&&(t.currentTarget.style.backgroundColor="#059669")},onMouseLeave:t=>{e.length<o&&(t.currentTarget.style.backgroundColor="#10b981")},children:[X.jsx("span",{style:{fontSize:"16px"},children:"+"}),s]})})]}):X.jsxs("div",{className:"datagrid-list-view",style:{display:"flex",flexDirection:"column",gap:"12px",backgroundColor:"var(--df-color-fb-container)"},children:[e.length>0?e.map((s,o)=>X.jsxs("div",{className:"list-entry",style:{border:"1px solid var(--df-color-fb-border)",borderRadius:"8px",padding:"16px",backgroundColor:"var(--df-color-fb-container)",position:"relative",transition:"all 0.2s ease"},children:[X.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",paddingBottom:"8px",borderBottom:"1px solid var(--df-color-fb-border)"},children:[X.jsxs("span",{style:{fontWeight:"600",color:"var(--df-color-text-dark)",fontSize:"14px"},children:["Entry #",o+1]}),i&&e.length>1&&X.jsx("button",{type:"button",onClick:t=>{if(t.preventDefault(),t.stopPropagation(),!(e.length<=l)&&h)try{h(o)}catch(t){console.error("Error removing entry:",t)}},disabled:e.length<=l,style:{padding:"4px 8px",backgroundColor:e.length<=l?"#f3f4f6":"#ef4444",color:e.length<=l?"#9ca3af":"#ffffff",border:"none",borderRadius:"4px",fontSize:"12px",fontWeight:"500",cursor:e.length<=l?"not-allowed":"pointer",display:"flex",alignItems:"center",gap:"4px",minWidth:"24px",height:"24px",justifyContent:"center",transition:"all 0.2s ease",pointerEvents:"auto",zIndex:1e3},title:a,onMouseEnter:t=>{e.length>l&&(t.currentTarget.style.backgroundColor="#dc2626")},onMouseLeave:t=>{e.length>l&&(t.currentTarget.style.backgroundColor="#ef4444")},children:X.jsx("span",{style:{fontSize:"14px"},children:"×"})})]}),X.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:"16px"},children:t.map((t,e)=>{var i,a,l;let c=null===(i=s.components)||void 0===i?void 0:i[e];const u=`${t.id||`component-${e}`}-entry-${w}-${o}-${e}`;return c||(c=null===(a=s.components)||void 0===a?void 0:a.find(e=>{var A,r;return e.name===t.name&&(null===(A=e.basic)||void 0===A?void 0:A.label)===(null===(r=t.basic)||void 0===r?void 0:r.label)})),c=c?c.id!==u?Object.assign(Object.assign({},c),{id:u,basic:Object.assign(Object.assign({},c.basic),{showLabel:!1})}):Object.assign(Object.assign({},c),{id:c.id,basic:Object.assign(Object.assign({},c.basic),{showLabel:!1})}):Object.assign(Object.assign({},t),{id:u,basic:Object.assign(Object.assign({},t.basic),{showLabel:!1,defaultValue:void 0,value:void 0})}),X.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[X.jsx("label",{style:{fontSize:"12px",fontWeight:"500",color:"var(--df-color-text-light)",textTransform:"uppercase",letterSpacing:"0.05em"},children:(null===(l=t.basic)||void 0===l?void 0:l.label)||`Field ${e+1}`}),X.jsxs("div",{style:{minHeight:"40px",display:"flex",alignItems:"center",flexDirection:"column",width:"100%"},children:[r?r(c):A(c),!["section","table","heading","file","instructions","signature","location","datagrid"].includes(c.name)&&X.jsx(vt,{component:c,mode:"test",formTemplateId:f,formValue:d[c.id],onThresholdActionCompletion:p,onThresholdIssueRaised:g,onNotesChange:m?t=>m(c.id,t):void 0,onAttachmentChange:v?t=>v(c.id,t):void 0}),"preview"===n&&(()=>{var t,e;return(null===(t=c.basic)||void 0===t?void 0:t.notes)&&c.basic.notes.trim().length>0||(null===(e=c.basic)||void 0===e?void 0:e.attachments)&&Array.isArray(c.basic.attachments)&&c.basic.attachments.length>0?X.jsx(Bt,{component:c}):null})()]})]},`${s.id}-${e}`)})})]},s.id)):X.jsxs("div",{style:{padding:"40px",textAlign:"center",color:"var(--df-color-text-light)",backgroundColor:"var(--df-color-fb-container)",border:"1px dashed #d1d5db",borderRadius:"8px"},children:["No data entries. ",i?'Click "Add Another" to add entries.':"Use the properties panel to add entries."]}),"test"===n&&i&&X.jsx("div",{style:{padding:"16px",backgroundColor:"#f8f9fa",border:"1px solid var(--df-color-fb-border)",borderRadius:"8px",display:"flex",justifyContent:"center"},children:X.jsxs("button",{type:"button",onClick:t=>{if(t.preventDefault(),t.stopPropagation(),!(e.length>=o)&&u)try{u()}catch(t){console.error("Error adding entry:",t)}},disabled:e.length>=o,style:{padding:"8px 16px",backgroundColor:e.length>=o?"#f3f4f6":"#10b981",color:e.length>=o?"#9ca3af":"#ffffff",border:"none",borderRadius:"6px",fontSize:"14px",fontWeight:"500",cursor:e.length>=o?"not-allowed":"pointer",display:"flex",alignItems:"center",gap:"8px",transition:"all 0.2s ease",pointerEvents:"auto",zIndex:1e3},onMouseEnter:t=>{e.length<o&&(t.currentTarget.style.backgroundColor="#059669")},onMouseLeave:t=>{e.length<o&&(t.currentTarget.style.backgroundColor="#10b981")},children:[X.jsx("span",{children:"+"}),s]})})]}),Qt=({id:t,properties:i,mode:s="edit",formData:a={},validationErrors:o={},touchedFields:l={},formSubmitted:c=!1,onValueChange:u,onSelect:h,isSelected:d=!1,className:f="",onDataGridSelect:p,onComponentSelect:g,onComponentDelete:m,onComponentEdit:v,onComponentUpdate:w,selectedComponent:B,renderFormComponent:b,onEntryAdd:y,onEntryRemove:C,formTemplateId:x,onThresholdActionCompletion:U,onThresholdIssueRaised:E,onNotesChange:N,onAttachmentChange:L,workOrderNumber:I,assetNumber:_,onCreateIssue:O,onUpdateIssue:k})=>{var T,j,H,P,D,M,R,K,V,z,G,q;const[W,Y]=e(!1),J=n(!1);let $=i.templateComponents||[];const Z=i.entries||[];0===$.length&&Z.length>0&&Z[0].components&&($=Z[0].components.map(t=>{var e;return Object.assign(Object.assign({},t),{id:(null===(e=t.id)||void 0===e?void 0:e.replace(/-entry-\d+$/,""))||t.id,basic:Object.assign(Object.assign({},t.basic),{showLabel:!0})})})),A(()=>{if("edit"===s&&!i.templateComponents&&u&&J.current){const e=Object.assign(Object.assign({},i),{templateComponents:[]});JSON.stringify(e)!==JSON.stringify(i)&&u({id:t,value:e})}J.current=!0},[i.templateComponents,t,u,i,s]),A(()=>{if($.length>0){if("test"===s&&0===Z.length&&J.current){const e={id:`entry-${t}-0`,index:0,components:$.map((e,A)=>{const r=e.id||`component-${A}`;return Object.assign(Object.assign({},e),{id:`${r}-entry-${t}-0-${A}`,basic:Object.assign(Object.assign({},e.basic),{showLabel:!1,defaultValue:void 0,value:void 0})})}),styles:{}};if(u){const A=Object.assign(Object.assign({},i),{entries:[e]});JSON.stringify(A)!==JSON.stringify(i)&&u({id:t,value:A})}return}if("edit"!==s||!J.current)return;const e=Z.some(t=>{var e;return null===(e=t.components)||void 0===e?void 0:e.some((e,A)=>{var r;const n=`${null===(r=$[A])||void 0===r?void 0:r.id}-entry-${t.index}-${A}`;return e.id!==n})});if(e&&u){const e=Z.map(t=>{var e;return Object.assign(Object.assign({},t),{components:(null===(e=t.components)||void 0===e?void 0:e.map((e,A)=>{var r;return Object.assign(Object.assign({},e),{id:`${null===(r=$[A])||void 0===r?void 0:r.id}-entry-${t.index}-${A}`})}))||[]})}),A=Object.assign(Object.assign({},i),{entries:e});return void(JSON.stringify(A)!==JSON.stringify(i)&&u({id:t,value:A}))}if(0===Z.length&&"edit"===s){const e={id:`entry-${t}-0`,index:0,components:$.map((e,A)=>{const r=e.id||`component-${A}`;return Object.assign(Object.assign({},e),{id:`${r}-entry-${t}-0-${A}`,basic:Object.assign(Object.assign({},e.basic),{showLabel:!1,defaultValue:void 0,value:void 0})})}),styles:{}};if(u){const A=Object.assign(Object.assign({},i),{entries:[e]});JSON.stringify(A)!==JSON.stringify(i)&&u({id:t,value:A})}}else if(Z.length>0){const e=Z.some(t=>$.some((e,A)=>{var r,n,i,s,a,o,l,c,u,h,d;const f=null===(r=t.components)||void 0===r?void 0:r[A];if(!f)return!0;const p=`${e.id}-entry-${t.index}-${A}`,g=f.id===p,m=JSON.stringify(null===(n=f.basic)||void 0===n?void 0:n.options)!==JSON.stringify(null===(i=e.basic)||void 0===i?void 0:i.options)||(null===(s=f.basic)||void 0===s?void 0:s.placeholder)!==(null===(a=e.basic)||void 0===a?void 0:a.placeholder)||(null===(o=f.basic)||void 0===o?void 0:o.defaultValue)!==(null===(l=e.basic)||void 0===l?void 0:l.defaultValue)||(null===(c=f.basic)||void 0===c?void 0:c.label)!==(null===(u=e.basic)||void 0===u?void 0:u.label)||(null===(h=f.validation)||void 0===h?void 0:h.required)!==(null===(d=e.validation)||void 0===d?void 0:d.required);return!g||m}));if(e&&u){const e=Z.map(e=>{const A=$.map((A,r)=>{var n,i;let s=null===(n=e.components)||void 0===n?void 0:n[r];s||(s=null===(i=e.components)||void 0===i?void 0:i.find(t=>{var e,r;return t.name===A.name&&(null===(e=t.basic)||void 0===e?void 0:e.label)===(null===(r=A.basic)||void 0===r?void 0:r.label)}));const a=`${A.id||`component-${r}`}-entry-${t}-${e.index}-${r}`;if(s){return Object.assign(Object.assign({},A),{id:a,basic:Object.assign(Object.assign({},A.basic),{showLabel:!1,defaultValue:void 0,value:void 0})})}return Object.assign(Object.assign({},A),{id:a,basic:Object.assign(Object.assign({},A.basic),{showLabel:!1,defaultValue:void 0,value:void 0})})});return Object.assign(Object.assign({},e),{components:A})}),A=Object.assign(Object.assign({},i),{entries:e});JSON.stringify(A)!==JSON.stringify(i)&&u({id:t,value:A})}}}},[$,Z,t,u,i,s,i.templateComponents]);const tt=r(t=>{t.stopPropagation(),null==h||h(),null==p||p(i)},[h,p,i]),et=r((e,A)=>{A.stopPropagation(),m&&m(e,A);const r=$.filter(t=>t.id!==e.id),n=Z.map(t=>{var A;return Object.assign(Object.assign({},t),{components:(null===(A=t.components)||void 0===A?void 0:A.filter(t=>{var A,r;return!(t.name===e.name&&(null===(A=t.basic)||void 0===A?void 0:A.label)===(null===(r=e.basic)||void 0===r?void 0:r.label))}))||[]})});u&&u({id:t,value:Object.assign(Object.assign({},i),{templateComponents:r,entries:n})})},[m,i,u,t,$,Z]),At=r((e,A)=>{w&&w(e,A);const r=$.map(t=>t.id===e?Object.assign(Object.assign({},t),A):t);u&&u({id:t,value:Object.assign(Object.assign({},i),{templateComponents:r})})},[w,i,u,t,$]),rt=r(t=>{"test"===s&&u&&u({id:t.id,value:t.value})},[u]),nt=r(()=>{const e=i.entries||[],A=e.length,r={id:`entry-${t}-${A}`,index:A,components:$.map((e,r)=>{const n=`${e.id||`component-${r}`}-entry-${t}-${A}-${r}`;return Object.assign(Object.assign({},e),{id:n,basic:Object.assign(Object.assign({},e.basic),{showLabel:!1,defaultValue:void 0,value:void 0})})}),styles:{}},n=[...e,r];u&&u({id:t,value:Object.assign(Object.assign({},i),{entries:n})}),null==y||y()},[i,u,t,y,$]),ct=r(e=>{const A=i.entries.filter((t,A)=>A!==e).map((e,A)=>Object.assign(Object.assign({},e),{index:A,id:`entry-${t}-${A}`}));u&&u({id:t,value:Object.assign(Object.assign({},i),{entries:A})})},[i,u,t,C]),dt=r((t,e=!1)=>{var A,r,n;const i=a[t.id]||"defaultValue"in t.basic&&t.basic.defaultValue||"";let u=i;"number-input"===t.name&&"number"==typeof i?u=String(i):"number-input"===t.name&&null==i&&(u="");const h={id:t.id,properties:t,validationErrors:o||{},formValue:u,touchedFields:l||{},formSubmitted:c||!1,mode:s,hideLabel:e,onValueChange:rt,onBlur:()=>{},onFocus:()=>{}};switch(t.name){case"text-input":case"email-input":case"number-input":return X.jsx(it,Object.assign({},h,{properties:t,inputType:"text-input"===t.name?"text":"number-input"===t.name?"number":"email",readonly:!1,disabled:!1,hideLabel:e}));case"textarea":return X.jsx(st,Object.assign({},h,{properties:t,readonly:!1,disabled:!1,hideLabel:e}));case"select":const i=Object.assign(Object.assign({},t),{options:(null===(A=t.basic)||void 0===A?void 0:A.options)||[]});return X.jsx(at,Object.assign({},h,{properties:i,disabled:!1,hideLabel:e}));case"checkbox":const s=Object.assign(Object.assign({},t),{options:(null===(r=t.basic)||void 0===r?void 0:r.options)||[]});return X.jsx(ot,Object.assign({},h,{properties:s,formValue:[],disabled:!1,hideLabel:e}));case"radio":const a=Object.assign(Object.assign({},t),{options:(null===(n=t.basic)||void 0===n?void 0:n.options)||[]});return X.jsx(lt,Object.assign({},h,{properties:a,readonly:!1,disabled:!1,hideLabel:e}));case"date":case"date-picker":case"datetime-picker":return X.jsx(ut,Object.assign({},h,{properties:t,readonly:!1,disabled:!1,hideLabel:e}));case"signature":return X.jsx(ht,Object.assign({},h,{properties:t,hideLabel:e}));case"heading":return X.jsx(pt,Object.assign({},h,{properties:t,hideLabel:e}));case"instructions":return X.jsx(gt,Object.assign({},h,{properties:t,hideLabel:e}));default:return X.jsxs("div",{className:"unknown-component",children:["Unknown component: ",t.name]})}},[s,rt,a,o,l,c]),ft={backgroundColor:i.styles.backgroundColor||"var(--df-color-fb-container)",borderColor:i.styles.borderColor||"var(--df-color-fb-border)",borderWidth:i.styles.borderWidth||"2px",borderRadius:i.styles.borderRadius||"8px",padding:i.styles.padding||"16px",margin:i.styles.margin||"16px 0"};return X.jsxs("div",{className:`form-group df-form-datagrid ${d?"selected":""} ${f}`,onClick:tt,style:ft,children:[X.jsx("div",{className:"grid-header",children:X.jsx("div",{className:"grid-title",onClick:e=>{e.stopPropagation(),Y(!W),null==u||u({id:t,value:Object.assign(Object.assign({},i),{basic:Object.assign(Object.assign({},i.basic),{collapsed:!W})})})},children:X.jsxs("div",{className:"title-content",style:{display:"flex",alignItems:"center",gap:"8px"},children:[W?X.jsx(Q,{size:16}):X.jsx(F,{size:16}),X.jsx(S,{size:16}),X.jsx("span",{className:"grid-label",style:{fontWeight:"600"},children:i.basic.label}),i.validation.required&&X.jsx("span",{className:"required-indicator",style:{color:"#ef4444"},children:"*"})]})})}),i.basic.description&&!W&&X.jsx("div",{className:"grid-description",style:{marginTop:"8px",color:"var(--df-color-text-light)",fontSize:"14px"},children:i.basic.description}),!W&&X.jsx("div",{className:"grid-content",style:{marginTop:"16px"},children:"edit"===s?X.jsx(xt,{gridComponents:$,mode:s,onComponentSelect:g||(()=>{}),onComponentDelete:et,onComponentEdit:v,onComponentUpdate:At,selectedComponent:B||null,renderFormComponent:b||dt,gridId:t,formData:a,formTemplateId:x,onThresholdActionCompletion:U,onThresholdIssueRaised:E,onNotesChange:N,onAttachmentChange:L,workOrderNumber:I,assetNumber:_,user:user,onCreateIssue:O,onUpdateIssue:k}):X.jsx(Ft,{templateComponents:$,dataEntries:Z,renderFormComponent:b||dt,mode:s,allowAddRemoveEntries:null===(j=null===(T=i.datagrid)||void 0===T?void 0:T.allowAddRemoveEntries)||void 0===j||j,addAnotherText:null!==(P=null===(H=i.datagrid)||void 0===H?void 0:H.addAnotherText)&&void 0!==P?P:"Add Entry",removeText:null!==(M=null===(D=i.datagrid)||void 0===D?void 0:D.removeText)&&void 0!==M?M:"Remove",maxEntries:null!==(K=null===(R=i.datagrid)||void 0===R?void 0:R.maxEntries)&&void 0!==K?K:10,minEntries:null!==(z=null===(V=i.datagrid)||void 0===V?void 0:V.minEntries)&&void 0!==z?z:1,displayAsGrid:null===(q=null===(G=i.datagrid)||void 0===G?void 0:G.displayAsGrid)||void 0===q||q,onAddEntry:y||nt,onRemoveEntry:C||ct,formData:a,formTemplateId:x,onThresholdActionCompletion:U,onThresholdIssueRaised:E,onNotesChange:N,onAttachmentChange:L,datagridId:t,workOrderNumber:I,assetNumber:_,user:user,onCreateIssue:O,onUpdateIssue:k})})]})},Ut=t.lazy(()=>Promise.resolve().then(function(){return kt})),Et=({formComponents:i=[],currentDevice:s="desktop",isPreviewMode:a=!1,initialFormData:o=[],onSubmit:l,onFormDataChange:c,formTitle:u,formDescription:h,formTemplateId:d,onComponentSelect:f,onComponentDelete:p,onComponentEdit:g,onComponentUpdate:m,selectedComponent:v,workOrderNumber:w,assetNumber:B,isStandalone:b,user:y,onCreateIssue:C,onUpdateIssue:x})=>{const[F,Q]=e({}),[U,E]=e({}),[N,S]=e(!1),[L,I]=e({}),[_,O]=e({}),[k,T]=e(new Set),[j,H]=e(new Map),[P,D]=e({isValid:!0}),[M,R]=e({}),[K,V]=e({});A(()=>{G()},[i,o]);const z=(t,e)=>{t.forEach(t=>{if(t.id&&(void 0!==e[t.id]||(t.basic&&"value"in t.basic&&void 0!==t.basic.value&&""!==t.basic.value&&null!==t.basic.value?e[t.id]=t.basic.value:t.basic&&"defaultValue"in t.basic&&void 0!==t.basic.defaultValue&&""!==t.basic.defaultValue&&null!==t.basic.defaultValue?e[t.id]=t.basic.defaultValue:"checkbox"===t.name||"select"===t.name?e[t.id]=[]:e[t.id]="")),t.cells&&Array.isArray(t.cells)&&t.cells.forEach((t,A)=>{Array.isArray(t)&&t.forEach((t,A)=>{t&&t.components&&Array.isArray(t.components)&&z(t.components,e)})}),t.entries&&Array.isArray(t.entries)&&t.entries.forEach((t,A)=>{t&&t.components&&Array.isArray(t.components)&&z(t.components,e)}),"file"===t.name&&t.basic){const A=t.basic.files||t.basic.attachments||t.basic.value;A&&(e[t.id]=A)}if(t.id&&t.basic&&t.basic.notes,"instructions"===t.name&&t.basic){t.basic.instructions||(t.basic.instructions=[]);const A=t.basic.value||t.basic.instructions;A&&(e[t.id]=A)}t.children&&Array.isArray(t.children)&&z(t.children,e)})},G=r(()=>{const t={},e={},A={},r=new Set,n=t=>{t.forEach(t=>{var r,i,s,a,o;t.id&&(((null===(r=t.basic)||void 0===r?void 0:r.notes)||(null===(i=t.basic)||void 0===i?void 0:i.comments))&&(e[t.id]=(null===(s=t.basic)||void 0===s?void 0:s.notes)||(null===(a=t.basic)||void 0===a?void 0:a.comments)),(null===(o=t.basic)||void 0===o?void 0:o.attachments)&&(A[t.id]=t.basic.attachments)),t.children&&n(t.children),t.cells&&t.cells.forEach(t=>t.forEach(t=>{t.components&&n(t.components)})),t.entries&&t.entries.forEach(t=>{t.components&&n(t.components)})})},s=t=>{t.forEach((t,e)=>{var A;if(t.id&&"string"==typeof t.id&&""!==t.id.trim())r.has(t.id)&&(console.error(`[DfFormPreview] Duplicate component ID detected: ${t.id}. Component:`,t),t.id=`${t.id}-duplicate-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,console.warn(`[DfFormPreview] Generated new unique ID: ${t.id}`));else{const r=t.name||"component",n=((null===(A=t.basic)||void 0===A?void 0:A.label)||"").replace(/[^a-zA-Z0-9]/g,"").toLowerCase().substring(0,10);t.id=`${r}-${n||"gen"}-${Date.now()}-${Math.random().toString(36).substr(2,6)}-${e}`}r.add(t.id),t.children&&Array.isArray(t.children)&&s(t.children),t.cells&&Array.isArray(t.cells)&&t.cells.forEach(t=>{Array.isArray(t)&&t.forEach(t=>{t&&t.components&&Array.isArray(t.components)&&s(t.components)})}),t.entries&&Array.isArray(t.entries)&&t.entries.forEach(t=>{t&&t.components&&Array.isArray(t.components)&&s(t.components)})})};i&&i.length>0&&s(i),o&&o.length>0&&s(o),o&&o.length>0&&z(o,t),o&&o.length>0&&z(o,t),i&&i.length>0&&(z(i,t),n(i)),Q(e=>Object.assign(Object.assign({},t),e)),R(t=>Object.assign(Object.assign({},e),t)),V(t=>Object.assign(Object.assign({},A),t)),W()},[o,i]),q=(t,e)=>{t.forEach(t=>{if(t.id)if("table"===t.name||"datagrid"===t.name)e[t.id]=!0;else if(t.conditional){const A=J.evaluateConditionalLogic(t.conditional,i,F);e[t.id]=A.shouldShow}else e[t.id]=!0;t.cells&&Array.isArray(t.cells)&&t.cells.forEach(t=>{t.forEach(t=>{t.components&&Array.isArray(t.components)&&q(t.components,e)})}),t.entries&&Array.isArray(t.entries)&&t.entries.forEach(t=>{t.components&&Array.isArray(t.components)&&q(t.components,e)}),t.children&&Array.isArray(t.children)&&q(t.children,e)})},W=r(()=>{const t={};i&&i.length>0&&q(i,t),O(t)},[i,F]),Y=r(t=>{const e=i.find(e=>e.id===t);if(e&&("table"===e.name||"datagrid"===e.name))return!0;return!1!==_[t]},[_,i]),Z=r(t=>{if(!t.id||"string"!=typeof t.id||""===t.id.trim())return void console.error("[DfFormPreview] Invalid component ID in onFormValueChange:",t);const e=i.filter(e=>e.id===t.id);if(e.length>1)return void console.error(`[DfFormPreview] ID COLLISION DETECTED! Multiple components share ID "${t.id}":`,e.map(t=>{var e;return{id:t.id,name:t.name,label:null===(e=t.basic)||void 0===e?void 0:e.label}}));const A=F[t.id];void 0!==A&&A!==t.value&&console.log("[DfFormPreview] Updating form value:",{id:t.id,oldValue:A,newValue:t.value});const r=Object.assign(Object.assign({},F),{[t.id]:t.value});Q(r);const n=i.find(e=>e.id===t.id);if(n){const t=null==n?void 0:n.threshold;t&&t.conditions&&t.conditions.length>0&&T(e=>{const A=new Set(e);return t.conditions.forEach(t=>{A.delete(t.id)}),A})}const s=e=>e.map(e=>{var A;return e.id===t.id&&"defaultValue"in e.basic?Object.assign(Object.assign({},e),{basic:Object.assign(Object.assign({},e.basic),{value:null!==(A=t.value)&&void 0!==A?A:e.basic.defaultValue,defaultValue:t.value})}):"section"===e.name&&e.children?Object.assign(Object.assign({},e),{children:s(e.children)}):"table"===e.name&&e.cells?Object.assign(Object.assign({},e),{cells:e.cells.map(t=>t.map(t=>{const e=Object.assign({},t);return e.components&&(e.components=s(e.components)),e}))}):"datagrid"===e.name&&e.entries?Object.assign(Object.assign({},e),{entries:e.entries.map(t=>{const e=Object.assign({},t);return e.components&&(e.components=s(e.components)),e})}):e}),o=s(i);if(null==c||c(o),U[t.id]&&E(e=>Object.assign(Object.assign({},e),{[t.id]:""})),!a){if(t.isValid)return void E(e=>{const A=e[t.id];return A&&""!==A.trim()?Object.assign(Object.assign({},e),{[t.id]:""}):e});setTimeout(()=>{et(t.id)},150)}setTimeout(()=>{const t={};i.forEach(e=>{if("table"===e.name||"datagrid"===e.name)t[e.id]=!0;else if(e.conditional){const A=J.evaluateConditionalLogic(e.conditional,i,r);t[e.id]=A.shouldShow}else t[e.id]=!0}),O(t)},0)},[i,F,U,c]),tt=r((t,e)=>{for(const A of t){if(A.id===e)return A;if("section"===A.name&&A.children){const t=tt(A.children,e);if(t)return t}if("table"===A.name&&A.cells)for(const t of A.cells)for(const A of t)if(A.components){const t=tt(A.components,e);if(t)return t}if("datagrid"===A.name&&A.entries)for(const t of A.entries)if(t.components){const A=tt(t.components,e);if(A)return A}}return null},[]),et=r(t=>{if(a)return;const e=tt(i,t);if(!e)return;const A=F[t]||"";if("number-input"===e.name&&(!A||""===A)){if(e.validation.required){const A=e.validation.customValidationMessage,r=e.basic.label||"This field",n=A||`${r} is required`;E(e=>Object.assign(Object.assign({},e),{[t]:n}))}else E(e=>Object.assign(Object.assign({},e),{[t]:""}));return}let r=!1;r=Array.isArray(A)?A.length>0:"string"==typeof A?""!==A.trim():null!=A;let n="";if(e.validation.required&&!r){const t=e.validation.customValidationMessage,A=e.basic.label||"This field";n=t||`${A} is required`}else if("email-input"===e.name&&r&&!/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(A)){const t=e.validation.customValidationMessage,A=e.basic.label||"This field";n=t||`${A} must be a valid email`}else if(e.validation.minLength&&r&&A.length<e.validation.minLength){const t=e.validation.customValidationMessage,A=e.basic.label||"This field";n=t||`${A} must be at least ${e.validation.minLength} characters`}else if(e.validation.maxLength&&r&&A.length>e.validation.maxLength){const t=e.validation.customValidationMessage,A=e.basic.label||"This field";n=t||`${A} must be no more than ${e.validation.maxLength} characters`}else if("number-input"===e.name&&r){const t=String(A).trim(),r=parseFloat(t);if(!isNaN(r)){const t=e.validation;t&&"lowerLimit"in t&&void 0!==t.lowerLimit&&null!==t.lowerLimit&&0!==t.lowerLimit&&r<t.lowerLimit?n="Number is below the lower limit":t&&"upperLimit"in t&&void 0!==t.upperLimit&&null!==t.upperLimit&&0!==t.upperLimit&&r>t.upperLimit&&(n="Number is above the upper limit")}}E(e=>Object.assign(Object.assign({},e),{[t]:n}))},[i,a,F,tt]),At=r(t=>{I(e=>Object.assign(Object.assign({},e),{[t]:!0})),a||setTimeout(()=>{et(t)},0)},[a,et]),rt=r(t=>{U[t]&&E(e=>Object.assign(Object.assign({},e),{[t]:""}))},[U]),nt=r(()=>!Object.values(U).some(t=>t&&"string"==typeof t&&""!==t.trim())&&i.every(t=>{const e=F[t.id]||"";let A=!1;if(A=Array.isArray(e)?e.length>0:"string"==typeof e?""!==e.trim():null!=e,t.validation.required&&!A)return!1;if("number-input"===t.name&&A){const A=String(e).trim(),r=parseFloat(A);if(!isNaN(r)){const e=t.validation;if(e&&"lowerLimit"in e&&void 0!==e.lowerLimit&&null!==e.lowerLimit&&0!==e.lowerLimit&&r<e.lowerLimit)return!1;if(e&&"upperLimit"in e&&void 0!==e.upperLimit&&null!==e.upperLimit&&0!==e.upperLimit&&r>e.upperLimit)return!1}}return!0}),[i,F,U]),mt=r((t,e)=>{if(Array.isArray(e))return e.some(e=>mt(t,e));if(null==e||""===e)return!1;const A="string"==typeof e?parseFloat(e):e,r="string"==typeof t.value?parseFloat(t.value):t.value;if(!isNaN(A)&&!isNaN(r))switch(t.operator){case"greaterThan":return A>r;case"lessThan":return A<r;case"greaterThanOrEqual":return A>=r;case"lessThanOrEqual":return A<=r;case"equals":return A===r;case"notEquals":return A!==r;default:return!1}const n=String(e).toLowerCase(),i=String(t.value).toLowerCase();switch(t.operator){case"equals":return n===i||String(e)===String(t.value);case"notEquals":return n!==i&&String(e)!==String(t.value);default:return!1}},[]),wt=r(()=>{if(a)return[];const t=[];return i.forEach(e=>{const A=null==e?void 0:e.condition;if(!A||!A.conditions||0===A.conditions.length)return;const r=F[e.id];null!=r&&""!==r&&!(Array.isArray(r)&&0===r.length)&&A.conditions.forEach(A=>{var n;mt(A,r)&&t.push({componentId:e.id,condition:A,componentLabel:(null===(n=e.basic)||void 0===n?void 0:n.label)||"Field"})})}),t},[i,F,a,mt]),bt=r(()=>{if(a)return{isValid:!0};const t=wt();if(0===t.length)return{isValid:!0};for(const{condition:e,componentLabel:A}of t){const t=j.get(e.id)||{notesCompleted:!1,attachmentsCompleted:!1,emailSent:!1},r=[];if(!0!==e.enableRaiseIssue||k.has(e.id)||r.push("raise an issue"),!0!==e.enableNotes||t.notesCompleted||r.push("add notes"),!0!==e.enableAttachment||t.attachmentsCompleted||r.push("add attachments"),!0!==e.enableSendEmail||t.emailSent||r.push("send email"),r.length>0){return{isValid:!1,errorMessage:`Please ${1===r.length?r[0]:r.slice(0,-1).join(", ")+" and "+r[r.length-1]} for the threshold condition met in "${A}". You cannot submit the form until all required actions are completed.`}}}return{isValid:!0}},[a,wt,k,j]),Ct=r(t=>{t&&T(e=>{const A=new Set(e);return A.add(t),A})},[]),xt=r((t,e,A)=>{t&&H(r=>{const n=new Map(r),i=n.get(t)||{notesCompleted:!1,attachmentsCompleted:!1,emailSent:!1};return"notes"===e?n.set(t,Object.assign(Object.assign({},i),{notesCompleted:A})):"attachments"===e?n.set(t,Object.assign(Object.assign({},i),{attachmentsCompleted:A})):"email"===e&&n.set(t,Object.assign(Object.assign({},i),{emailSent:A})),n})},[]);A(()=>{if(!a){const t=bt();D(t)}},[F,k,j,a,bt]);const Ft=r(()=>{if(a)return!0;let t=!0;S(!0);const e={};return i.forEach(A=>{const r=F[A.id]||"";let n=!1;if(n=Array.isArray(r)?r.length>0:"string"==typeof r?""!==r.trim():null!=r,A.validation.required&&!n){const r=A.validation.customValidationMessage,n=A.basic.label||"This field",i=r||`${n} is required`;e[A.id]=i,t=!1}else if("number-input"===A.name&&n){const n=String(r).trim(),i=parseFloat(n);if(isNaN(i))e[A.id]="";else{const r=A.validation;r&&"lowerLimit"in r&&void 0!==r.lowerLimit&&null!==r.lowerLimit&&0!==r.lowerLimit&&i<r.lowerLimit?(e[A.id]="Number is below the lower limit",t=!1):r&&"upperLimit"in r&&void 0!==r.upperLimit&&null!==r.upperLimit&&0!==r.upperLimit&&i>r.upperLimit?(e[A.id]="Number is above the upper limit",t=!1):e[A.id]=""}}else e[A.id]="";I(t=>Object.assign(Object.assign({},t),{[A.id]:!0}))}),E(e),t},[i,a,F]),Et=r((t="Submitted")=>{if(S(!0),!Ft()){const t=i.find(t=>{const e=F[t.id]||"";let A=!1;return A=Array.isArray(e)?e.length>0:"string"==typeof e?""!==e.trim():null!=e,t.validation.required&&!A});if(t){const e=document.getElementById(t.id);e&&e.focus()}return}const e=bt();if(!e.isValid){e.errorMessage&&$.showError(e.errorMessage);const t=wt().find(({condition:t})=>!k.has(t.id));if(t){const e=document.getElementById(t.componentId);e&&e.scrollIntoView({behavior:"smooth",block:"center"})}return}const A=t=>t.map(t=>{var e,r,n,i,s,a;let o=F[t.id];"text-input"===t.name&&(null===(e=t.basic)||void 0===e||e.label),void 0===o&&(o="value"in t.basic&&void 0!==t.basic.value?t.basic.value:"defaultValue"in t.basic&&void 0!==t.basic.defaultValue?t.basic.defaultValue:""),"text-input"===t.name&&(null===(r=t.basic)||void 0===r||r.label);const l=Object.assign(Object.assign({},t),{basic:Object.assign(Object.assign({},t.basic),{value:o,defaultValue:o,notes:void 0!==M[t.id]?M[t.id]:null===(n=t.basic)||void 0===n?void 0:n.notes,comments:void 0!==M[t.id]?M[t.id]:(null===(i=t.basic)||void 0===i?void 0:i.comments)||(null===(s=t.basic)||void 0===s?void 0:s.notes),attachments:void 0!==K[t.id]?K[t.id]:null===(a=t.basic)||void 0===a?void 0:a.attachments})});return"section"===l.name&&l.children&&(l.children=A(l.children)),"table"===l.name&&l.cells&&(l.cells=l.cells.map(t=>t.map(t=>{const e=Object.assign({},t);return e.components&&(e.components=A(e.components)),e}))),"datagrid"===l.name&&l.entries&&(l.entries=l.entries.map(t=>{const e=Object.assign({},t);return e.components&&(e.components=A(e.components)),e})),l}),r=A(i),n=Object.assign(Object.assign({},F),{status:t});null==l||l(r,n)},[i,F,Ft,l,M,K]),Nt=r(()=>({[`device-${s}`]:!0,readonly:a}),[s,a]),St=r((t,e)=>{R(A=>Object.assign(Object.assign({},A),{[t]:e}))},[]),Lt=r((t,e)=>{V(A=>Object.assign(Object.assign({},A),{[t]:e||[]}))},[]),It=n(new Map),_t=n(0),Ot=e=>{var A,r,n,s,a,o,l,u,h,b,E,S,I;let _;if(e.id&&"string"==typeof e.id&&""!==e.id.trim())_=e.id;else{const t=(null===(A=e.basic)||void 0===A?void 0:A.label)||"",r=e.name||"unknown",n=`${r}-${t}`;let i=It.current.get(n);i||(_t.current+=1,i=`generated-${r}-${_t.current}-${Math.random().toString(36).substr(2,9)}`,It.current.set(n,i),console.warn("[DfFormPreview] Generated and cached ID for component:",i,"key:",n)),_=i,e=Object.assign(Object.assign({},e),{id:_})}const O=_,T=F[O];if(void 0!==T){const t=i.filter(t=>t.id!==O&&F[t.id]===T);t.length>0&&console.warn(`[DfFormPreview] Component ${O} shares form value with other components:`,t.map(t=>t.id))}const j={id:O,validationErrors:U,formValue:T,touchedFields:L,formSubmitted:N,mode:"test",readonly:!1,onValueChange:Z,onBlur:()=>At(O),onFocus:()=>rt(O)};switch(e.name){case"text-input":case"number-input":case"email-input":return X.jsx(it,Object.assign({},j,{properties:e,inputType:"text-input"===e.name?"text":"number-input"===e.name?"number":"email",formTemplateId:d,onThresholdIssueRaised:Ct,raisedThresholdIssues:k,workOrderNumber:w,assetNumber:B,user:y}));case"textarea":return X.jsx(st,Object.assign({},j,{properties:e}));case"select":const A=Object.assign(Object.assign({},e),{options:(null===(r=e.basic)||void 0===r?void 0:r.options)||[],basic:Object.assign(Object.assign({},e.basic),{comments:(null===(n=e.basic)||void 0===n?void 0:n.comments)||""})});return X.jsx(at,Object.assign({},j,{properties:A}));case"checkbox":const _=Object.assign(Object.assign({},e),{options:(null===(s=e.basic)||void 0===s?void 0:s.options)||[],basic:Object.assign(Object.assign({},e.basic),{comments:(null===(a=e.basic)||void 0===a?void 0:a.comments)||""})});return X.jsx(ot,Object.assign({},j,{properties:_}));case"radio":const O=Object.assign(Object.assign({},e),{options:(null===(o=e.basic)||void 0===o?void 0:o.options)||[],basic:Object.assign(Object.assign({},e.basic),{comments:(null===(l=e.basic)||void 0===l?void 0:l.comments)||""})});return X.jsx(lt,Object.assign({},j,{properties:O}));case"segment":const H=Object.assign(Object.assign({},e),{options:(null===(u=e.basic)||void 0===u?void 0:u.options)||[],basic:Object.assign(Object.assign({},e.basic),{comments:(null===(h=e.basic)||void 0===h?void 0:h.comments)||""})});return X.jsx(ct,Object.assign({},j,{properties:H}));case"date":case"date-picker":case"datetime-picker":return X.jsx(ut,Object.assign({},j,{properties:e}));case"signature":return X.jsx(ht,Object.assign({},j,{properties:e}));case"heading":return X.jsx(pt,Object.assign({},j,{properties:e}));case"instructions":const P=T||(null===(b=e.basic)||void 0===b?void 0:b.value)||null;return X.jsx(gt,Object.assign({},j,{properties:e,formValue:P}));case"location":return X.jsx(ft,Object.assign({},j,{properties:e}));case"section":return X.jsx(yt,Object.assign({},j,{properties:e,formData:F,formTemplateId:d,onThresholdActionCompletion:xt,onThresholdIssueRaised:Ct,onNotesChange:St,onAttachmentChange:Lt,workOrderNumber:w,assetNumber:B,user:y,onCreateIssue:C,onUpdateIssue:x,renderFormComponent:t=>Ot(t)}));case"table":return X.jsx(t.Suspense,{fallback:X.jsx("div",{children:"Loading table..."}),children:X.jsx(Ut,Object.assign({},j,{properties:e,formData:F,formTemplateId:d,mode:j.mode,validationErrors:U,touchedFields:L,formSubmitted:N,onThresholdActionCompletion:xt,onThresholdIssueRaised:Ct,workOrderNumber:w,assetNumber:B,onCreateIssue:C,onUpdateIssue:x,onNotesChange:(t,A)=>{const r=i.map(r=>{if(r.id===e.id&&r.cells){const e=r.cells.map(e=>e.map(e=>{if(e.components){const r=e.components.map(e=>e.id===t?Object.assign(Object.assign({},e),{basic:Object.assign(Object.assign({},e.basic),{notes:A})}):e);return Object.assign(Object.assign({},e),{components:r})}return e}));return Object.assign(Object.assign({},r),{cells:e})}return r});null==c||c(r)},onAttachmentChange:(t,A)=>{const r=i.map(r=>{if(r.id===e.id&&r.cells){const e=r.cells.map(e=>e.map(e=>{if(e.components){const r=e.components.map(e=>e.id===t?Object.assign(Object.assign({},e),{basic:Object.assign(Object.assign({},e.basic),{attachments:A||[]})}):e);return Object.assign(Object.assign({},e),{components:r})}return e}));return Object.assign(Object.assign({},r),{cells:e})}return r});null==c||c(r)},renderFormComponent:t=>Ot(t)}))});case"datagrid":return X.jsx(Qt,Object.assign({},j,{properties:e,formData:F,formTemplateId:d,mode:j.mode,validationErrors:U,touchedFields:L,formSubmitted:N,onThresholdActionCompletion:xt,onThresholdIssueRaised:Ct,workOrderNumber:w,assetNumber:B,user:y,onComponentSelect:f,onComponentDelete:p,onComponentEdit:g,onCreateIssue:C,onUpdateIssue:x,onComponentUpdate:m,selectedComponent:v,onNotesChange:(t,A)=>{St(t,A);const r=i.map(r=>{if(r.id===e.id&&r.entries){const e=r.entries.map(e=>{if(e.components){const r=e.components.map(e=>e.id===t?Object.assign(Object.assign({},e),{basic:Object.assign(Object.assign({},e.basic),{notes:A||""})}):e);return Object.assign(Object.assign({},e),{components:r})}return e});return Object.assign(Object.assign({},r),{entries:e})}return r});null==c||c(r)},onAttachmentChange:(t,A)=>{Lt(t,A);const r=i.map(r=>{if(r.id===e.id&&r.entries){const e=r.entries.map(e=>{if(e.components){const r=e.components.map(e=>e.id===t?Object.assign(Object.assign({},e),{basic:Object.assign(Object.assign({},e.basic),{attachments:A||[]})}):e);return Object.assign(Object.assign({},e),{components:r})}return e});return Object.assign(Object.assign({},r),{entries:e})}return r});null==c||c(r)},onValueChange:t=>{if(t.id===e.id&&t.value&&"object"==typeof t.value&&"entries"in t.value){const A=i.map(A=>A.id===e.id?Object.assign(Object.assign({},A),t.value):A);null==c||c(A),t.value.entries&&Array.isArray(t.value.entries)&&t.value.entries.forEach(t=>{t.components&&Array.isArray(t.components)&&t.components.forEach(t=>{var e;if(void 0!==F[t.id]);else{const A=null===(e=t.basic)||void 0===e?void 0:e.defaultValue;void 0!==A&&Q(e=>Object.assign(Object.assign({},e),{[t.id]:A}))}})})}else Z(t)},onEntryAdd:()=>{const t=i.find(t=>t.id===e.id);if(t&&t.entries){const t=i.map(t=>t.id===e.id?Object.assign(Object.assign({},t),{entries:t.entries||[]}):t);null==c||c(t)}else setTimeout(()=>{const t=F[e.id];if(t&&"object"==typeof t&&"entries"in t){const A=i.map(A=>A.id===e.id?Object.assign(Object.assign({},A),{entries:t.entries}):A);null==c||c(A)}},100)},onEntryRemove:t=>{const A=i.map(A=>{if(A.id===e.id&&A.entries){const e=(A.entries||[]).filter((e,A)=>A!==t).map((t,e)=>{var r;return Object.assign(Object.assign({},t),{index:e,id:`entry-${A.id}-${e}`,components:(null===(r=t.components)||void 0===r?void 0:r.map((t,A)=>{const r=(t.templateComponents||[])[A];return Object.assign(Object.assign({},t),{id:r?`${r.id}-entry-${e}-${A}`:t.id})}))||[]})});return Object.assign(Object.assign({},A),{entries:e})}return A});null==c||c(A)},renderFormComponent:t=>Ot(t)}));case"file":const D=T||(null===(E=e.basic)||void 0===E?void 0:E.value)||(null===(S=e.basic)||void 0===S?void 0:S.files)||(null===(I=e.basic)||void 0===I?void 0:I.attachments)||null;return X.jsx(dt,Object.assign({},j,{properties:e,formValue:D}));default:return X.jsx("div",{className:"form-group",children:X.jsxs("div",{className:"form-group-label",children:["Unsupported Component: ",e.name]})})}};return X.jsx("div",{className:"form-preview-container",children:X.jsx("div",{className:"form-preview-wrapper",children:X.jsxs("div",{className:`form-preview ${Object.entries(Nt()).map(([t,e])=>e?t:"").join(" ")}`,children:[X.jsx("div",{className:"form-canvas-header"}),0===i.length?X.jsx("div",{className:"empty-state",children:X.jsx("div",{className:"empty-state-card",children:X.jsx("div",{className:"empty-state-preview-area",children:X.jsx("span",{className:"empty-state-placeholder",children:"Add components to see the form preview"})})})}):X.jsxs("form",{className:"form-preview-form",onSubmit:t=>{t.preventDefault(),Et()},children:[(u||h)&&X.jsxs("div",{className:"form-header",children:[u&&X.jsx("h1",{className:"form-title",children:u}),h&&X.jsx("p",{className:"form-description",children:h})]}),i.map(t=>{var e,A,r,n;const s=t.basic,o=F[t.id],l=["select","radio","checkbox","segment"].includes(t.name||""),u=t.options||(null==s?void 0:s.options)||[],h=(()=>{var e;const A=null===(e=null==t?void 0:t.styles)||void 0===e?void 0:e.column;return"section"===t.name||"table"===t.name||"datagrid"===t.name?"col-12":3===A?"col-3":6===A?"col-6":9===A?"col-9":"col-12"})();let f=!1;if(!a)if(l&&null!=o&&""!==o)if("checkbox"===t.name){f=(Array.isArray(o)?o:[o]).some(t=>{const e=u.find(e=>e.value===t);return e&&(e.enableNotes||e.enableAttachment||e.enableRaiseIssue||e.enableSendEmail)})}else{const t=u.find(t=>t.value===o);f=t&&(t.enableNotes||t.enableAttachment||t.enableRaiseIssue||t.enableSendEmail)}else f=(null==s?void 0:s.enableNotes)||(null==s?void 0:s.enableAttachment)||(null==s?void 0:s.enableRaiseIssue)||(null==s?void 0:s.enableSendEmail);const p=a&&((null===(e=t.basic)||void 0===e?void 0:e.notes)&&t.basic.notes.trim().length>0||(null===(A=t.basic)||void 0===A?void 0:A.attachments)&&Array.isArray(t.basic.attachments)&&t.basic.attachments.length>0);return X.jsxs("div",{className:`form-group ${h} ${f||p?"has-action-features":""}`,style:{display:Y(t.id)?"block":"none"},children:[Ot(t),!a&&!["section","table","heading","file","instructions","signature","location","datagrid"].includes(t.name)&&X.jsx(vt,{component:t,mode:a?"preview":"test",formTemplateId:d,formValue:o,onThresholdActionCompletion:xt,onThresholdIssueRaised:Ct,onNotesChange:e=>{R(A=>Object.assign(Object.assign({},A),{[t.id]:e}));const A=i.map(A=>A.id===t.id?Object.assign(Object.assign({},A),{basic:Object.assign(Object.assign({},A.basic),{notes:e||""})}):A);null==c||c(A)},onAttachmentChange:e=>{V(A=>Object.assign(Object.assign({},A),{[t.id]:e||[]}));const A=i.map(A=>A.id===t.id?Object.assign(Object.assign({},A),{basic:Object.assign(Object.assign({},A.basic),{attachments:e||[]})}):A);null==c||c(A)},notes:void 0!==M[t.id]?M[t.id]:(null===(r=t.basic)||void 0===r?void 0:r.notes)||"",attachments:void 0!==K[t.id]?K[t.id]:(null===(n=t.basic)||void 0===n?void 0:n.attachments)||null,workOrderNumber:w,assetNumber:B,isStandalone:b,user:y,onCreateIssue:C,onUpdateIssue:x}),a&&p&&X.jsx(Bt,{component:t})]},t.id)}),!a&&X.jsxs("div",{className:"form-actions",children:[X.jsx("button",{type:"button",onClick:()=>Et("Saved"),className:"form-save-button",disabled:N&&!nt(),children:"Save"}),X.jsx("button",{type:"button",disabled:!nt()||!P.isValid,className:"form-submit-button",title:P.isValid?"":P.errorMessage,onClick:()=>Et("Submitted"),children:"Submit"})]})]})]})})})},Nt=({comment:t="",onSave:n,placeholder:i="Enter your reason...",className:s="",disabled:a=!1})=>{const[o,l]=e(!0),[c,u]=e(t),[h,d]=e(!1);A(()=>{u(t),d(!1)},[t]);const f=r(e=>{const A=e.target.value;u(A),d(A!==t)},[t]),p=r(()=>{h&&n&&!a&&(n(c),d(!1))},[h,n,c,a]),g=r(()=>{},[]),m=r(()=>{a||l(!o)},[o,a]);return X.jsxs("div",{className:`df-form-comments ${s}`,children:[X.jsxs("div",{className:"df-form-comments__header",children:[X.jsx("h3",{className:"df-form-comments__title",children:"Comments"}),X.jsx("button",{className:"df-form-comments__toggle",type:"button",onClick:m,"aria-expanded":o,"aria-label":"Toggle comments section",disabled:a,children:o?X.jsx("span",{className:"df-form-comments__toggle-icon",children:"▼"}):X.jsx("span",{className:"df-form-comments__toggle-icon",children:"▶"})})]}),X.jsx("div",{className:"df-form-comments__content "+(o?"df-form-comments__content--expanded":""),children:X.jsx("div",{className:"df-form-comments__input-container",children:X.jsx("div",{className:"df-form-comments__input-line",children:X.jsx("input",{type:"text",id:"comment-input",className:"df-form-comments__input",value:c,onChange:f,onBlur:p,onFocus:g,placeholder:i,disabled:a})})})})]})},St=t=>t.id?t:Object.assign(Object.assign({},t),{id:D()}),Lt=({component:t,mode:e,renderFormComponent:A,formData:r={},formTemplateId:n,onThresholdActionCompletion:i,onThresholdIssueRaised:s,onNotesChange:a,onAttachmentChange:o,workOrderNumber:l,assetNumber:c,user:u,onCreateIssue:h,onUpdateIssue:d})=>{var f,p;const g=r[t.id],m="preview"===e&&((null===(f=t.basic)||void 0===f?void 0:f.notes)&&t.basic.notes.trim().length>0||(null===(p=t.basic)||void 0===p?void 0:p.attachments)&&Array.isArray(t.basic.attachments)&&t.basic.attachments.length>0);return X.jsxs("div",{className:"simple-table-component",children:[A(t),!["section","table","heading","file","instructions","signature","location","datagrid"].includes(t.name)&&X.jsx(vt,{component:t,mode:"test",formTemplateId:n,formValue:g,formData:r,onThresholdActionCompletion:i,onThresholdIssueRaised:s,onNotesChange:a?e=>a(t.id,e):void 0,onAttachmentChange:o?e=>o(t.id,e):void 0,workOrderNumber:l,assetNumber:c,user:u,onCreateIssue:h,onUpdateIssue:d}),m&&X.jsx(Bt,{component:t})]})},It=({component:t,selectedComponent:e,mode:A,onComponentSelect:r,onComponentDelete:n,onComponentEdit:i,renderFormComponent:s,isOverlay:a=!1})=>{const{attributes:o,listeners:l,setNodeRef:c,transform:u,transition:h,isDragging:d,isSorting:f}=j({id:t.id,disabled:a}),p={transform:P.Transform.toString(u),transition:h,opacity:d?.3:1,zIndex:d?1e3:"auto"};return X.jsxs("div",{ref:c,style:p,className:`form-component table-component ${(null==e?void 0:e.id)===t.id?"selected":""} ${d?"dragging":""} ${f?"sorting":""}`,onClick:()=>!d&&r(t),role:"button",tabIndex:0,children:["edit"===A&&X.jsx("div",Object.assign({className:"component-drag-handle"},l,o,{onClick:t=>t.stopPropagation(),style:{opacity:1},children:X.jsx(U,{size:14})})),X.jsx("div",{className:"component-content",children:s(t)}),"edit"===A&&X.jsxs("div",{className:"component-actions",style:{opacity:1},children:[i&&X.jsx("button",{className:"component-edit-btn",onClick:e=>{e.stopPropagation(),i(t)},type:"button",title:"Edit Component",children:X.jsx(E,{size:12})}),X.jsx("button",{className:"component-delete-btn",onClick:e=>{e.stopPropagation(),n(t,e)},type:"button",title:"Delete Component",children:X.jsx(N,{size:12})})]})]})},_t=({cell:t,mode:e,onComponentSelect:A,onComponentDelete:r,onComponentEdit:n,selectedComponent:i,renderFormComponent:s,formData:a={},formTemplateId:o,onThresholdActionCompletion:l,onThresholdIssueRaised:c,tableId:u,onNotesChange:h,onAttachmentChange:d,workOrderNumber:f,assetNumber:p,user:g,onCreateIssue:m,onUpdateIssue:v})=>{var w,B,b,y,C;const x=`table-cell-${u}-${t.row}-${t.column}`,{setNodeRef:F,isOver:Q}=O({id:x,disabled:"edit"!==e,data:{type:"table-cell",tableId:u,cell:t,row:t.row,column:t.column}}),U=Object.assign(Object.assign({},t.styles),{backgroundColor:Q?"var(--df-color-primary-light)":(null===(w=t.styles)||void 0===w?void 0:w.backgroundColor)||"transparent",minHeight:(null===(B=t.styles)||void 0===B?void 0:B.minHeight)||"preview"===e||"test"===e?"40px":"60px",padding:(null===(b=t.styles)||void 0===b||b.padding,"8px"),border:"preview"===e||"test"===e?"none":Q?"2px dashed var(--df-color-primary)":(null===(y=t.styles)||void 0===y?void 0:y.borderColor)?`1px solid ${t.styles.borderColor}`:"1px solid var(--df-color-fb-border)",borderRadius:"preview"===e||"test"===e?"0":"4px",position:"relative",verticalAlign:(null===(C=t.styles)||void 0===C?void 0:C.verticalAlign)||"top"});return X.jsx("td",{ref:F,style:U,className:"table-cell "+(Q?"drag-over":""),children:X.jsx("div",{className:"cell-content",children:t.components&&Array.isArray(t.components)&&t.components.length>0?"edit"===e?X.jsx(k,{items:t.components.map(t=>t.id||D()),strategy:T,children:t.components.map(t=>{const a=St(t);return X.jsx(It,{component:a,selectedComponent:i,mode:e,onComponentSelect:A,onComponentDelete:r,onComponentEdit:n,renderFormComponent:s},a.id)})}):t.components.map(t=>{const A=t.id?t:St(t);return X.jsx(Lt,{component:A,mode:e,renderFormComponent:s,formData:a,formTemplateId:o,onThresholdActionCompletion:l,onThresholdIssueRaised:c,onNotesChange:h,onAttachmentChange:d,workOrderNumber:f,assetNumber:p,user:g,onCreateIssue:m,onUpdateIssue:v},A.id)}):"edit"===e?X.jsx("div",{className:"empty-cell-placeholder",children:X.jsxs("div",{className:"cell-info",children:[X.jsx("span",{className:"drop-zone-text",children:"Drag and Drop a form component"}),X.jsxs("span",{className:"cell-coordinates",children:["Cell (",t.row+1,", ",t.column+1,")"]})]})}):X.jsx("div",{style:{minHeight:"20px",backgroundColor:"transparent",visibility:"hidden"},children:" "})})})},Ot=({id:t,properties:n,mode:s="edit",formData:a={},validationErrors:o={},touchedFields:l={},formSubmitted:c=!1,onValueChange:u,onSelect:h,isSelected:d=!1,className:f="",onTableSelect:p,onComponentSelect:g,onComponentDelete:m,onComponentEdit:v,selectedComponent:w,renderFormComponent:B,formTemplateId:b,onThresholdActionCompletion:y,onThresholdIssueRaised:C,onNotesChange:x,onAttachmentChange:U,workOrderNumber:E,assetNumber:N,user:S,onCreateIssue:I,onUpdateIssue:_})=>{var O,k,T,j,H,P,D,M,R,K,V,z,G,q,W,Y,J,$;const[Z,tt]=e(!1),et=(null===(O=n.cells)||void 0===O?void 0:O.some(t=>t.some(t=>t.components&&t.components.length>0)))||!1;A(()=>{},[null===(k=n.table)||void 0===k?void 0:k.rows,null===(T=n.table)||void 0===T?void 0:T.columns,null===(j=n.basic)||void 0===j?void 0:j.rows,null===(H=n.basic)||void 0===H?void 0:H.columns,n.cells,t,u]);const At=r(t=>{t.stopPropagation(),null==h||h(),null==p||p(n)},[h,p,n]),rt=r((e,A)=>{A.stopPropagation();const r=n.cells.map(t=>t.map(t=>{if(t.components&&t.components.some(t=>t.id===e.id)){const A=t.components.filter(t=>t.id!==e.id);return Object.assign(Object.assign({},t),{components:A})}return t}));u&&u({id:t,value:Object.assign(Object.assign({},n),{cells:r})})},[m,n,u,t]),nt=i(()=>n.cells?n.cells.map((e,A)=>e.map((e,r)=>Object.assign(Object.assign({},e),{components:e.components&&Array.isArray(e.components)?e.components.map((e,n)=>{if(e.id&&"string"==typeof e.id&&""!==e.id.trim())return e;const i=`${e.name||"component"}-table-${t}-row-${A}-cell-${r}-comp-${n}`;return Object.assign(Object.assign({},e),{id:i})}):[]}))):[],[n.cells,t]),ct=B||r(t=>{var e,A,r;const n=t.id?t:St(t),i=a[n.id]||"defaultValue"in n.basic&&n.basic.defaultValue||"";let o=i;"number-input"===n.name&&"number"==typeof i?o=String(i):"number-input"===n.name&&null==i&&(o="");const l={id:n.id,properties:n,validationErrors:{},formValue:o,touchedFields:{},formSubmitted:!1,mode:s,onValueChange:t=>{null==u||u(t)},onBlur:()=>{},onFocus:()=>{}};switch(n.name){case"text-input":case"email-input":case"number-input":return X.jsx(it,Object.assign({},l,{properties:n,inputType:"text-input"===n.name?"text":"number-input"===n.name?"number":"email",readonly:!1,disabled:!1}));case"textarea":return X.jsx(st,Object.assign({},l,{properties:n,readonly:!1,disabled:!1}));case"select":const t=Object.assign(Object.assign({},n),{options:(null===(e=n.basic)||void 0===e?void 0:e.options)||[]});return X.jsx(at,Object.assign({},l,{properties:t,disabled:!1}));case"checkbox":const i=Object.assign(Object.assign({},n),{options:(null===(A=n.basic)||void 0===A?void 0:A.options)||[]});return X.jsx(ot,Object.assign({},l,{properties:i,formValue:[],disabled:!1}));case"radio":const s=Object.assign(Object.assign({},n),{options:(null===(r=n.basic)||void 0===r?void 0:r.options)||[]});return X.jsx(lt,Object.assign({},l,{properties:s,readonly:!1,disabled:!1}));case"date":case"date-picker":case"datetime-picker":return X.jsx(ut,Object.assign({},l,{properties:n,readonly:!1,disabled:!1}));case"signature":return X.jsx(ht,Object.assign({},l,{properties:n}));case"heading":return X.jsx(pt,Object.assign({},l,{properties:n}));default:return X.jsxs("div",{className:"unknown-component",children:["Unknown component: ",n.name]})}},[B,s,a,u]),dt={backgroundColor:(null===(P=n.styles)||void 0===P?void 0:P.backgroundColor)||"var(--df-color-fb-container)",borderColor:(null===(D=n.styles)||void 0===D?void 0:D.borderColor)||"var(--df-color-fb-border)",borderWidth:(null===(M=n.styles)||void 0===M?void 0:M.borderWidth)||"2px",borderRadius:(null===(R=n.styles)||void 0===R?void 0:R.borderRadius)||"8px",padding:(null===(K=n.styles)||void 0===K?void 0:K.padding)||"16px",margin:(null===(V=n.styles)||void 0===V?void 0:V.margin)||"16px 0"},ft={width:"100%",minWidth:"600px",borderCollapse:"preview"===s||"test"===s?"separate":"collapse",tableLayout:"fixed",border:"preview"===s||"test"===s?"1px solid var(--df-color-fb-border)":"none"};return et||"preview"!==s?X.jsxs("div",{className:`form-group df-form-table ${d?"selected":""} ${"preview"===s?"preview-mode":"test"===s?"test-mode":""} ${f}`,onClick:At,style:dt,children:[X.jsx("div",{className:"table-header",children:X.jsx("div",{className:"table-title",onClick:e=>{e.stopPropagation(),tt(!Z),null==u||u({id:t,value:Object.assign(Object.assign({},n),{basic:Object.assign(Object.assign({},n.basic||{}),{collapsed:!Z})})})},children:X.jsxs("div",{className:"title-content",children:[Z?X.jsx(Q,{size:16}):X.jsx(F,{size:16}),X.jsx(L,{size:16}),X.jsx("span",{className:"table-label",children:(null===(z=n.basic)||void 0===z?void 0:z.label)||"Table"}),(null===(G=n.validation)||void 0===G?void 0:G.required)&&X.jsx("span",{className:"required-indicator",children:"*"})]})})}),(null===(q=n.basic)||void 0===q?void 0:q.description)&&!Z&&X.jsx("div",{className:"table-description",children:n.basic.description}),!Z&&X.jsxs("div",{className:"table-content",children:[null,X.jsxs("table",{style:ft,children:[(null===(W=n.table)||void 0===W?void 0:W.displayAsTable)&&("edit"===s||(null===(Y=n.table)||void 0===Y?void 0:Y.showColumns))&&X.jsx("thead",{children:X.jsx("tr",{className:"table-header-row",children:Array.from({length:(null===(J=n.table)||void 0===J?void 0:J.columns)||(null===($=n.basic)||void 0===$?void 0:$.columns)||3},(t,e)=>{var A,r;const i=((null===(r=null===(A=n.table)||void 0===A?void 0:A.columnNames)||void 0===r?void 0:r.split(",").map(t=>t.trim()))||[])[e]||`Column ${e+1}`;return X.jsx("th",{className:"table-header-cell",style:{backgroundColor:(n.styles.headerBackgroundColor,"var(--df-color-fb-container)"),color:n.styles.headerTextColor||"var(--df-color-text-dark)",padding:"12px",border:"1px solid var(--df-color-fb-border)",fontWeight:"600",fontSize:"14px",textAlign:"center"},children:i},`header-${e}`)})})}),X.jsx("tbody",{children:nt.map((e,A)=>X.jsx("tr",{className:"table-row",children:e.map(e=>X.jsx(_t,{cell:e,mode:s,onComponentSelect:g||(()=>{}),onComponentDelete:rt,onComponentEdit:v,selectedComponent:w||null,renderFormComponent:ct,formData:a,formTemplateId:b,onThresholdActionCompletion:y,onThresholdIssueRaised:C,tableId:t,onNotesChange:x,onAttachmentChange:U,workOrderNumber:E,assetNumber:N,user:S,onCreateIssue:I,onUpdateIssue:_},e.id))},A))})]})]})]}):null};var kt=Object.freeze({__proto__:null,DfFormTable:Ot,default:Ot});const Tt={page:{fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif',padding:"30px",backgroundColor:"#ffffff",color:"#000000",lineHeight:"1.4"},header:{marginBottom:"30px",paddingBottom:"15px",borderBottom:"2px solid #303992",display:"flex",justifyContent:"space-between",alignItems:"flex-end"},title:{margin:"0 0 5px 0",fontSize:"24px",fontWeight:"bold",color:"#303992"},description:{margin:"0",fontSize:"14px",color:"#666666"},submittedBy:{fontSize:"14px",color:"#333",textAlign:"right",whiteSpace:"nowrap",marginBottom:"2px"},formGroup:{marginBottom:"20px",breakInside:"avoid"},label:{fontWeight:"400",display:"block",marginBottom:"8px",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif',fontSize:"14px",lineHeight:"1.5",fontColor:"var(--df-color-text-dark)"},labelLeft:{fontWeight:"400",display:"block",marginRight:"10px",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif',fontSize:"14px",lineHeight:"1.5",width:"60%",fontColor:"var(--df-color-text-dark)"},valueContainer:{border:"1px solid #e2e8f0",borderRadius:"6px",padding:"8px 12px",backgroundColor:"#ffffff",minHeight:"20px",fontSize:"14px",flex:1},value:{fontSize:"14px",color:"#000000"},gridRow:{display:"flex",flexWrap:"wrap",gap:"16px",marginBottom:"20px"},gridCol:t=>({flex:`0 0 calc(${t/12*100}% - 8px)`,minWidth:"0"}),img:{maxWidth:"100%",maxHeight:"300px",border:"1px solid #ddd",borderRadius:"4px",display:"block",marginTop:"5px"},table:{width:"100%",borderCollapse:"collapse",border:"1px solid #ddd",marginTop:"10px",tableLayout:"fixed"},th:{border:"1px solid #ddd",padding:"8px",backgroundColor:"#f5f5f5",fontWeight:"bold",textAlign:"left",fontSize:"13px"},td:{border:"1px solid #ddd",padding:"8px",fontSize:"13px",verticalAlign:"top"},section:{marginBottom:"25px",breakInside:"avoid"},sectionHeader:{fontSize:"18px",marginBottom:"15px",display:"block",fontWeight:"600"},sectionChildren:{marginLeft:"20px",paddingLeft:"20px",borderLeft:"2px solid #3b82f6",marginTop:"15px"},notesSection:{marginTop:"10px",padding:"10px",backgroundColor:"rgba(48, 57, 146, 0.05)",borderLeft:"3px solid #303992",borderRadius:"4px",fontSize:"13px",boxSizing:"border-box"},notesLabel:{fontWeight:"bold",color:"#303992",marginRight:"5px"},attachmentsSection:{marginTop:"10px",padding:"10px",backgroundColor:"rgba(48, 57, 146, 0.05)",borderLeft:"3px solid #303992",borderRadius:"4px",display:"flex",flexWrap:"wrap",gap:"10px",boxSizing:"border-box"},attachmentThumbnail:{width:"60px",height:"60px",border:"1px solid #e5e7eb",borderRadius:"4px",overflow:"hidden",backgroundColor:"#fff",display:"flex",alignItems:"center",justifyContent:"center"},attachmentImg:{width:"100%",height:"100%",objectFit:"cover"},segmentContainer:{display:"flex",gap:"8px",flexWrap:"wrap",alignItems:"center"},segmentButton:{display:"flex",alignItems:"center",justifyContent:"center",padding:"4px 6px",borderRadius:"6px",border:"1px solid #e0e0e0",backgroundColor:"#ffffff",fontSize:"10px",fontWeight:600,minWidth:"30px",color:"#666"},segmentIcon:{marginRight:"4px",fontSize:"9px",fontWeight:"bold",display:"inline-block",lineHeight:"1"},checkboxItem:{display:"flex",alignItems:"center",padding:"10px 14px",backgroundColor:"#f8f9fa",borderRadius:"6px",marginBottom:"8px",width:"100%",boxSizing:"border-box"}},jt=t=>{if(!t||"string"!=typeof t)return!1;const e=t.trim();return e.startsWith("data:image")||e.startsWith("iVBORw0KGgo")||e.startsWith("/9j/4AAQ")||e.startsWith("UklGR")||e.startsWith("R0lGOD")},Ht=(t,e)=>{if(!t)return"";const A=t.trim();return A.startsWith("data:")||A.startsWith("http")||A.startsWith("blob:")||A.startsWith("/")?A:A.startsWith("iVBORw0KGgo")?`data:image/png;base64,${A}`:A.startsWith("/9j/4AAQ")?`data:image/jpeg;base64,${A}`:A.startsWith("UklGR")?`data:image/webp;base64,${A}`:A.startsWith("R0lGOD")?`data:image/gif;base64,${A}`:e&&e.startsWith("image/")?`data:${e};base64,${A}`:A},Pt=t=>{const e=String(t||"").toLowerCase();return"pass"===e||"yes"===e?"pass":"fail"===e||"no"===e?"fail":"pass"},Dt=({component:t})=>{var e,A;const r=(null===(e=t.basic)||void 0===e?void 0:e.notes)||"",n=(null===(A=t.basic)||void 0===A?void 0:A.attachments)||[];return r.trim()||0!==n.length?X.jsxs("div",{style:{marginTop:"5px"},children:[r.trim().length>0&&X.jsxs("div",{style:Tt.notesSection,children:[X.jsx("span",{style:Tt.notesLabel,children:"Notes:"}),r]}),n.length>0&&X.jsx("div",{style:Tt.attachmentsSection,children:n.map((t,e)=>{var A;const r=!(!t.data&&!t.url),n=((null===(A=t.type)||void 0===A?void 0:A.startsWith("image/"))||jt(t.data||t.url||""))&&r?Ht(t.data||t.url||"",t.type):null;return X.jsx("div",{style:Tt.attachmentThumbnail,children:n?X.jsx("img",{src:n,alt:t.name||"Attachment",style:Tt.attachmentImg}):X.jsx("span",{style:{fontSize:"20px",color:"#999"},children:"📎"})},e)})})]}):null},Mt=({component:t})=>{var e,A,r,n,i,s,a,o;const l=void 0!==(null===(e=t.basic)||void 0===e?void 0:e.value)?t.basic.value:null===(A=t.basic)||void 0===A?void 0:A.defaultValue,{name:c}=t;if("signature"===c)return l&&jt(l)?X.jsx("div",{style:{marginTop:"5px"},children:X.jsx("img",{src:Ht(l),alt:"Signature",style:Object.assign(Object.assign({},Tt.img),{maxHeight:"100px",width:"auto"})})}):X.jsx("span",{style:{color:"#999",fontStyle:"italic"},children:"No signature"});if("checkbox"===c){const e=(null===(r=t.basic)||void 0===r?void 0:r.options)||[],A=(Array.isArray(l)?l:l?[l]:[]).map(t=>String(t));return X.jsx("div",{style:{marginTop:"5px",width:"100%"},children:e.map((t,e)=>{const r=A.includes(String(t.value));return X.jsxs("div",{style:Tt.checkboxItem,children:[X.jsx("div",{style:{width:"18px",height:"18px",minWidth:"18px",border:"2px solid "+(r?"#303992":"#cbd5e1"),borderRadius:"4px",marginRight:"12px",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:r?"#303992":"#ffffff"},children:r&&X.jsx("span",{style:{color:"#ffffff",fontSize:"12px",fontWeight:"bold",lineHeight:1},children:"✓"})}),X.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:"#334155"},children:t.label})]},e)})})}if("radio"===c){const e=(null===(n=t.basic)||void 0===n?void 0:n.options)||[];return X.jsx("div",{style:{marginTop:"5px",width:"100%"},children:e.map((t,e)=>{const A=String(l||"")===String(t.value||"");return X.jsxs("div",{style:Tt.checkboxItem,children:[X.jsx("div",{style:{width:"18px",height:"18px",minWidth:"18px",border:"2px solid "+(A?"#303992":"#cbd5e1"),borderRadius:"50%",marginRight:"12px",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#ffffff"},children:A&&X.jsx("div",{style:{width:"10px",height:"10px",borderRadius:"50%",backgroundColor:"#303992"}})}),X.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:"#334155"},children:t.label})]},e)})})}if("segment"===c){const e=(null===(i=t.basic)||void 0===i?void 0:i.options)||[],A=l;return X.jsx("div",{style:Tt.segmentContainer,children:e.map((t,e)=>{const r=String(A||"")===String(t.value||""),n=(t=>void 0!==(null==t?void 0:t.icon)&&null!==(null==t?void 0:t.icon)?t.icon:"pass"===Pt((null==t?void 0:t.value)||t)?"✓":"×")(t),i=t.color||t.backgroundColor,s=Pt(t.value);let a,o,l;i?r?(a=i,o="#ffffff",l=i):(a=`${i}20`,o=i,l=i):"pass"===s?r?(a="#00814b",o="#ffffff",l="#00814b"):(a="#34bd4914",o="#00814b",l="#e0e0e0"):r?(a="#dc3545",o="#ffffff",l="#dc3545"):(a="#fa323d14",o="#dc3545",l="#e0e0e0");const c=Object.assign(Object.assign({},Tt.segmentButton),{backgroundColor:a,color:o,borderColor:l,borderWidth:"1px",borderStyle:"solid"});return X.jsxs("div",{style:c,children:[X.jsx("span",{style:Tt.segmentIcon,children:n}),X.jsx("span",{children:t.value})]},e)})})}if("file"===c){const t=(Array.isArray(l)?l:l?[l]:[]).filter(t=>{const e=!(!t.data&&!t.url),A=t.type&&t.type.startsWith("image/"),r=e&&jt(t.data||t.url);return A||r});return t.length>0?X.jsx("div",{style:{marginTop:"10px"},children:t.map((t,e)=>{const A=Ht(t.data||t.url,t.type);return A?X.jsx("img",{src:A,alt:t.name||"File",style:Object.assign(Object.assign({},Tt.img),{marginBottom:"10px"})},e):null})}):X.jsx("div",{style:{color:"#999",fontStyle:"italic"},children:"No images uploaded"})}if("location"===c){if(l&&"object"==typeof l){const t=l;return X.jsxs("div",{style:{fontSize:"14px"},children:[t.placeName&&X.jsxs("div",{style:{marginBottom:"4px"},children:[X.jsx("strong",{children:"Place:"})," ",t.placeName]}),(t.city||t.country)&&X.jsxs("div",{style:{marginBottom:"4px"},children:[X.jsx("strong",{children:"Address:"})," ",[t.city,t.country].filter(Boolean).join(", ")]}),t.latitude&&t.longitude&&X.jsxs("div",{style:{marginBottom:"4px"},children:[X.jsx("strong",{children:"Coordinates:"})," ",t.latitude.toFixed(6),", ",t.longitude.toFixed(6)]}),t.timestamp&&X.jsxs("div",{children:[X.jsx("strong",{children:"Captured:"})," ",(et(t.timestamp)||new Date).toLocaleString()]})]})}return X.jsx("div",{style:{color:"#999",fontStyle:"italic"},children:"No location data"})}if("instructions"===c){const e=(null===(s=t.basic)||void 0===s?void 0:s.instructions)||[],A=(null===(a=t.validation)||void 0===a?void 0:a.listStyle)||"numbers";if(!Array.isArray(e)||0===e.length)return X.jsx("div",{style:{color:"#999",fontStyle:"italic"},children:"No instructions"});const r=()=>X.jsx("div",{dangerouslySetInnerHTML:{__html:e.join("")}});return"numbers"===A?X.jsx("ol",{style:{margin:"10px 0",paddingLeft:"25px"},children:X.jsx(r,{})}):"bullets"===A?X.jsx("ul",{style:{margin:"10px 0",paddingLeft:"25px"},children:X.jsx(r,{})}):X.jsx("div",{style:{margin:"10px 0"},children:X.jsx(r,{})})}if("select"===c){const e=(null===(o=t.basic)||void 0===o?void 0:o.options)||[],A=l;let r="";if(Array.isArray(A))r=A.map(t=>{const A=e.find(e=>String(e.value)===String(t));return A?A.label:t}).join(", ");else{const t=A,n=e.find(e=>String(e.value)===String(t));r=n?n.label||n.value:null!=t?String(t):""}return X.jsx("div",{style:Tt.valueContainer,children:X.jsx("div",{style:Tt.value,children:r})})}const u="object"==typeof l?JSON.stringify(l):String(l);if(!["signature","checkbox","radio","segment","file","instructions","heading","section","table","datagrid","select"].includes(c)){const t="textarea"===c;return X.jsx("div",{style:Object.assign(Object.assign({},Tt.valueContainer),t?{minHeight:"60px",whiteSpace:"pre-wrap"}:{}),children:X.jsx("div",{style:Tt.value,children:u})})}return X.jsx("div",{style:Tt.value,children:u})},Rt=({component:t})=>{var e,A,r;const{name:n,basic:i,styles:s,validation:a}=t,o=null==i?void 0:i.label,l=null==a?void 0:a.required,c="left"===((null==s?void 0:s.labelAlignment)||"top");if("section"===n){const e=null==s?void 0:s.headerBackgroundColor,A=null==s?void 0:s.headerTextColor,r=Object.assign(Object.assign(Object.assign(Object.assign({},Tt.sectionHeader),e?{backgroundColor:e,padding:"8px",borderRadius:"4px"}:{}),A?{color:A}:{}),{display:"flex",alignItems:"center"});return X.jsxs("div",{style:Tt.section,children:[o&&X.jsx("label",{style:r,children:X.jsxs("span",{style:{flex:1},children:[o,l&&" *"]})}),(null==i?void 0:i.description)&&X.jsx("p",{style:Object.assign(Object.assign({},Tt.description),{marginBottom:"15px"}),children:i.description}),X.jsx(Dt,{component:t}),X.jsx("div",{style:Tt.sectionChildren,children:X.jsx(Kt,{components:t.children||[]})})]})}if("heading"===n){const t=`h${Math.max(1,Math.min(6,null!==(A=null!==(e=null==s?void 0:s.level)&&void 0!==e?e:null==i?void 0:i.level)&&void 0!==A?A:1))}`,r=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},(null==s?void 0:s.headerBackgroundColor)?{backgroundColor:s.headerBackgroundColor,padding:"8px",borderRadius:"4px"}:{}),(null==s?void 0:s.headerTextColor)?{color:s.headerTextColor}:{}),(null==s?void 0:s.fontSize)?{fontSize:s.fontSize}:{}),(null==s?void 0:s.textAlign)?{textAlign:s.textAlign}:{}),{marginTop:0,marginBottom:"15px"});return X.jsx("div",{style:Tt.formGroup,children:X.jsx(t,{style:r,children:(null==i?void 0:i.label)||(null==i?void 0:i.value)})})}if("table"===n){const e=t.cells||[],A=Math.max(0,...e.map(t=>t?t.length:0)),r=A>0?100/A:100,n=null==s?void 0:s.headerBackgroundColor,i=null==s?void 0:s.headerTextColor,a=Object.assign(Object.assign(Object.assign({},Tt.label),n?{backgroundColor:n,padding:"8px",borderRadius:"4px",marginBottom:"10px"}:{}),i?{color:i}:{});return X.jsxs("div",{style:Tt.formGroup,children:[o&&X.jsxs("label",{style:a,children:[o,l&&" *"]}),X.jsx("table",{style:Tt.table,children:X.jsx("tbody",{children:e.map((t,e)=>X.jsx("tr",{children:t&&t.map((t,e)=>X.jsx("td",{style:Object.assign(Object.assign({},Tt.td),{width:`${r}%`}),children:t.components&&t.components.map((t,e)=>{var A;return X.jsxs("div",{style:{marginBottom:"8px"},children:[(null===(A=t.basic)||void 0===A?void 0:A.label)&&X.jsxs("span",{style:{fontWeight:"bold",marginRight:"5px",fontSize:"12px"},children:[t.basic.label,":"]}),X.jsx(Mt,{component:t}),X.jsx(Dt,{component:t})]},e)})},e))},e))})})]})}if("datagrid"===n){const e=t.entries||[];let A=t.templateComponents||[];0===A.length&&e.length>0&&(null===(r=e[0])||void 0===r?void 0:r.components)&&(A=e[0].components.map(t=>{var e;return Object.assign(Object.assign({},t),{basic:Object.assign(Object.assign({},t.basic),{label:(null===(e=t.basic)||void 0===e?void 0:e.label)||t.name})})}));const n=null==s?void 0:s.headerBackgroundColor,i=null==s?void 0:s.headerTextColor,a=Object.assign(Object.assign(Object.assign({},Tt.label),n?{backgroundColor:n,padding:"8px",borderRadius:"4px",marginBottom:"10px"}:{}),i?{color:i}:{}),c=e.filter(t=>!(!t.components||0===t.components.length)&&t.components.some(t=>{var e,A;const r=void 0!==(null===(e=t.basic)||void 0===e?void 0:e.value)?t.basic.value:null===(A=t.basic)||void 0===A?void 0:A.defaultValue;return Array.isArray(r)?r.length>0:null!=r&&""!==String(r).trim()}));return 0===c.length?X.jsxs("div",{style:Tt.formGroup,children:[o&&X.jsxs("label",{style:a,children:[o,l&&" *"]}),X.jsx("div",{style:{fontStyle:"italic",color:"#999"},children:"No data"})]}):X.jsxs("div",{style:Tt.formGroup,children:[o&&X.jsxs("label",{style:a,children:[o,l&&" *"]}),X.jsxs("table",{style:Tt.table,children:[X.jsx("thead",{children:X.jsx("tr",{children:A.map((t,e)=>{var A;return X.jsx("th",{style:Tt.th,children:(null===(A=t.basic)||void 0===A?void 0:A.label)||t.name},e)})})}),X.jsx("tbody",{children:c.map((t,e)=>X.jsx("tr",{children:A.map((e,A)=>{const r=t.components[A];return X.jsx("td",{style:Tt.td,children:r?X.jsxs(X.Fragment,{children:[X.jsx(Mt,{component:r}),X.jsx(Dt,{component:r})]}):"N/A"},A)})},e))})]})]})}if(c&&"instructions"!==n){const e=["segment"].includes(n);return X.jsxs("div",{style:Tt.formGroup,children:[X.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[o&&X.jsxs("label",{style:Tt.labelLeft,children:[o,l&&" *"]}),X.jsx("div",{style:Object.assign({flex:1},e?{display:"flex",justifyContent:"flex-end"}:{}),children:X.jsx(Mt,{component:t})})]}),X.jsx(Dt,{component:t})]})}return X.jsxs("div",{style:Tt.formGroup,children:[o&&X.jsxs("label",{style:Tt.label,children:[o,l&&" *"]}),X.jsx(Mt,{component:t}),X.jsx(Dt,{component:t})]})},Kt=({components:t})=>{if(!t||0===t.length)return null;const e=[];let A=[],r=0;return t.forEach(t=>{var n;const i=["section","table","datagrid","heading","instructions"].includes(t.name),s=i?12:(null===(n=t.styles)||void 0===n?void 0:n.column)||12;r+s>12&&A.length>0&&(e.push(A),A=[],r=0),A.push(t),r+=s,(i||r>=12)&&r>0&&(e.push(A),A=[],r=0)}),A.length>0&&e.push(A),X.jsx(X.Fragment,{children:e.map((t,e)=>1===t.length?X.jsx(Rt,{component:t[0]},t[0].id||e):X.jsx("div",{style:Tt.gridRow,children:t.map((t,e)=>{var A;const r=(null===(A=t.styles)||void 0===A?void 0:A.column)||12;return X.jsx("div",{style:Tt.gridCol(r),children:X.jsx(Rt,{component:t})},t.id||e)})},e))})},Vt=({formTitle:t,formDescription:e,userName:A,components:r})=>X.jsxs("div",{className:"pdf-container",style:Tt.page,children:[X.jsxs("div",{style:Tt.header,children:[X.jsxs("div",{children:[X.jsx("h1",{style:Tt.title,children:t}),e&&X.jsx("p",{style:Tt.description,children:e})]}),A&&X.jsxs("div",{style:Tt.submittedBy,children:[X.jsx("strong",{children:"Submitted By:"})," ",A]})]}),X.jsx("div",{className:"form-content",children:X.jsx(Kt,{components:r})})]});var zt,Gt=I;if("production"===process.env.NODE_ENV)zt=Gt.createRoot,Gt.hydrateRoot;else{var qt=Gt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;zt=function(t,e){qt.usingClientEntryPoint=!0;try{return Gt.createRoot(t,e)}finally{qt.usingClientEntryPoint=!1}}}var Wt={exports:{}};
10
+ */"production"===process.env.NODE_ENV?z.exports=function(){if(V)return G;V=1;var e=t,A=Symbol.for("react.element"),r=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function a(t,e,r){var a,o={},l=null,c=null;for(a in void 0!==r&&(l=""+r),void 0!==e.key&&(l=""+e.key),void 0!==e.ref&&(c=e.ref),e)n.call(e,a)&&!s.hasOwnProperty(a)&&(o[a]=e[a]);if(t&&t.defaultProps)for(a in e=t.defaultProps)void 0===o[a]&&(o[a]=e[a]);return{$$typeof:A,type:t,key:l,ref:c,props:o,_owner:i.current}}return G.Fragment=r,G.jsx=a,G.jsxs=a,G}():z.exports=(q||(q=1,"production"!==process.env.NODE_ENV&&function(){var e,A=t,r=Symbol.for("react.element"),n=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),h=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen"),g=Symbol.iterator,m=A.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function v(t){for(var e=arguments.length,A=new Array(e>1?e-1:0),r=1;r<e;r++)A[r-1]=arguments[r];!function(t,e,A){var r=m.ReactDebugCurrentFrame.getStackAddendum();""!==r&&(e+="%s",A=A.concat([r]));var n=A.map(function(t){return String(t)});n.unshift("Warning: "+e),Function.prototype.apply.call(console[t],console,n)}("error",t,A)}function w(t){return t.displayName||"Context"}function B(t){if(null==t)return null;if("number"==typeof t.tag&&v("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),"function"==typeof t)return t.displayName||t.name||null;if("string"==typeof t)return t;switch(t){case i:return"Fragment";case n:return"Portal";case a:return"Profiler";case s:return"StrictMode";case u:return"Suspense";case h:return"SuspenseList"}if("object"==typeof t)switch(t.$$typeof){case l:return w(t)+".Consumer";case o:return w(t._context)+".Provider";case c:return function(t,e,A){var r=t.displayName;if(r)return r;var n=e.displayName||e.name||"";return""!==n?A+"("+n+")":A}(t,t.render,"ForwardRef");case d:var e=t.displayName||null;return null!==e?e:B(t.type)||"Memo";case f:var A=t,r=A._payload,p=A._init;try{return B(p(r))}catch(t){return null}}return null}e=Symbol.for("react.module.reference");var b,y,C,x,F,Q,U,E=Object.assign,N=0;function S(){}S.__reactDisabledLog=!0;var L,I=m.ReactCurrentDispatcher;function _(t,e,A){if(void 0===L)try{throw Error()}catch(t){var r=t.stack.trim().match(/\n( *(at )?)/);L=r&&r[1]||""}return"\n"+L+t}var O,k=!1,T="function"==typeof WeakMap?WeakMap:Map;function j(t,e){if(!t||k)return"";var A,r=O.get(t);if(void 0!==r)return r;k=!0;var n,i=Error.prepareStackTrace;Error.prepareStackTrace=void 0,n=I.current,I.current=null,function(){if(0===N){b=console.log,y=console.info,C=console.warn,x=console.error,F=console.group,Q=console.groupCollapsed,U=console.groupEnd;var t={configurable:!0,enumerable:!0,value:S,writable:!0};Object.defineProperties(console,{info:t,log:t,warn:t,error:t,group:t,groupCollapsed:t,groupEnd:t})}N++}();try{if(e){var s=function(){throw Error()};if(Object.defineProperty(s.prototype,"props",{set:function(){throw Error()}}),"object"==typeof Reflect&&Reflect.construct){try{Reflect.construct(s,[])}catch(t){A=t}Reflect.construct(t,[],s)}else{try{s.call()}catch(t){A=t}t.call(s.prototype)}}else{try{throw Error()}catch(t){A=t}t()}}catch(e){if(e&&A&&"string"==typeof e.stack){for(var a=e.stack.split("\n"),o=A.stack.split("\n"),l=a.length-1,c=o.length-1;l>=1&&c>=0&&a[l]!==o[c];)c--;for(;l>=1&&c>=0;l--,c--)if(a[l]!==o[c]){if(1!==l||1!==c)do{if(l--,--c<0||a[l]!==o[c]){var u="\n"+a[l].replace(" at new "," at ");return t.displayName&&u.includes("<anonymous>")&&(u=u.replace("<anonymous>",t.displayName)),"function"==typeof t&&O.set(t,u),u}}while(l>=1&&c>=0);break}}}finally{k=!1,I.current=n,function(){if(0===--N){var t={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:E({},t,{value:b}),info:E({},t,{value:y}),warn:E({},t,{value:C}),error:E({},t,{value:x}),group:E({},t,{value:F}),groupCollapsed:E({},t,{value:Q}),groupEnd:E({},t,{value:U})})}N<0&&v("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}(),Error.prepareStackTrace=i}var h=t?t.displayName||t.name:"",d=h?_(h):"";return"function"==typeof t&&O.set(t,d),d}function H(t,e,A){if(null==t)return"";if("function"==typeof t)return j(t,!(!(r=t.prototype)||!r.isReactComponent));var r;if("string"==typeof t)return _(t);switch(t){case u:return _("Suspense");case h:return _("SuspenseList")}if("object"==typeof t)switch(t.$$typeof){case c:return j(t.render,!1);case d:return H(t.type,e,A);case f:var n=t,i=n._payload,s=n._init;try{return H(s(i),e,A)}catch(t){}}return""}O=new T;var P=Object.prototype.hasOwnProperty,D={},M=m.ReactDebugCurrentFrame;function R(t){if(t){var e=t._owner,A=H(t.type,t._source,e?e.type:null);M.setExtraStackFrame(A)}else M.setExtraStackFrame(null)}var K=Array.isArray;function V(t){return K(t)}function z(t){return""+t}function G(t){if(function(t){try{return z(t),!1}catch(t){return!0}}(t))return v("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",function(t){return"function"==typeof Symbol&&Symbol.toStringTag&&t[Symbol.toStringTag]||t.constructor.name||"Object"}(t)),z(t)}var q,X,Y,J=m.ReactCurrentOwner,$={key:!0,ref:!0,__self:!0,__source:!0};function Z(t,e,A,n,i){var s,a={},o=null,l=null;for(s in void 0!==A&&(G(A),o=""+A),function(t){if(P.call(t,"key")){var e=Object.getOwnPropertyDescriptor(t,"key").get;if(e&&e.isReactWarning)return!1}return void 0!==t.key}(e)&&(G(e.key),o=""+e.key),function(t){if(P.call(t,"ref")){var e=Object.getOwnPropertyDescriptor(t,"ref").get;if(e&&e.isReactWarning)return!1}return void 0!==t.ref}(e)&&(l=e.ref,function(t,e){if("string"==typeof t.ref&&J.current&&e&&J.current.stateNode!==e){var A=B(J.current.type);Y[A]||(v('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',B(J.current.type),t.ref),Y[A]=!0)}}(e,i)),e)P.call(e,s)&&!$.hasOwnProperty(s)&&(a[s]=e[s]);if(t&&t.defaultProps){var c=t.defaultProps;for(s in c)void 0===a[s]&&(a[s]=c[s])}if(o||l){var u="function"==typeof t?t.displayName||t.name||"Unknown":t;o&&function(t,e){var A=function(){q||(q=!0,v("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",e))};A.isReactWarning=!0,Object.defineProperty(t,"key",{get:A,configurable:!0})}(a,u),l&&function(t,e){var A=function(){X||(X=!0,v("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",e))};A.isReactWarning=!0,Object.defineProperty(t,"ref",{get:A,configurable:!0})}(a,u)}return function(t,e,A,n,i,s,a){var o={$$typeof:r,type:t,key:e,ref:A,props:a,_owner:s,_store:{}};return Object.defineProperty(o._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(o,"_self",{configurable:!1,enumerable:!1,writable:!1,value:n}),Object.defineProperty(o,"_source",{configurable:!1,enumerable:!1,writable:!1,value:i}),Object.freeze&&(Object.freeze(o.props),Object.freeze(o)),o}(t,o,l,i,n,J.current,a)}Y={};var tt,et=m.ReactCurrentOwner,At=m.ReactDebugCurrentFrame;function rt(t){if(t){var e=t._owner,A=H(t.type,t._source,e?e.type:null);At.setExtraStackFrame(A)}else At.setExtraStackFrame(null)}function nt(t){return"object"==typeof t&&null!==t&&t.$$typeof===r}function it(){if(et.current){var t=B(et.current.type);if(t)return"\n\nCheck the render method of `"+t+"`."}return""}tt=!1;var st={};function at(t,e){if(t._store&&!t._store.validated&&null==t.key){t._store.validated=!0;var A=function(t){var e=it();if(!e){var A="string"==typeof t?t:t.displayName||t.name;A&&(e="\n\nCheck the top-level render call using <"+A+">.")}return e}(e);if(!st[A]){st[A]=!0;var r="";t&&t._owner&&t._owner!==et.current&&(r=" It was passed a child from "+B(t._owner.type)+"."),rt(t),v('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',A,r),rt(null)}}}function ot(t,e){if("object"==typeof t)if(V(t))for(var A=0;A<t.length;A++){var r=t[A];nt(r)&&at(r,e)}else if(nt(t))t._store&&(t._store.validated=!0);else if(t){var n=function(t){if(null===t||"object"!=typeof t)return null;var e=g&&t[g]||t["@@iterator"];return"function"==typeof e?e:null}(t);if("function"==typeof n&&n!==t.entries)for(var i,s=n.call(t);!(i=s.next()).done;)nt(i.value)&&at(i.value,e)}}function lt(t){var e,A=t.type;if(null!=A&&"string"!=typeof A){if("function"==typeof A)e=A.propTypes;else{if("object"!=typeof A||A.$$typeof!==c&&A.$$typeof!==d)return;e=A.propTypes}if(e){var r=B(A);!function(t,e,A,r,n){var i=Function.call.bind(P);for(var s in t)if(i(t,s)){var a=void 0;try{if("function"!=typeof t[s]){var o=Error((r||"React class")+": "+A+" type `"+s+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof t[s]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw o.name="Invariant Violation",o}a=t[s](e,s,r,A,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(t){a=t}!a||a instanceof Error||(R(n),v("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",r||"React class",A,s,typeof a),R(null)),a instanceof Error&&!(a.message in D)&&(D[a.message]=!0,R(n),v("Failed %s type: %s",A,a.message),R(null))}}(e,t.props,"prop",r,t)}else void 0===A.PropTypes||tt||(tt=!0,v("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",B(A)||"Unknown"));"function"!=typeof A.getDefaultProps||A.getDefaultProps.isReactClassApproved||v("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}var ct={};function ut(t,A,n,g,m,w){var b=function(t){return"string"==typeof t||"function"==typeof t||t===i||t===a||t===s||t===u||t===h||t===p||"object"==typeof t&&null!==t&&(t.$$typeof===f||t.$$typeof===d||t.$$typeof===o||t.$$typeof===l||t.$$typeof===c||t.$$typeof===e||void 0!==t.getModuleId)}(t);if(!b){var y="";(void 0===t||"object"==typeof t&&null!==t&&0===Object.keys(t).length)&&(y+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var C,x=function(t){return void 0!==t?"\n\nCheck your code at "+t.fileName.replace(/^.*[\\\/]/,"")+":"+t.lineNumber+".":""}(m);y+=x||it(),null===t?C="null":V(t)?C="array":void 0!==t&&t.$$typeof===r?(C="<"+(B(t.type)||"Unknown")+" />",y=" Did you accidentally export a JSX literal instead of a component?"):C=typeof t,v("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",C,y)}var F=Z(t,A,n,m,w);if(null==F)return F;if(b){var Q=A.children;if(void 0!==Q)if(g)if(V(Q)){for(var U=0;U<Q.length;U++)ot(Q[U],t);Object.freeze&&Object.freeze(Q)}else v("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else ot(Q,t)}if(P.call(A,"key")){var E=B(t),N=Object.keys(A).filter(function(t){return"key"!==t}),S=N.length>0?"{key: someKey, "+N.join(": ..., ")+": ...}":"{key: someKey}";ct[E+S]||(v('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',S,E,N.length>0?"{"+N.join(": ..., ")+": ...}":"{}",E),ct[E+S]=!0)}return t===i?function(t){for(var e=Object.keys(t.props),A=0;A<e.length;A++){var r=e[A];if("children"!==r&&"key"!==r){rt(t),v("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",r),rt(null);break}}null!==t.ref&&(rt(t),v("Invalid attribute `ref` supplied to `React.Fragment`."),rt(null))}(F):lt(F),F}var ht=function(t,e,A){return ut(t,e,A,!1)},dt=function(t,e,A){return ut(t,e,A,!0)};W.Fragment=i,W.jsx=ht,W.jsxs=dt}()),W);var X=z.exports;class Y{constructor(){}static getInstance(){return Y.instance||(Y.instance=new Y),Y.instance}getAvailableComponentsForConditional(t,e){if(!t||!Array.isArray(t))return[];const A=t.filter(t=>!e||t.id!==e).map(t=>{var e;return{id:t.id,label:(null===(e=t.basic)||void 0===e?void 0:e.label)||t.id,type:t.name,key:t.id}}).sort((t,e)=>t.label.localeCompare(e.label));return A}getApplicableOperators(t){switch(t){case"text-input":case"email-input":case"textarea":return["equals","notEquals","contains","notContains","isEmpty","isNotEmpty"];case"number-input":case"date-picker":case"datetime-picker":return["equals","notEquals","greaterThan","lessThan","greaterThanOrEqual","lessThanOrEqual","isEmpty","isNotEmpty"];case"select":case"radio":case"segment":default:return["equals","notEquals","isEmpty","isNotEmpty"];case"checkbox":return["contains","notContains","isEmpty","isNotEmpty"]}}validateConditionalLogic(t,e){const A=[];try{return t?(["show","hide","always"].includes(t.action)||A.push("Invalid conditional action"),["all","any"].includes(t.when)||A.push("Invalid when condition"),t.conditions&&0!==t.conditions.length?t.conditions.forEach((t,r)=>{try{let n=e.find(e=>{var A;return(null===(A=e.basic)||void 0===A?void 0:A.label)===t.when});if(n||(n=e.find(e=>e.id===t.when)),!n)return void A.push(`Condition ${r+1}: Component not found`);this.getApplicableOperators(n.name).includes(t.operator)||A.push(`Condition ${r+1}: Operator not applicable for component type`),this.isValidConditionValue(t.value,n.name,t.operator)||A.push(`Condition ${r+1}: Invalid condition value`)}catch(t){console.error("[ConditionalLogicService] Error validating condition:",t),A.push(`Condition ${r+1}: Validation error`)}}):A.push("At least one condition is required"),{isValid:0===A.length,errors:A}):{isValid:!0,errors:[]}}catch(t){return console.error("[ConditionalLogicService] Error in validateConditionalLogic:",t),{isValid:!1,errors:["Validation failed due to an error"]}}}evaluateConditionalLogic(t,e,A){try{if("always"===t.action)return{shouldShow:!0,evaluatedConditions:[]};if(!t||!t.conditions||0===t.conditions.length)return{shouldShow:!0,evaluatedConditions:[]};const r=t.conditions.map(t=>{try{const r=this.getComponentValue(t.when,e,A);return{condition:t,result:this.evaluateCondition(t,r),componentValue:r}}catch(e){return console.error("[ConditionalLogicService] Error evaluating condition:",e,t),{condition:t,result:!1,componentValue:void 0}}});return{shouldShow:this.determineFinalResult(t,r),evaluatedConditions:r}}catch(t){return console.error("[ConditionalLogicService] Error in evaluateConditionalLogic:",t),{shouldShow:!0,evaluatedConditions:[]}}}getComponentValue(t,e,A){let r=e.find(e=>{var A;return(null===(A=e.basic)||void 0===A?void 0:A.label)===t});return r||(r=e.find(e=>e.id===t)),r?A&&void 0!==A[r.id]?A[r.id]:r.basic&&"defaultValue"in r.basic?r.basic.defaultValue:void 0:A&&void 0!==A[t]?A[t]:void 0}evaluateCondition(t,e){const{operator:A,value:r}=t;if("checked"===r||"notChecked"===r)return this.evaluateCheckboxCondition(e,r);switch(A){case"equals":return this.isEqual(e,r);case"notEquals":return!this.isEqual(e,r);case"isEmpty":return this.isEmpty(e);case"isNotEmpty":return!this.isEmpty(e);case"contains":return this.contains(e,r);case"notContains":return!this.contains(e,r);case"greaterThan":return this.isGreaterThan(e,r);case"lessThan":return this.isLessThan(e,r);case"greaterThanOrEqual":return this.isGreaterThanOrEqual(e,r);case"lessThanOrEqual":return this.isLessThanOrEqual(e,r);default:return!1}}evaluateCheckboxCondition(t,e){const A=this.isCheckboxChecked(t);return"checked"===e?A:"notChecked"===e&&!A}isCheckboxChecked(t){return null!=t&&("boolean"==typeof t?t:"string"==typeof t?"true"===t.toLowerCase()||"1"===t:Array.isArray(t)?t.length>0:"number"==typeof t&&t>0)}determineFinalResult(t,e){let A,r;return A="all"===t.when?e.every(t=>t.result):"any"===t.when&&e.some(t=>t.result),r="show"===t.action?A:"hide"===t.action?!A:(t.action,!0),r}isEqual(t,e){if(t===e)return!0;if(null==t||null==e)return!1;if(Array.isArray(t)&&Array.isArray(e))return t.length===e.length&&t.every((t,A)=>this.isEqual(t,e[A]));if("object"==typeof t&&"object"==typeof e){const A=Object.keys(t),r=Object.keys(e);return A.length===r.length&&A.every(A=>this.isEqual(t[A],e[A]))}return!1}isEmpty(t){return null==t||void 0===t||("string"==typeof t?""===t.trim():Array.isArray(t)?0===t.length:"object"==typeof t&&0===Object.keys(t).length)}contains(t,e){return null!=t&&null!=e&&("string"==typeof t?t.toLowerCase().includes(String(e).toLowerCase()):!!Array.isArray(t)&&t.some(t=>this.isEqual(t,e)))}isGreaterThan(t,e){const A=Number(t),r=Number(e);return!isNaN(A)&&!isNaN(r)&&A>r}isLessThan(t,e){const A=Number(t),r=Number(e);return!isNaN(A)&&!isNaN(r)&&A<r}isGreaterThanOrEqual(t,e){const A=Number(t),r=Number(e);return!isNaN(A)&&!isNaN(r)&&A>=r}isLessThanOrEqual(t,e){const A=Number(t),r=Number(e);return!isNaN(A)&&!isNaN(r)&&A<=r}isValidConditionValue(t,e,A){if(null==t)return["isEmpty","isNotEmpty"].includes(A);switch(e){case"number-input":return!isNaN(Number(t))||["isEmpty","isNotEmpty"].includes(A);case"date-picker":case"datetime-picker":return!isNaN(Date.parse(t))||["isEmpty","isNotEmpty"].includes(A);case"checkbox":return Array.isArray(t)||"string"==typeof t||"number"==typeof t;default:return!0}}createDefaultConditionalLogic(){return{action:"show",when:"all",conditions:[]}}getOperatorDisplayText(t){return{equals:"Is Equal To",notEquals:"Is Not Equal To",contains:"Contains",notContains:"Does Not Contain",isEmpty:"Is Empty",isNotEmpty:"Is Not Empty",greaterThan:"Is Greater Than",lessThan:"Is Less Than",greaterThanOrEqual:"Is Greater Than Or Equal To",lessThanOrEqual:"Is Less Than Or Equal To"}[t]||t}getActionDisplayText(t){return{show:"Show this field when",hide:"Hide this field when",always:"Always show this field"}[t]||t}getConditionalLogicSummary(t,e){try{if(!t||!t.conditions||0===t.conditions.length)return"No conditions";if("always"===t.action)return"Always show";const A=this.getActionDisplayText(t.action),r=t.conditions.map(t=>{var A;try{let r=e.find(e=>{var A;return(null===(A=e.basic)||void 0===A?void 0:A.label)===t.when});r||(r=e.find(e=>e.id===t.when));const n=(null===(A=null==r?void 0:r.basic)||void 0===A?void 0:A.label)||t.when||"Unknown component",i=this.getOperatorDisplayText(t.operator);return`${n} ${i} ${this.formatConditionValue(t.value)}`}catch(t){return console.error("[ConditionalLogicService] Error formatting condition:",t),"Invalid condition"}}),n="all"===t.when?" and ":" or ";return`${A} ${r.join(n)}`}catch(t){return console.error("[ConditionalLogicService] Error in getConditionalLogicSummary:",t),"Error displaying conditions"}}formatConditionValue(t){return null==t?"empty":Array.isArray(t)?`[${t.join(", ")}]`:"string"==typeof t?`"${t}"`:String(t)}}const J=Y.getInstance();const $=new class{constructor(){this.toasts=[],this.listeners=[],this.defaultDuration=3e3,this.timeouts={}}generateId(){return Date.now().toString(36)+Math.random().toString(36).substr(2)}notifyListeners(){this.listeners.forEach(t=>t([...this.toasts]))}addToast(t){try{this.toasts.push(t),this.notifyListeners(),this.timeouts[t.id]=setTimeout(()=>{this.removeToast(t.id)},t.duration||this.defaultDuration)}catch(t){console.error("Error displaying toast message:",t)}}removeToast(t){this.timeouts[t]&&(clearTimeout(this.timeouts[t]),delete this.timeouts[t]),this.toasts=this.toasts.filter(e=>e.id!==t),this.notifyListeners()}showSuccess(t,e=3e3){const A={id:this.generateId(),message:t,type:"success",duration:e};this.addToast(A)}showError(t,e=5e3){const A={id:this.generateId(),message:t,type:"danger",duration:e};this.addToast(A)}showWarning(t,e){const A={id:this.generateId(),message:t,type:"warning",duration:e};this.addToast(A)}showInfo(t,e){const A={id:this.generateId(),message:t,type:"info",duration:e};this.addToast(A)}show(t,e="success",A){const r={id:this.generateId(),message:t,type:e,duration:A};this.addToast(r)}clearAll(){Object.values(this.timeouts).forEach(t=>clearTimeout(t)),this.timeouts={},this.toasts=[],this.notifyListeners()}subscribe(t){return this.listeners.push(t),()=>{this.listeners=this.listeners.filter(e=>e!==t)}}getToasts(){return[...this.toasts]}},Z=({validationErrors:t,fieldId:e,touchedFields:A,formSubmitted:r,properties:n,localValidation:i,isTouched:s,mode:a})=>{const o=t=>{var e,A;const r=n.basic.label||"This field",i=n.name||"",s=null===(e=n.validation)||void 0===e?void 0:e.customValidationMessage;if("number-input"===i)switch(t){case"required":return`${r} is required`;case"lowerLimit":return"Number is below the lower limit";case"upperLimit":return"Number is above the upper limit";default:return""}if(s)return s;const a="date-picker"===i||"datetime-picker"===i?(null===(A=n.basic)||void 0===A?void 0:A.dateTimeMode)||("datetime-picker"===i?"datetime":"date"):null;switch(t){case"required":return`${r} is required`;case"invalidDate":return"time"===a?"Please select a valid time":"datetime"===a?"Please select a valid date and time":"date"===a?"Please select a valid date":`${r} is invalid`;case"minLength":return`${r} must be at least ${n.validation.minLength} characters long`;case"maxLength":return`${r} must be no more than ${n.validation.maxLength} characters long`;case"min":return`${r} must be at least ${n.validation.min}`;case"max":return`${r} must be no more than ${n.validation.max}`;case"lowerLimit":const t=n.validation;return`You are under the limit. ${r} must be at least ${null==t?void 0:t.lowerLimit}`;case"upperLimit":const e=n.validation;return`You crossed the limit. ${r} must be no more than ${null==e?void 0:e.upperLimit}`;case"pattern":return`${r} format is invalid`;case"email":return`${r} must be a valid email address`;default:return`${r} is invalid`}},l=(()=>{var l;if("test"!==a)return"";if(!(s||A[e]||r))return"";if(i&&i.isValid)return"";if(i&&!i.isValid&&Object.keys(i.errors).length>0){const t=Object.keys(i.errors).filter(t=>!0===i.errors[t]);if(t.length>0){const e=t[0],A=n.name||"";return"pattern"===e&&"number-input"===A?"":o(e)}}const c=t[e];if(c&&"string"==typeof c&&""!==c.trim()){const t=n.name||"";if("number-input"===t&&i){const t=n.validation,e=t&&"lowerLimit"in t&&void 0!==t.lowerLimit&&null!==t.lowerLimit&&0!==t.lowerLimit,A=t&&"upperLimit"in t&&void 0!==t.upperLimit&&null!==t.upperLimit&&0!==t.upperLimit;return!c.includes("limit")&&!c.includes("Limit")||e||A?(i.isValid,""):""}if(("date-picker"===t||"datetime-picker"===t)&&c.includes("valid date")){const e=(null===(l=n.basic)||void 0===l?void 0:l.dateTimeMode)||("datetime-picker"===t?"datetime":"date");if("time"===e)return"Please select a valid time";if("datetime"===e)return"Please select a valid date and time"}return c}return""})();return l?X.jsx("div",{className:"form-error-msg",children:l}):null};function tt(t,e,A,r){return new(A||(A=Promise))(function(n,i){function s(t){try{o(r.next(t))}catch(t){i(t)}}function a(t){try{o(r.throw(t))}catch(t){i(t)}}function o(t){var e;t.done?n(t.value):(e=t.value,e instanceof A?e:new A(function(t){t(e)})).then(s,a)}o((r=r.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const et=t=>{if(null==t||""===t)return null;if(t instanceof Date)return isNaN(t.getTime())?null:t;if("number"==typeof t){const e=new Date(t);return isNaN(e.getTime())?null:e}if("string"==typeof t){let e=t.trim();e.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}/)&&(e=e.replace(" ","T"));const A=new Date(e);return isNaN(A.getTime())?null:A}return null};var At;!function(t){t.OPEN="Open",t.IN_PROGRESS="In-Progress",t.REJECTED="Rejected",t.RESOLVE="Resolve"}(At||(At={}));const rt=({isOpen:r,onClose:n,onSuccess:i,component:d,formTemplateId:f,notes:p="",attachments:g=null,issue:m=null,onCreateIssue:v,onUpdateIssue:w,user:B,availableUsers:b=["Priya Das","Maria Garcia","John Smith","Sarah Johnson"],workOrderNumber:y,assetNumber:C,isStandalone:x,isEdit:F})=>{var Q,U,E,N,S,L;const[I,O]=e(""),[k,T]=e(""),[j,H]=e(""),[P,D]=e(""),[M,R]=e("Medium"),[K,V]=e(At.OPEN),[z,G]=e(""),[q,W]=e(""),[Y,J]=e(!1),[Z,rt]=e(g||[]),[nt,it]=e(!1),st=t.useRef(null),at=void 0!==F?F:!!m;A(()=>{(null==m?void 0:m.attachments)&&m.attachments.length>0?rt(m.attachments):g&&rt(g)},[g,m]);const ot=t=>{if(!t)return"Attachment";if(t instanceof File)return t.name;if("string"==typeof t){if(t.startsWith("data:"))return"Attachment";const e=t.split("/");return e[e.length-1]||"Attachment"}return t.fileName||t.filename||t.name||"Attachment"},lt=t=>{if(!t)return null;const e=t=>/\.(jpg|jpeg|png|gif|webp)$/i.test(t),A=t=>t.startsWith("data:image");return t instanceof File?t.type.startsWith("image/")?URL.createObjectURL(t):null:"string"==typeof t?A(t)||e(t)?t:null:t.data&&A(t.data)||t.fileName&&e(t.fileName)&&t.data?t.data:null};A(()=>{var t;if(r)if(m||at){O((null==m?void 0:m.title)||""),T((null==m?void 0:m.description)||""),H((null==m?void 0:m.workOrderNumber)||y||""),D((null==m?void 0:m.assetNumber)||C||""),R((null==m?void 0:m.priority)||"Medium");const t=(null==m?void 0:m.status)||At.OPEN,e=t===At.OPEN||t===At.IN_PROGRESS||t===At.REJECTED||t===At.RESOLVE?t:At.OPEN;V(e),G((null==m?void 0:m.assignTo)||(null==m?void 0:m.assignee)||""),W((null==m?void 0:m.comments)||"")}else d&&(null===(t=d.basic)||void 0===t||t.label,O(""),T(""),W(p||""),y&&H(y),C&&D(C))},[r,d,p,m,y,C]);const ct=t.useMemo(()=>{if(!I.trim())return!1;if(!k.trim())return!1;if(!K)return!1;if(!z)return!1;if(!x){if(!j.trim())return!1;if(!P.trim())return!1}return!0},[I,k,K,z,x,j,P]),ut=t=>tt(void 0,void 0,void 0,function*(){var e;if(m){J(!0);try{const e={title:String(I||"").trim(),description:String(k||"").trim(),workOrderNumber:String(j||"").trim()||void 0,assetNumber:String(P||"").trim()||void 0,formTemplateId:m.formTemplateId||"",component:m.component||{},priority:M,assignee:String(z||"").trim()||void 0,status:t,comments:String(q||"").trim()||""};w&&m._id&&(yield w(m._id,e)),V(t);const A={[At.IN_PROGRESS]:"Issue accepted and moved to In-Progress",[At.RESOLVE]:"Issue resolved successfully",[At.REJECTED]:"Issue rejected"};$.showSuccess(A[t]||"Issue status updated successfully"),i&&i(),n()}catch(t){const A=(null==t?void 0:t.message)||(null===(e=null==t?void 0:t.error)||void 0===e?void 0:e.message)||"Failed to update issue status. Please try again.";$.showError(A)}finally{J(!1)}}});if(!r)return null;const ht=X.jsx("div",{className:"raise-issue-modal-overlay",onClick:n,children:X.jsxs("div",{className:"raise-issue-modal",onClick:t=>t.stopPropagation(),children:[X.jsxs("div",{className:"raise-issue-modal-header",children:[X.jsxs("div",{className:"raise-issue-modal-header-left",children:[X.jsx(s,{className:"raise-issue-modal-icon",size:20}),X.jsx("div",{className:"raise-issue-modal-header-text",children:X.jsx("div",{className:"raise-issue-modal-title-main",children:at?"Edit Issue":"Create Issue"})})]}),X.jsx("button",{className:"raise-issue-modal-close",onClick:n,"aria-label":"Close",children:X.jsx(a,{size:18})})]}),X.jsx("div",{className:"raise-issue-modal-content",children:X.jsxs("div",{className:"raise-issue-fields-grid",children:[at&&(null==m?void 0:m.issueNumber)&&X.jsxs("div",{className:"raise-issue-field",children:[X.jsx("label",{className:"raise-issue-field-label",children:"Issue ID"}),X.jsx("input",{type:"text",className:"raise-issue-field-input raise-issue-field-readonly",value:m.issueNumber,readOnly:!0})]}),X.jsxs("div",{className:"raise-issue-field",children:[X.jsx("label",{className:"raise-issue-field-label",children:"Task"}),X.jsx("input",{type:"text",className:"raise-issue-field-input raise-issue-field-readonly",value:at?(null===(U=null===(Q=null==m?void 0:m.component)||void 0===Q?void 0:Q.basic)||void 0===U?void 0:U.label)||"":(null===(E=null==d?void 0:d.basic)||void 0===E?void 0:E.label)||"",readOnly:!0})]}),X.jsxs("div",{className:"raise-issue-field",children:[X.jsx("label",{className:"raise-issue-field-label",children:"Task Value"}),X.jsx("input",{type:"text",className:"raise-issue-field-input raise-issue-field-readonly",value:at?(null===(S=null===(N=null==m?void 0:m.component)||void 0===N?void 0:N.basic)||void 0===S?void 0:S.value)||"":(null===(L=null==d?void 0:d.basic)||void 0===L?void 0:L.value)||"",readOnly:!0})]}),X.jsxs("div",{className:"raise-issue-field",children:[X.jsxs("label",{className:"raise-issue-field-label",children:["Title ",X.jsx("span",{className:"raise-issue-required",children:"*"})]}),X.jsx("input",{type:"text",className:"raise-issue-field-input "+(at?"raise-issue-field-readonly":""),value:I,onChange:t=>O(t.target.value),placeholder:"Enter issue title",readOnly:at})]}),!x&&X.jsxs("div",{className:"raise-issue-field",children:[X.jsxs("label",{className:"raise-issue-field-label",children:["Work Order ",X.jsx("span",{className:"raise-issue-required",children:"*"})]}),X.jsx("input",{type:"text",className:"raise-issue-field-input "+(at?"raise-issue-field-readonly":""),value:j,onChange:t=>H(t.target.value),placeholder:"N/A",readOnly:at})]}),!x&&X.jsxs("div",{className:"raise-issue-field",children:[X.jsxs("label",{className:"raise-issue-field-label",children:["Asset Number ",X.jsx("span",{className:"raise-issue-required",children:"*"})]}),X.jsx("input",{type:"text",className:"raise-issue-field-input "+(at?"raise-issue-field-readonly":""),value:P,onChange:t=>D(t.target.value),placeholder:"Enter asset number",readOnly:at})]}),X.jsxs("div",{className:"raise-issue-field",children:[X.jsxs("label",{className:"raise-issue-field-label",children:["Raised By ",X.jsx("span",{className:"raise-issue-required",children:"*"})]}),X.jsxs("div",{className:"raise-issue-field-value-with-icon",children:[X.jsx(o,{size:16}),X.jsx("span",{children:B&&`${B.firstName||""} ${B.lastName||""}`.trim()||"User"})]})]}),X.jsxs("div",{className:"raise-issue-field",children:[X.jsx("label",{className:"raise-issue-field-label",children:"Created On"}),X.jsxs("div",{className:"raise-issue-field-value-with-icon",children:[X.jsx(l,{size:16}),X.jsx("span",{children:at&&(null==m?void 0:m.createdAt)?(et(m.createdAt)||new Date).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!0}):(new Date).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!0})})]})]}),X.jsxs("div",{className:"raise-issue-field raise-issue-field-full-width",children:[X.jsxs("label",{className:"raise-issue-field-label",children:["Description ",X.jsx("span",{className:"raise-issue-required",children:"*"})]}),X.jsx("textarea",{className:"raise-issue-field-textarea "+(at?"raise-issue-field-readonly":""),value:k,onChange:t=>T(t.target.value),placeholder:"Enter issue description",rows:4,readOnly:at})]}),X.jsxs("div",{className:"raise-issue-field",children:[X.jsxs("label",{className:"raise-issue-field-label",children:["Status ",X.jsx("span",{className:"raise-issue-required",children:"*"})]}),X.jsxs("select",{className:"raise-issue-field-select "+(at?"":"raise-issue-field-readonly"),value:K,onChange:t=>V(t.target.value),disabled:!at,children:[X.jsx("option",{value:At.OPEN,children:At.OPEN}),X.jsx("option",{value:At.IN_PROGRESS,children:At.IN_PROGRESS}),X.jsx("option",{value:At.REJECTED,children:At.REJECTED}),X.jsx("option",{value:At.RESOLVE,children:At.RESOLVE})]})]}),X.jsxs("div",{className:"raise-issue-field",children:[X.jsxs("label",{className:"raise-issue-field-label",children:["Assign to ",X.jsx("span",{className:"raise-issue-required",children:"*"})]}),X.jsxs("select",{className:"raise-issue-field-select",value:z,onChange:t=>G(t.target.value),children:[X.jsx("option",{value:"",children:"Unassigned"}),b.map(t=>X.jsx("option",{value:t,children:t},t))]})]}),X.jsxs("div",{className:"raise-issue-field raise-issue-field-full-width",children:[X.jsxs("label",{className:"raise-issue-field-label",children:["Priority ",X.jsx("span",{className:"raise-issue-required",children:"*"})]}),X.jsxs("div",{className:"raise-issue-priority-buttons",children:[X.jsx("button",{type:"button",className:"priority-button priority-low "+("Low"===M?"active":""),onClick:()=>R("Low"),children:"Low"}),X.jsx("button",{type:"button",className:"priority-button priority-medium "+("Medium"===M?"active":""),onClick:()=>R("Medium"),children:"Medium"}),X.jsx("button",{type:"button",className:"priority-button priority-high "+("High"===M?"active":""),onClick:()=>R("High"),children:"High"})]})]}),X.jsxs("div",{className:"raise-issue-field raise-issue-field-full-width",children:[X.jsxs("label",{className:"raise-issue-field-label-with-icon",children:[X.jsx(c,{size:16}),X.jsx("span",{children:"Comments"})]}),!q&&X.jsx("div",{className:"raise-issue-no-comments",children:"No comments yet"}),X.jsx("textarea",{className:"raise-issue-field-textarea raise-issue-comments-textarea "+(at?"raise-issue-field-readonly":""),value:q,onChange:t=>W(t.target.value),placeholder:"Add a comment...",rows:4,readOnly:at})]}),X.jsxs("div",{className:"raise-issue-field raise-issue-field-full-width",style:{marginTop:"1rem"},children:[X.jsx("label",{className:"raise-issue-field-label",children:"Attachments"}),X.jsxs("div",{className:"raise-issue-attachments-container",children:[!at&&X.jsxs("div",{className:"raise-issue-dropzone "+(nt?"dragging":""),onDragOver:t=>{t.preventDefault(),it(!0)},onDragLeave:t=>{t.preventDefault(),it(!1)},onDrop:t=>{if(t.preventDefault(),it(!1),t.dataTransfer.files&&t.dataTransfer.files.length>0){const e=Array.from(t.dataTransfer.files);rt(t=>[...t,...e])}},onClick:()=>{var t;return null===(t=st.current)||void 0===t?void 0:t.click()},children:[X.jsx("input",{type:"file",ref:st,style:{display:"none"},onChange:t=>{if(t.target.files&&t.target.files.length>0){const e=Array.from(t.target.files);rt(t=>[...t,...e]),st.current&&(st.current.value="")}},multiple:!0}),X.jsx("div",{className:"raise-issue-dropzone-icon",children:X.jsx(u,{size:24})}),X.jsx("div",{className:"raise-issue-dropzone-text",children:"Click to upload or drag and drop"}),X.jsx("div",{className:"raise-issue-dropzone-hint",children:"PNG, JPG up to 10MB"})]}),Z.length>0&&X.jsx("div",{className:"raise-issue-attachments-list",children:Z.map((t,e)=>X.jsxs("div",{className:"raise-issue-attachment-item",children:[X.jsx("div",{className:"raise-issue-attachment-thumbnail",children:lt(t)?X.jsx("img",{src:lt(t),alt:"Thumbnail"}):X.jsx(h,{size:20,color:"#9ca3af"})}),X.jsxs("div",{className:"raise-issue-attachment-info",children:[X.jsx("span",{className:"attachment-name",title:ot(t),children:ot(t)}),t instanceof File&&X.jsxs("span",{className:"attachment-size",children:[(t.size/1024).toFixed(1)," KB"]})]}),!at&&X.jsx("button",{type:"button",className:"attachment-remove-btn",onClick:()=>(t=>{rt(e=>e.filter((e,A)=>A!==t))})(e),title:"Remove",children:X.jsx(a,{size:12})})]},e))})]})]})]})}),X.jsx("div",{className:"raise-issue-modal-actions",children:X.jsxs("div",{className:"raise-issue-modal-actions-buttons",children:[at&&m&&X.jsxs(X.Fragment,{children:[K===At.OPEN&&X.jsx("button",{className:"raise-issue-modal-button raise-issue-modal-button-accept",onClick:()=>tt(void 0,void 0,void 0,function*(){yield ut(At.IN_PROGRESS)}),disabled:Y,children:Y?"Processing...":"Accept"}),K===At.IN_PROGRESS&&X.jsx("button",{className:"raise-issue-modal-button raise-issue-modal-button-resolve",onClick:()=>tt(void 0,void 0,void 0,function*(){yield ut(At.RESOLVE)}),disabled:Y,children:Y?"Processing...":"Resolve"}),(K===At.OPEN||K===At.IN_PROGRESS)&&X.jsx("button",{className:"raise-issue-modal-button raise-issue-modal-button-reject",onClick:()=>tt(void 0,void 0,void 0,function*(){yield ut(At.REJECTED)}),disabled:Y,children:Y?"Processing...":"Reject"})]}),!at&&X.jsx("button",{className:"raise-issue-modal-button raise-issue-modal-button-save "+(ct?"":"disabled"),onClick:()=>tt(void 0,void 0,void 0,function*(){var t,e,A,r,s,a,o;if(String(I||"").trim())if(String(k||"").trim())if(x||String(j||"").trim())if(x||String(P||"").trim())if(String(z||"").trim()){J(!0);try{if(at&&m){const s={title:String(I||"").trim(),description:String(k||"").trim(),workOrderNumber:String(j||"").trim()||void 0,assetNumber:String(P||"").trim()||void 0,formTemplateId:m.formTemplateId||"",component:m.component||{},priority:M,assignTo:String(z||"").trim()||void 0,status:K,comments:String(q||"").trim()||"",task:(null===(e=null===(t=m.component)||void 0===t?void 0:t.basic)||void 0===e?void 0:e.label)||"",taskValue:(null===(r=null===(A=m.component)||void 0===A?void 0:A.basic)||void 0===r?void 0:r.value)||""};w&&m._id&&(yield w(m._id,s)),$.showSuccess("Issue updated successfully"),i&&i(),n()}else{if(!d)return $.showError("Component is required"),void J(!1);if(!f||""===String(f||"").trim())return $.showError("Form template is required"),void J(!1);const t=Object.assign(Object.assign({},d),{basic:Object.assign(Object.assign({},d.basic),{comments:String(p||"")})}),e=B?`${B.firstName||""} ${B.lastName||""}`.trim():"User",A={title:String(I||"").trim(),workOrderNumber:String(j||"").trim()||void 0,assetNumber:String(P||"").trim()||void 0,component:t,description:String(k||"").trim(),formTemplateId:f,assignTo:String(z||"").trim()||void 0,priority:M,status:K,comments:String(q||"").trim()||"",createdBy:e,task:(null===(s=null==d?void 0:d.basic)||void 0===s?void 0:s.label)||"",taskValue:(null===(a=null==d?void 0:d.basic)||void 0===a?void 0:a.value)||""};let r;if(v&&(r=yield v(A,Z)),$.showSuccess("Issue raised successfully"),i){const t=Object.assign({_id:(null==r?void 0:r._id)||"temp-id",issueNumber:(null==r?void 0:r.issueNumber)||"",title:A.title,description:A.description,status:A.status,priority:A.priority,createdAt:(null==r?void 0:r.createdAt)||(new Date).toISOString(),updatedAt:(null==r?void 0:r.updatedAt)||(new Date).toISOString(),component:A.component,workOrderNumber:A.workOrderNumber,assetNumber:A.assetNumber,assignee:A.assignTo,comments:A.comments,attachments:(null==r?void 0:r.attachments)||Z},r);i(t)}n()}}catch(t){const e=(null==t?void 0:t.message)||(null===(o=null==t?void 0:t.error)||void 0===o?void 0:o.message)||(at?"Failed to update issue. Please try again.":"Failed to raise issue. Please try again.");$.showError(e)}finally{J(!1)}}else $.showError("Assignee is required");else $.showError("Asset Number is required");else $.showError("Work Order is required");else $.showError("Description is required");else $.showError("Title is required")}),disabled:Y||!ct,children:Y?"Creating...":"Create Issue"})]})})]})});return _(ht,document.body)},nt=({component:t,condition:n,currentValue:i,thresholdValue:a,formTemplateId:o,workOrderNumber:l,assetNumber:c,user:u,onIssueRaised:h,isIssueRaised:d=!1,compact:f=!1})=>{const[p,g]=e(!1),[m,v]=e(null),[w,B]=e(!1),[b,y]=e(!1);A(()=>{d&&y(!0)},[d]),A(()=>{y(!1)},[null==n?void 0:n.id]);const C=t=>({greaterThan:">",lessThan:"<",greaterThanOrEqual:"≥",lessThanOrEqual:"≤",equals:"=",notEquals:"≠"}[t]||t),x=r(()=>tt(void 0,void 0,void 0,function*(){if(d||b){if(m)return void g(!0);B(!0);try{v(null),g(!0)}catch(t){console.error("Error fetching issue:",t),$.showError("Failed to load issue details")}finally{B(!1)}}else v(null),g(!0)}),[d,b,o,t,m]),F=r(()=>{g(!1),d||b||v(null)},[d,b]),Q=r(t=>{g(!1),v(t||null),y(!0),h&&(null==n?void 0:n.id)&&h(n.id)},[h,n]);return d||b?X.jsx(X.Fragment,{children:p&&X.jsx(rt,{isOpen:p,onClose:F,onSuccess:Q,component:t,formTemplateId:o,workOrderNumber:l,assetNumber:c,user:u,notes:"",attachments:null,issue:m})}):f?X.jsxs(X.Fragment,{children:[X.jsxs("div",{className:"threshold-alert threshold-alert-unresolved threshold-alert-compact",children:[X.jsx("div",{className:"threshold-alert-border"}),X.jsxs("div",{className:"threshold-alert-content-compact",children:[X.jsx(s,{className:"threshold-alert-icon-compact",size:14}),X.jsx("span",{className:"threshold-alert-message-compact",children:`Threshold ${C(n.operator)} ${a}`}),X.jsx("button",{type:"button",onClick:x,className:"threshold-alert-raise-issue-btn-compact",title:"Raise Issue",children:"Raise Issue"})]})]}),p&&X.jsx(rt,{isOpen:p,onClose:F,onSuccess:Q,component:t,formTemplateId:o,workOrderNumber:l,assetNumber:c,user:u,notes:"",attachments:null,issue:m})]}):X.jsxs(X.Fragment,{children:[X.jsxs("div",{className:"threshold-alert threshold-alert-unresolved",children:[X.jsx("div",{className:"threshold-alert-border"}),X.jsxs("div",{className:"threshold-alert-content",children:[X.jsx("div",{className:"threshold-alert-header",children:X.jsxs("div",{className:"threshold-alert-title-group",children:[X.jsx(s,{className:"threshold-alert-icon",size:20}),X.jsx("span",{className:"threshold-alert-title",children:"Threshold Condition Met - Action Required"})]})}),X.jsxs("div",{className:"threshold-alert-message",children:[(()=>{var e;const A=C(n.operator);return`${(null===(e=t.basic)||void 0===e?void 0:e.label)||"Value"}: Value ${i} exceeds threshold ${A} ${a}`})(),X.jsx("span",{className:"threshold-alert-warning",children:" You must raise an issue before submitting the form."})]}),X.jsx("div",{className:"threshold-alert-buttons",children:X.jsx("button",{type:"button",onClick:x,className:"threshold-alert-raise-issue-btn",children:"Raise Issue Now"})})]})]}),p&&X.jsx(rt,{isOpen:p,onClose:F,onSuccess:Q,component:t,formTemplateId:o,workOrderNumber:l,assetNumber:c,user:u,notes:"",attachments:null,issue:m})]})},it=({id:t,properties:s,validationErrors:a={},formValue:o="",inputType:l="text",readonly:c=!1,disabled:u=!1,touchedFields:h={},formSubmitted:d=!1,mode:f="test",onValueChange:p,onBlur:g,onFocus:m,className:v="",hideLabel:w=!1,formTemplateId:B,onThresholdIssueRaised:b,raisedThresholdIssues:y=new Set,workOrderNumber:C,assetNumber:x,user:F})=>{var Q,U,E,N,S;const L=t=>null==t?"":"string"==typeof t?t:"number"==typeof t||"boolean"==typeof t?String(t):"object"==typeof t?Array.isArray(t)?"":"value"in t?L(t.value):"label"in t?L(t.label):"":String(t||""),I=n(t),_=n(null);A(()=>{t!==I.current&&(console.warn(`[DfFormInput] Component ID changed from ${I.current} to ${t}`),I.current=t)},[t]);const O=L(o||(null===(Q=null==s?void 0:s.basic)||void 0===Q?void 0:Q.defaultValue)||""),[k,T]=e(O),[j,H]=e(!1),[P,D]=e(!1),[M,R]=e(new Set),[K,V]=e(O),z=()=>{if(l)return l;const t=null==s?void 0:s.name;return"text-input"===t?"text":"number-input"===t?"number":"email-input"===t?"email":"text"},G=r(t=>{const e=(()=>{var t;const e={};if((null===(t=null==s?void 0:s.validation)||void 0===t?void 0:t.required)&&(e.required=!0),"email"===z()&&(e.email=!0),"text"===z()){const t=s.validation;(null==t?void 0:t.minLength)&&(e.minLength=t.minLength),(null==t?void 0:t.maxLength)&&(e.maxLength=t.maxLength)}if("number"===z()){const t=s.validation;t&&"lowerLimit"in t&&void 0!==t.lowerLimit&&null!==t.lowerLimit&&0!==t.lowerLimit&&(e.lowerLimit=t.lowerLimit),t&&"upperLimit"in t&&void 0!==t.upperLimit&&null!==t.upperLimit&&0!==t.upperLimit&&(e.upperLimit=t.upperLimit)}return e})(),A={};let r=!0;const n="string"==typeof t?t:null!=t?String(t):"";if(!e.required||n&&""!==n.trim()||(A.required=!0,r=!1),e.email&&n&&!/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(n)&&(A.email=!0,r=!1),e.minLength&&n&&n.length<e.minLength&&(A.minLength=!0,r=!1),e.maxLength&&n&&n.length>e.maxLength&&(A.maxLength=!0,r=!1),"number"===z())if(delete A.pattern,delete A.min,delete A.max,n&&""!==n.trim()){const t=n.trim(),i=parseFloat(t);isNaN(i)||("lowerLimit"in e&&void 0!==e.lowerLimit&&null!==e.lowerLimit&&0!==e.lowerLimit&&i<e.lowerLimit&&(A.lowerLimit=!0,r=!1),"upperLimit"in e&&void 0!==e.upperLimit&&null!==e.upperLimit&&0!==e.upperLimit&&i>e.upperLimit&&(A.upperLimit=!0,r=!1))}else delete A.lowerLimit,delete A.upperLimit;return{isValid:r,errors:A}},[s,z]),q=r(e=>{const A="string"==typeof e?e:null!=e?String(e):"";if(T(A),p){const e=G(A),r=I.current,n={id:r,value:A,isValid:e.isValid,errors:e.errors};r!==t&&console.error(`[DfFormInput] ID mismatch in handleValueChange! ref: ${r}, prop: ${t}`),p(n)}},[t,p,G,I]);A(()=>{j&&(h[t]=!0)},[j,t,h]),A(()=>{var t;if("edit"===f){H(!1);const e=(null===(t=null==s?void 0:s.basic)||void 0===t?void 0:t.defaultValue)||"";T(e)}else"test"===f&&(H(!1),T(""))},[f,null===(U=null==s?void 0:s.basic)||void 0===U?void 0:U.defaultValue]),A(()=>{var e;const A=I.current,r=L(o||(null===(e=null==s?void 0:s.basic)||void 0===e?void 0:e.defaultValue)||"");r===k||P||""===r&&""!==String(k||"").trim()?""===r&&String(k||"").trim():null!=o&&(A===t?T(r):console.error(`[DfFormInput] ID mismatch! componentIdRef: ${A}, prop id: ${t}`))},[o,k,P,null===(E=null==s?void 0:s.basic)||void 0===E?void 0:E.defaultValue,t]),A(()=>{d&&H(!0)},[d]),A(()=>{"test"!==f&&T("")},[f]);const W=r((t,e)=>{if(!e||""===e)return!1;const A="string"==typeof e?parseFloat(e):e,r="string"==typeof t.value?parseFloat(t.value):t.value;if(isNaN(A)||isNaN(r))return!1;switch(t.operator){case"greaterThan":return A>r;case"lessThan":return A<r;case"greaterThanOrEqual":return A>=r;case"lessThanOrEqual":return A<=r;case"equals":return A===r;case"notEquals":return A!==r;default:return!1}},[]),Y=i(()=>{var t;return(null===(t=null==s?void 0:s.condition)||void 0===t?void 0:t.conditions)||[]},[null==s?void 0:s.condition]);A(()=>{k!==K&&(R(new Set),V(k))},[k,K]);const J=i(()=>{if("test"!==f||!k||""===k)return null;const t=Y.filter(t=>W(t,k));if(0===t.length)return null;for(const e of t)if(!M.has(e.id))return e;return null},[k,Y,M,f,W,y]),$=r(t=>{R(e=>new Set(e).add(t))},[]),tt=z(),et=u||c||(null===(N=null==s?void 0:s.validation)||void 0===N?void 0:N.readonly);return X.jsxs(X.Fragment,{children:[X.jsxs("div",{className:`form-group ${(()=>{var t;return"left"===(null===(t=null==s?void 0:s.styles)||void 0===t?void 0:t.labelAlignment)?"label-left":"label-top"})()}`,children:[!w&&s.basic.label&&X.jsxs("label",{htmlFor:t,className:"form-label",children:[s.basic.label,s.validation.required&&X.jsx("span",{className:"required-indicator",children:"*"})]}),X.jsxs("div",{className:"input-wrapper",ref:_,children:[X.jsx("input",{type:tt,id:t,value:k,onChange:t=>{const e=t.target.value;q(e)},onFocus:()=>{D(!0),m&&m()},onBlur:()=>{if(D(!1),H(!0),"test"===f&&p){const e="string"==typeof k?k:null!=k?String(k):"",A=G(e),r={id:t,value:e,isValid:A.isValid,errors:A.errors};p(r)}g&&g()},placeholder:s.basic.placeholder,disabled:et,readOnly:c||(null===(S=null==s?void 0:s.validation)||void 0===S?void 0:S.readonly),className:(()=>{const e="form-control";if("test"===f){const A="string"==typeof k?k:null!=k?String(k):"",r=G(A);if(r.isValid)return`${e} ${v}`.trim();const n=!r.isValid&&j,i=a[t]&&(j||d)&&!r;return`${e} ${n||i?"is-invalid":""} ${v}`.trim()}return`${e} ${v}`.trim()})()}),X.jsx(Z,{validationErrors:a,fieldId:t,touchedFields:h,formSubmitted:d,properties:s,localValidation:G(k),isTouched:j,mode:f})]})]}),J&&"test"===f&&(()=>{var t,e,A,r;const n=(null==y?void 0:y.has(J.id))||!1,i=null!==(null===(t=_.current)||void 0===t?void 0:t.closest(".table-cell"))||null!==(null===(e=_.current)||void 0===e?void 0:e.closest(".cell-content"))||null!==(null===(A=_.current)||void 0===A?void 0:A.closest(".datagrid-table-view"))||null!==(null===(r=_.current)||void 0===r?void 0:r.closest(".datagrid-list-view"))||v.includes("table-cell")||v.includes("cell-content");return X.jsx(nt,{component:s,condition:J,currentValue:k,thresholdValue:J.value,formTemplateId:B,workOrderNumber:C,assetNumber:x,user:F,onDismiss:()=>$(J.id),onIssueRaised:b,isIssueRaised:n,compact:i},`${J.id}-${n}`)})()]})},st=({id:t,properties:n,validationErrors:i={},formValue:s="",readonly:a=!1,disabled:o=!1,touchedFields:l={},formSubmitted:c=!1,mode:u="preview",onValueChange:h,onBlur:d,onFocus:f,className:p="",hideLabel:g=!1})=>{var m,v,w;const[B,b]=e(s),[y,C]=e(!1),x=r(t=>{var e,A,r;const i={};let s=!0;return!(null===(e=null==n?void 0:n.validation)||void 0===e?void 0:e.required)||t&&""!==t.trim()||(i.required=!0,s=!1),(null===(A=null==n?void 0:n.validation)||void 0===A?void 0:A.minLength)&&t&&t.length<n.validation.minLength&&(i.minLength=!0,s=!1),(null===(r=null==n?void 0:n.validation)||void 0===r?void 0:r.maxLength)&&t&&t.length>n.validation.maxLength&&(i.maxLength=!0,s=!1),{isValid:s,errors:i}},[n]),F=r(e=>{if(b(e),h){const A=x(e),r={id:t,value:e,isValid:A.isValid,errors:A.errors};h(r)}},[t,h,x]);A(()=>{y&&(l[t]=!0)},[y,t,l]),A(()=>{""===B&&""!==s&&b(s)},[s]),A(()=>{c&&C(!0)},[c]),A(()=>{"test"!==u&&b("")},[u]);const Q=o||a||(null===(m=null==n?void 0:n.validation)||void 0===m?void 0:m.readonly),U=(null===(v=null==n?void 0:n.validation)||void 0===v?void 0:v.rows)||4;return X.jsxs("div",{className:`form-group ${(()=>{var t;return"left"===(null===(t=null==n?void 0:n.styles)||void 0===t?void 0:t.labelAlignment)?"label-left":"label-top"})()}`,children:[!g&&n.basic.label&&X.jsxs("label",{htmlFor:t,className:"form-label",children:[n.basic.label,n.validation.required&&X.jsx("span",{className:"required-indicator",children:"*"})]}),X.jsxs("div",{className:"input-wrapper",children:[X.jsx("textarea",{id:t,value:B,onChange:t=>{const e=t.target.value;F(e)},onFocus:()=>{f&&f()},onBlur:()=>{C(!0),d&&d()},placeholder:n.basic.placeholder,disabled:Q,readOnly:a||(null===(w=null==n?void 0:n.validation)||void 0===w?void 0:w.readonly),rows:U,className:`form-textarea ${!x(B).isValid&&y?"is-invalid":""} ${p}`.trim()}),X.jsx(Z,{validationErrors:i,fieldId:t,touchedFields:l,formSubmitted:c,properties:n,localValidation:x(B),isTouched:y,mode:u})]})]})},at=({id:t,properties:n,validationErrors:i={},formValue:s="",readonly:a=!1,disabled:o=!1,touchedFields:l={},formSubmitted:c=!1,mode:u="preview",onValueChange:h,onBlur:d,onFocus:f,className:p="",hideLabel:g=!1})=>{var m,v;const[w,B]=e(s),[b,y]=e(!1),C=(null===(m=null==n?void 0:n.validation)||void 0===m?void 0:m.multiple)||!1,x=r(t=>{var e;const A={};let r=!0;return(null===(e=null==n?void 0:n.validation)||void 0===e?void 0:e.required)&&(C?Array.isArray(t)&&0!==t.length||(A.required=!0,r=!1):(!t||"string"==typeof t&&""===t.trim())&&(A.required=!0,r=!1)),{isValid:r,errors:A}},[n,C]),F=r(e=>{if(B(e),h){const A=x(e),r={id:t,value:e,isValid:A.isValid,errors:A.errors};h(r)}},[t,h,x]);A(()=>{b&&(l[t]=!0)},[b,t,l]),A(()=>{JSON.stringify(s)!==JSON.stringify(w)&&B(s)},[s,w]),A(()=>{c&&y(!0)},[c]);const Q=o||a||(null===(v=null==n?void 0:n.validation)||void 0===v?void 0:v.readonly);return X.jsxs("div",{className:`form-group ${(()=>{var t;return"left"===(null===(t=null==n?void 0:n.styles)||void 0===t?void 0:t.labelAlignment)?"label-left":"label-top"})()}`,children:[!g&&n.basic.label&&X.jsxs("label",{htmlFor:t,className:"form-label",children:[n.basic.label,n.validation.required&&X.jsx("span",{className:"required-indicator",children:"*"})]}),X.jsxs("div",{className:"input-wrapper",children:[X.jsxs("select",{id:t,value:w,onChange:t=>{if(C){const e=Array.from(t.target.selectedOptions,t=>t.value);F(e)}else F(t.target.value)},onFocus:()=>{f&&f()},onBlur:()=>{y(!0),d&&d()},disabled:Q,multiple:C,className:`form-select ${!x(w).isValid&&b?"is-invalid":""} ${p}`.trim(),children:[!C&&X.jsx("option",{value:"",children:n.basic.placeholder||"Select an option"}),(n.options||[]).map((t,e)=>X.jsx("option",{value:t.value,disabled:t.disabled,children:t.label},e))]}),X.jsx(Z,{validationErrors:i,fieldId:t,touchedFields:l,formSubmitted:c,properties:n,localValidation:x(w),isTouched:b,mode:u})]})]})},ot=({id:t,properties:n,validationErrors:i={},formValue:s=[],readonly:a=!1,disabled:o=!1,touchedFields:l={},formSubmitted:c=!1,mode:u="preview",onValueChange:h,onBlur:d,onFocus:f,className:p="",hideLabel:g=!1})=>{var m,v,w;const[B,b]=e(!1),y=Array.isArray(s)?s:[],C=r(t=>{var e;const A={};let r=!0;return(null===(e=null==n?void 0:n.validation)||void 0===e?void 0:e.required)&&0===t.length&&(A.required=!0,r=!1),{isValid:r,errors:A}},[n]),x=r(e=>{if(h){const A=C(e),r={id:t,value:e,isValid:A.isValid,errors:A.errors};h(r)}},[t,h,C,y]),F=(t,e)=>{let A;A=e?[...y,t]:y.filter(e=>e!==t),x(A)},Q=()=>{f&&f()},U=()=>{b(!0),d&&d()};A(()=>{B&&(l[t]=!0)},[B,t,l]),A(()=>{},[s,t,y]),A(()=>{c&&b(!0)},[c]);const E=o||a||(null===(m=null==n?void 0:n.validation)||void 0===m?void 0:m.readonly);return X.jsx(X.Fragment,{children:X.jsx("div",{className:`form-group checkbox-group ${(()=>{var t;return"left"===(null===(t=null==n?void 0:n.styles)||void 0===t?void 0:t.labelAlignment)?"label-left":"label-top"})()} ${(()=>{var t;return(null===(t=null==n?void 0:n.basic)||void 0===t?void 0:t.inlineLayout)?"inline-layout":"vertical-layout"})()} ${p}`,children:!g&&n.basic.label?X.jsxs(X.Fragment,{children:[X.jsxs("label",{className:"form-label",children:[n.basic.label,n.validation.required&&X.jsx("span",{className:"required-indicator",children:"*"})]}),X.jsxs("div",{className:"input-wrapper",children:[X.jsx("div",{className:"mt-2 "+((null===(v=null==n?void 0:n.basic)||void 0===v?void 0:v.inlineLayout)?"inline-options-grid":"space-y-2"),children:(n.options||[]).map((e,A)=>X.jsxs("div",{className:"form-check",children:[X.jsx("input",{type:"checkbox",id:`${t}-${A}`,name:t,value:e.value,checked:y.includes(e.value),onChange:t=>{F(e.value,t.target.checked)},onFocus:Q,onBlur:U,disabled:E||e.disabled,className:"form-check-input"}),X.jsx("label",{htmlFor:`${t}-${A}`,className:"form-check-label",children:e.label})]},A))}),X.jsx(Z,{validationErrors:i,fieldId:t,touchedFields:l,formSubmitted:c,properties:n,localValidation:C(y),isTouched:B,mode:u})]})]}):X.jsxs("div",{className:"input-wrapper",children:[X.jsx("div",{className:"mt-2 "+((null===(w=null==n?void 0:n.basic)||void 0===w?void 0:w.inlineLayout)?"inline-options-grid":"space-y-2"),children:(n.options||[]).map((e,A)=>X.jsxs("div",{className:"form-check",children:[X.jsx("input",{type:"checkbox",id:`${t}-${A}`,name:t,value:e.value,checked:y.includes(e.value),onChange:t=>{F(e.value,t.target.checked)},onFocus:Q,onBlur:U,disabled:E||e.disabled,className:"form-check-input"}),X.jsx("label",{htmlFor:`${t}-${A}`,className:"form-check-label",children:e.label})]},A))}),X.jsx(Z,{validationErrors:i,fieldId:t,touchedFields:l,formSubmitted:c,properties:n,localValidation:C(y),isTouched:B,mode:u})]})})})},lt=({id:t,properties:n,validationErrors:i={},formValue:s="",readonly:a=!1,disabled:o=!1,touchedFields:l={},formSubmitted:c=!1,mode:u="preview",onValueChange:h,onBlur:d,onFocus:f,className:p="",hideLabel:g=!1})=>{var m,v,w;const[B,b]=e(s),[y,C]=e(!1),x=r(t=>{var e;const A={};let r=!0;return!(null===(e=null==n?void 0:n.validation)||void 0===e?void 0:e.required)||t&&""!==t.trim()||(A.required=!0,r=!1),{isValid:r,errors:A}},[n]),F=r(e=>{if(b(e),h){const A=x(e),r={id:t,value:e,isValid:A.isValid,errors:A.errors};h(r)}},[t,h,x]),Q=t=>{F(t)},U=()=>{f&&f()},E=()=>{C(!0),d&&d()};A(()=>{y&&(l[t]=!0)},[y,t,l]),A(()=>{s!==B&&b(s)},[s,B]),A(()=>{c&&C(!0)},[c]);const N=o||a||(null===(m=null==n?void 0:n.validation)||void 0===m?void 0:m.readonly);return X.jsx(X.Fragment,{children:X.jsx("div",{className:`form-group radio-group ${(()=>{var t;return"left"===(null===(t=null==n?void 0:n.styles)||void 0===t?void 0:t.labelAlignment)?"label-left":"label-top"})()} ${(()=>{var t;return(null===(t=null==n?void 0:n.basic)||void 0===t?void 0:t.inlineLayout)?"inline-layout":"vertical-layout"})()} ${p}`,children:!g&&n.basic.label?X.jsxs(X.Fragment,{children:[X.jsxs("label",{className:"form-label",children:[n.basic.label,n.validation.required&&X.jsx("span",{className:"required-indicator",children:"*"})]}),X.jsxs("div",{className:"input-wrapper",children:[X.jsx("div",{className:"mt-2 "+((null===(v=null==n?void 0:n.basic)||void 0===v?void 0:v.inlineLayout)?"inline-options-grid":"space-y-2"),children:(n.options||[]).map((e,A)=>X.jsxs("div",{className:"form-check",children:[X.jsx("input",{type:"radio",id:`${t}-${A}`,name:t,value:e.value,checked:B===e.value,onChange:()=>Q(e.value),onFocus:U,onBlur:E,disabled:N||e.disabled,className:"form-check-input"}),X.jsx("label",{htmlFor:`${t}-${A}`,className:"form-check-label",children:e.label})]},A))}),X.jsx(Z,{validationErrors:i,fieldId:t,touchedFields:l,formSubmitted:c,properties:n,localValidation:x(B),isTouched:y,mode:u})]})]}):X.jsxs("div",{className:"input-wrapper",children:[X.jsx("div",{className:"mt-2 "+((null===(w=null==n?void 0:n.basic)||void 0===w?void 0:w.inlineLayout)?"inline-options-grid":"space-y-2"),children:(n.options||[]).map((e,A)=>X.jsxs("div",{className:"form-check",children:[X.jsx("input",{type:"radio",id:`${t}-${A}`,name:t,value:e.value,checked:B===e.value,onChange:()=>Q(e.value),onFocus:U,onBlur:E,disabled:N||e.disabled,className:"form-check-input"}),X.jsx("label",{htmlFor:`${t}-${A}`,className:"form-check-label",children:e.label})]},A))}),X.jsx(Z,{validationErrors:i,fieldId:t,touchedFields:l,formSubmitted:c,properties:n,localValidation:x(B),isTouched:y,mode:u})]})})})},ct=({id:t,properties:n,validationErrors:i={},formValue:s="",readonly:a=!1,disabled:o=!1,touchedFields:l={},formSubmitted:c=!1,mode:u="preview",onValueChange:h,onBlur:d,onFocus:f,className:p="",hideLabel:g=!1})=>{var m;const[v,w]=e(s),[B,b]=e(!1),y=r(t=>{var e;const A={};let r=!0;return!(null===(e=null==n?void 0:n.validation)||void 0===e?void 0:e.required)||t&&""!==t.trim()||(A.required=!0,r=!1),{isValid:r,errors:A}},[n]),C=r(e=>{if(w(e),b(!0),h){const A=y(e),r={id:t,value:e,isValid:A.isValid,errors:A.errors};h(r)}},[t,h,y]),x=()=>{f&&f()},F=()=>{b(!0),d&&d()};A(()=>{B&&(l[t]=!0)},[B,t,l]),A(()=>{s!==v&&w(s)},[s,v]),A(()=>{c&&b(!0)},[c]);const Q=()=>{var t;return(null===(t=null==n?void 0:n.basic)||void 0===t?void 0:t.inlineLayout)?"inline-layout":"grid-layout"},U=t=>{const e=null==t?void 0:t.toLowerCase();return"pass"===e||"yes"===e?"pass":"fail"===e||"no"===e?"fail":"pass"},E=t=>{if(void 0!==(null==t?void 0:t.icon)&&""!==t.icon)return t.icon;return"pass"===U((null==t?void 0:t.value)||t)?"✓":"×"},N=(t,e)=>(null==t?void 0:t.color)||(null==t?void 0:t.backgroundColor)?{color:e?"#ffffff":t.color||"#00814b",backgroundColor:e?t.color||"#00814b":t.backgroundColor||"#34bd4914",borderColor:t.color||"#00814b"}:{},S=t=>{if((null==t?void 0:t.color)||(null==t?void 0:t.backgroundColor))return"segment-button-label segment-button-custom";return"segment-button-label "+("pass"===U((null==t?void 0:t.value)||t)?"pass-button":"fail-button")},L=o||a||(null===(m=null==n?void 0:n.validation)||void 0===m?void 0:m.readonly);return X.jsxs(X.Fragment,{children:[X.jsx("div",{className:`form-group segment-group ${(()=>{var t;return"left"===(null===(t=null==n?void 0:n.styles)||void 0===t?void 0:t.labelAlignment)?"label-left":"label-top"})()} ${p}`,children:!g&&n.basic.label?X.jsxs(X.Fragment,{children:[X.jsxs("label",{className:"form-label",children:[n.basic.label,n.validation.required&&X.jsx("span",{className:"required-indicator",children:"*"})]}),X.jsx("div",{className:"form-segment-wrapper",children:X.jsx("div",{className:`form-segment-container ${Q()}`,children:(n.options||[]).map((e,A)=>{const r=v===e.value,n=N(e,r),i=S(e),s=E(e);return X.jsxs("div",{className:"form-segment-option "+(r?"selected":""),children:[X.jsx("input",{type:"radio",id:`${t}_option_${A}`,name:t,value:e.value,checked:r,onChange:()=>!L&&!e.disabled&&C(e.value),onFocus:x,onBlur:F,disabled:L||e.disabled,className:"form-segment-radio"}),X.jsxs("label",{htmlFor:`${t}_option_${A}`,className:i,style:Object.keys(n).length>0?n:void 0,children:[s&&X.jsx("span",{className:"segment-icon",children:s}),X.jsx("span",{className:"segment-text",children:e.value})]})]},A)})})})]}):X.jsx("div",{className:"form-segment-wrapper",children:X.jsx("div",{className:`form-segment-container ${Q()}`,children:(n.options||[]).map((e,A)=>{const r=v===e.value,n=N(e,r),i=S(e),s=E(e);return X.jsxs("div",{className:"form-segment-option "+(r?"selected":""),children:[X.jsx("input",{type:"radio",id:`${t}_option_${A}`,name:t,value:e.value,checked:r,onChange:()=>!L&&!e.disabled&&C(e.value),onFocus:x,onBlur:F,disabled:L||e.disabled,className:"form-segment-radio"}),X.jsxs("label",{htmlFor:`${t}_option_${A}`,className:i,style:Object.keys(n).length>0?n:void 0,children:[s&&X.jsx("span",{className:"segment-icon",children:s}),X.jsx("span",{className:"segment-text",children:e.value})]})]},A)})})})}),X.jsx(Z,{validationErrors:i,fieldId:t,touchedFields:l,formSubmitted:c,properties:n,localValidation:y(v),isTouched:B,mode:u})]})},ut=({id:t,properties:n,validationErrors:i={},formValue:s="",readonly:a=!1,disabled:o=!1,touchedFields:l={},formSubmitted:c=!1,mode:u="preview",onValueChange:h,onBlur:d,onFocus:f,className:p="",hideLabel:g=!1})=>{var m,v,w,B,b;const y=r(t=>{var e,A;if(!t)return"";if("string"==typeof t){if(/^\d{4}-\d{2}-\d{2}$/.test(t))return t;if(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/.test(t))return t;const A=et(t);if(A&&!isNaN(A.getTime())){const t=n.name||"",r=(null===(e=n.basic)||void 0===e?void 0:e.dateTimeMode)||("datetime-picker"===t?"datetime":"date");if("datetime"===r){return`${A.getFullYear()}-${String(A.getMonth()+1).padStart(2,"0")}-${String(A.getDate()).padStart(2,"0")}T${String(A.getHours()).padStart(2,"0")}:${String(A.getMinutes()).padStart(2,"0")}`}if("time"===r){return`${String(A.getHours()).padStart(2,"0")}:${String(A.getMinutes()).padStart(2,"0")}`}return`${A.getFullYear()}-${String(A.getMonth()+1).padStart(2,"0")}-${String(A.getDate()).padStart(2,"0")}`}return t}if(t instanceof Date){if(isNaN(t.getTime()))return"";const e=n.name||"",r=(null===(A=n.basic)||void 0===A?void 0:A.dateTimeMode)||("datetime-picker"===e?"datetime":"date");if("datetime"===r){return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}T${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}if("time"===r){return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`}if("object"==typeof t&&null!==t){if("value"in t&&t.value)return y(t.value);if("date"in t&&t.date)return y(t.date);try{const e=String(t),A=et(e);if(A&&!isNaN(A.getTime()))return y(A)}catch(t){}return""}return""},[n]),C=y(s),[x,F]=e(C),[Q,U]=e(!1),[E,N]=e(!1),S=r(t=>{var e,A,r,i,s,a;const o={};let l=!0;const c=n.name||"",u=(null===(e=n.basic)||void 0===e?void 0:e.dateTimeMode)||("datetime-picker"===c?"datetime":"date"),h=t?String(t).trim():"";if((null===(A=null==n?void 0:n.validation)||void 0===A?void 0:A.required)&&(!h||""===h))return o.required=!0,l=!1,{isValid:l,errors:o};if(h&&""!==h)if("time"===u){if(!/^([0-1][0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?$/.test(h))return o.invalidDate=!0,l=!1,{isValid:l,errors:o}}else if("datetime"===u){const t=et(h);if(!t||isNaN(t.getTime()))return o.invalidDate=!0,l=!1,{isValid:l,errors:o};if(null===(r=null==n?void 0:n.validation)||void 0===r?void 0:r.minDate){const e=et(n.validation.minDate);e&&t<e&&(o.minDate=!0,o.minDateMessage=`Date and time must be on or after ${e.toLocaleDateString()}`,l=!1)}if(null===(i=null==n?void 0:n.validation)||void 0===i?void 0:i.maxDate){const e=et(n.validation.maxDate);e&&t>e&&(o.maxDate=!0,o.maxDateMessage=`Date and time must be on or before ${e.toLocaleDateString()}`,l=!1)}}else{const t=et(h);if(!t||isNaN(t.getTime()))return o.invalidDate=!0,l=!1,{isValid:l,errors:o};if(null===(s=null==n?void 0:n.validation)||void 0===s?void 0:s.minDate){const e=et(n.validation.minDate);e&&t<e&&(o.minDate=!0,o.minDateMessage=`Date must be on or after ${e.toLocaleDateString()}`,l=!1)}if(null===(a=null==n?void 0:n.validation)||void 0===a?void 0:a.maxDate){const e=et(n.validation.maxDate);e&&t>e&&(o.maxDate=!0,o.maxDateMessage=`Date must be on or before ${e.toLocaleDateString()}`,l=!1)}}return{isValid:l,errors:o}},[n]),L=r(e=>{if(F(e),h){const A=S(e),r={id:t,value:e,isValid:A.isValid,errors:A.errors};h(r)}},[t,h,S]);A(()=>{Q&&(l[t]=!0)},[Q,t,l]),A(()=>{const t=y(s);t===x||E||F(t)},[s,x,E,y]),A(()=>{c&&U(!0)},[c]);const I=o||a||(null===(m=null==n?void 0:n.validation)||void 0===m?void 0:m.readonly),_=n.name||"",O=(null===(v=n.basic)||void 0===v?void 0:v.dateTimeMode)||("datetime-picker"===_?"datetime":"date"),k=(()=>{switch(O){case"time":return"time";case"datetime":return"datetime-local";default:return"date"}})();return X.jsxs("div",{className:`form-group ${(()=>{var t;return"left"===(null===(t=null==n?void 0:n.styles)||void 0===t?void 0:t.labelAlignment)?"label-left":"label-top"})()}`,children:[!g&&n.basic.label&&X.jsxs("label",{htmlFor:t,className:"form-label",children:[n.basic.label,n.validation.required&&X.jsx("span",{className:"required-indicator",children:"*"})]}),X.jsxs("div",{className:"input-wrapper",children:[X.jsx("input",{type:k,id:t,value:x,onChange:t=>{const e=t.target.value;L(e)},onFocus:()=>{N(!0),f&&f()},onBlur:()=>{if(N(!1),U(!0),h){const e=S(x),A={id:t,value:x,isValid:e.isValid,errors:e.errors};h(A)}d&&d()},disabled:I,readOnly:a||(null===(w=null==n?void 0:n.validation)||void 0===w?void 0:w.readonly),min:null===(B=null==n?void 0:n.validation)||void 0===B?void 0:B.minDate,max:null===(b=null==n?void 0:n.validation)||void 0===b?void 0:b.maxDate,className:`form-date ${!S(x).isValid&&Q?"is-invalid":""} ${p}`.trim()}),X.jsx(Z,{validationErrors:i,fieldId:t,touchedFields:l,formSubmitted:c,properties:n,localValidation:S(x),isTouched:Q,mode:u})]})]})},ht=({id:t,properties:i,validationErrors:s={},formValue:a="",readonly:o=!1,disabled:l=!1,touchedFields:c={},formSubmitted:u=!1,mode:h="preview",onValueChange:d,onBlur:f,onFocus:p,className:g="",hideLabel:m=!1})=>{var v;const w=n(null),[B,b]=e(!1),[y,C]=e(!1),[x,F]=e(a),[Q,U]=e(!1),E=r(t=>{var e;const A={};let r=!0;return!(null===(e=null==i?void 0:i.validation)||void 0===e?void 0:e.required)||t&&""!==t.trim()||(A.required=!0,r=!1),{isValid:r,errors:A}},[i]),N=r(e=>{if(F(e),d){const A=E(e),r={id:t,value:e,isValid:A.isValid,errors:A.errors};d(r)}},[t,d,E]),S=r(()=>{const t=document.documentElement.classList.contains("dark")||"dark"===document.documentElement.getAttribute("data-theme");let e=getComputedStyle(document.documentElement).getPropertyValue("--df-color-fb-input-bg").trim();e||(e=t?"#2c2e34":"#ffffff");return{strokeColor:t?"#ffffff":"#000000",backgroundColor:e}},[]),L=r(e=>{if(!e)return;const A=w.current;if(!A)return;const r=A.getContext("2d");if(!r)return;const n=new Image;n.onload=()=>{r.clearRect(0,0,A.width,A.height);const t=S();r.fillStyle=t.backgroundColor,r.fillRect(0,0,A.width,A.height);const e=A.width/A.height,i=n.width/n.height;let s=A.width,a=A.height,o=0,l=0;i>e?(a=A.width/i,l=(A.height-a)/2):(s=A.height*i,o=(A.width-s)/2),r.drawImage(n,o,l,s,a)},n.onerror=A=>{console.error("DfFormSignature: error loading image",{id:t,error:A,dataURL:e.substring(0,50)+"..."})},n.src=e},[S,t]),I=r(()=>{const t=w.current;if(!t)return;const e=t.getContext("2d");if(!e)return;const A=t.getBoundingClientRect();t.width=A.width,t.height=A.height,t.style.width=A.width+"px",t.style.height=A.height+"px";const r=S();e.strokeStyle=r.strokeColor,e.lineWidth=2,e.lineCap="round",e.lineJoin="round",x?L(x):(e.fillStyle=r.backgroundColor,e.fillRect(0,0,t.width,t.height))},[x,S,L]),_=r(()=>{setTimeout(()=>{I()},100)},[I]);A(()=>{const t=()=>{_()},e=new MutationObserver(t=>{t.forEach(t=>{if("attributes"===t.type&&"class"===t.attributeName){const e=t.target;e.classList.contains("form-canvas-container")&&(e.classList.contains("mobile-view")||e.classList.contains("tablet-view")||e.classList.contains("desktop-view"))&&_()}})});return e.observe(document.body,{attributes:!0,attributeFilter:["class"],subtree:!0}),window.addEventListener("resize",t),()=>{e.disconnect(),window.removeEventListener("resize",t)}},[_]);const O=r(t=>{const e=w.current;if(!e)return{x:0,y:0};const A=e.getBoundingClientRect(),r=e.width/A.width,n=e.height/A.height,i=t.type.includes("mouse")?t.clientX:t.touches[0].clientX,s=t.type.includes("mouse")?t.clientY:t.touches[0].clientY;return{x:(i-A.left)*r,y:(s-A.top)*n}},[]),k=t=>{var e;if(o||l||(null===(e=null==i?void 0:i.validation)||void 0===e?void 0:e.readonly))return;if(t.target.closest(".clear-signature-btn"))return;t.preventDefault(),t.stopPropagation(),b(!0),C(!0);const A=w.current;if(!A)return;const r=A.getContext("2d");if(!r)return;const{x:n,y:s}=O(t),a=S();r.strokeStyle=a.strokeColor,r.lineWidth=2,r.lineCap="round",r.lineJoin="round",r.beginPath(),r.moveTo(n,s)},T=t=>{if(!B)return;t.preventDefault(),t.stopPropagation();const e=w.current;if(!e)return;const A=e.getContext("2d");if(!A)return;const{x:r,y:n}=O(t);A.lineTo(r,n),A.stroke()},j=()=>{if(!B)return;b(!1),U(!0);const t=w.current;if(t){(t=>{const e=t.getContext("2d");if(!e)return!1;const A=e.getImageData(0,0,t.width,t.height).data;for(let t=0;t<A.length;t+=4){const e=A[t],r=A[t+1],n=A[t+2];if(A[t+3]>0&&(e<255||r<255||n<255))return!0}})(t);const e=t.toDataURL("image/png");F(e),N(e),setTimeout(()=>{U(!1)},100)}else U(!1)},H=r(()=>{const t=w.current;if(!t)return;const e=t.getContext("2d");if(!e)return;const A=S();if(e.strokeStyle=A.strokeColor,x){const r=x,n=t.getBoundingClientRect();e.fillStyle=A.backgroundColor,e.fillRect(0,0,n.width,n.height),r&&L(r)}else{const r=t.getBoundingClientRect();e.fillStyle=A.backgroundColor,e.fillRect(0,0,r.width,r.height)}},[S,x,L]);A(()=>{const t=new MutationObserver(t=>{t.forEach(t=>{"attributes"!==t.type||"class"!==t.attributeName&&"data-theme"!==t.attributeName||H()})});return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-theme"]}),()=>{t.disconnect()}},[H]);A(()=>{y&&(c[t]=!0)},[y,t,c]),A(()=>{if(!(a===x||B||Q||""!==x&&""===a)){if(a===x)return;F(a),a&&L(a)}},[a,x,B,Q]),A(()=>{u&&C(!0)},[u]),A(()=>{if("test"!==h){F("");const t=w.current;if(t){const e=t.getContext("2d");if(e){const A=t.getBoundingClientRect();t.width=A.width,t.height=A.height;const r=S();e.fillStyle=r.backgroundColor,e.fillRect(0,0,A.width,A.height)}}}},[h]),A(()=>{I()},[h]);const P=l||o||(null===(v=null==i?void 0:i.validation)||void 0===v?void 0:v.readonly);return X.jsxs("div",{className:`form-group ${(()=>{var t;return"left"===(null===(t=null==i?void 0:i.styles)||void 0===t?void 0:t.labelAlignment)?"label-left":"label-top"})()}`,children:[!m&&i.basic.label&&X.jsxs("label",{htmlFor:t,className:"form-label",children:[i.basic.label,i.validation.required&&X.jsx("span",{className:"required-indicator",children:"*"})]}),X.jsxs("div",{className:"input-wrapper",children:[X.jsxs("div",{className:"signature-container",style:{position:"relative",width:"100%",maxWidth:"100%",overflow:"hidden"},children:[X.jsx("canvas",{ref:w,id:t,className:`form-signature ${!E(x).isValid&&y?"is-invalid":""} ${g}`.trim(),onMouseDown:k,onMouseMove:T,onMouseUp:j,onMouseLeave:j,onTouchStart:k,onTouchMove:T,onTouchEnd:j,onFocus:()=>{p&&p()},onBlur:()=>{f&&f()},style:{width:"100%",height:"150px",border:"2px solid var(--df-color-primary-border)",borderRadius:"6px",cursor:P?"not-allowed":"crosshair",backgroundColor:"var(--df-color-fb-input-bg)",touchAction:"none",userSelect:"none"}}),!P&&X.jsx("button",{type:"button",onClick:t=>(t=>{null==t||t.preventDefault(),null==t||t.stopPropagation();const e=w.current;if(!e)return;const A=e.getBoundingClientRect();e.width=A.width,e.height=A.height;const r=e.getContext("2d");if(!r)return;const n=S();r.fillStyle=n.backgroundColor,r.fillRect(0,0,A.width,A.height),r.strokeStyle=n.strokeColor,r.lineWidth=2,r.lineCap="round",r.lineJoin="round",F(""),N("")})(t),className:"clear-signature-btn",style:{position:"absolute",bottom:"8px",right:"8px",padding:"4px 8px",backgroundColor:"var(--df-color-error-primary)",color:"white",border:"none",borderRadius:"4px",cursor:"pointer",fontSize:"0.75rem",fontWeight:"500",zIndex:10,transition:"all 0.2s ease",minWidth:"60px",minHeight:"28px"},onMouseEnter:t=>{t.currentTarget.style.backgroundColor="var(--df-color-error-dark, #dc2626)",t.currentTarget.style.transform="scale(1.05)"},onMouseLeave:t=>{t.currentTarget.style.backgroundColor="var(--df-color-error-primary)",t.currentTarget.style.transform="scale(1)"},children:"Clear"})]}),X.jsx(Z,{validationErrors:s,fieldId:t,touchedFields:c,formSubmitted:u,properties:i,localValidation:E(x),isTouched:y,mode:h})]})]})},dt=({id:t,properties:i,validationErrors:s={},formValue:a=null,readonly:o=!1,disabled:l=!1,touchedFields:c={},formSubmitted:u=!1,mode:h="test",onValueChange:d,onBlur:f,onFocus:p,className:g="",hideLabel:m=!1})=>{var v,w,B,b,y,C,x,F;const[Q,U]=e([]),[E,N]=e(!1),[S,L]=e(!1),I=n(null),_=r(e=>{if(!e)return[];const A=Array.isArray(e)?e:Array.from(e),r=[];return A.forEach((e,A)=>{if(e&&"object"==typeof e&&!(e instanceof File)&&!(e instanceof Blob)){const n=e;if(n.data||n.url||n.name&&n.type){const e=n.name||n.fileName||`file-${A}`,i=n.size||n.fileSize||0,s=n.type||n.fileType||n.mimeType||"";let a;if(n.url)a=n.url;else if(n.data){const t=n.data;if("string"==typeof t)if(t.startsWith("data:"))a=t;else{const e=t.replace(/\s/g,"");if(/^[A-Za-z0-9+/=]+$/.test(e)&&e.length>10){let t=s;t||(t=e.startsWith("/9j/")||e.startsWith("iVBORw0KGgoAAAANSUhEUgAA")?"image/jpeg":e.startsWith("iVBORw0KGgo")?"image/png":e.startsWith("R0lGOD")?"image/gif":e.startsWith("UklGR")?"image/webp":"image/png"),a=`data:${t};base64,${e}`}else a=t}}const o=new File([],e,{type:s});return void r.push({file:o,id:`${t}-file-${A}`,size:i,type:s,name:e,preview:a})}}let n,i,s=0,a="",o="";if(e instanceof File||e instanceof Blob){const t=e;if(s=t.size||0,a=t.type||"",o=t.name||`file-${A}`,i=t,a.startsWith("image/"))try{n=URL.createObjectURL(t)}catch(t){console.error("Error creating object URL:",t),n=void 0}}else if("string"==typeof e){const t=e,r=t.replace(/\s/g,""),s=r.length>50&&/^[A-Za-z0-9+/=]+$/.test(r)&&!t.startsWith("http")&&!t.startsWith("https")&&!t.startsWith("data:")&&!t.startsWith("blob:")&&!t.startsWith("/");let l=t;if(s){let t="image/png";r.startsWith("/9j/")||r.startsWith("iVBORw0KGgoAAAANSUhEUgAA")?t="image/jpeg":r.startsWith("iVBORw0KGgo")?t="image/png":r.startsWith("R0lGOD")?t="image/gif":r.startsWith("UklGR")&&(t="image/webp"),l=`data:${t};base64,${r}`}let c="";if(l.startsWith("data:")){const t=l.match(/filename=([^;]+)/i);if(t)c=decodeURIComponent(t[1]);else{const t=l.match(/data:([^;]+)/);if(t){const e=t[1];c=`file-${A+1}.${e.includes("image")?e.includes("jpeg")?"jpg":"png":e.includes("pdf")?"pdf":e.includes("word")?"doc":e.includes("excel")?"xls":"file"}`}else c=`file-${A+1}`}}else if(l.startsWith("http://")||l.startsWith("https://")||l.startsWith("blob:"))try{const e=new URL(t),r=e.pathname.split("/").pop()||"";if(r&&r.includes("."))c=decodeURIComponent(r);else{const t=e.searchParams.get("filename")||e.searchParams.get("name");c=t?decodeURIComponent(t):`file-${A+1}`}}catch(e){const r=t.lastIndexOf("/"),n=r>=0?t.substring(r+1):t,i=n.indexOf("?"),s=i>=0?n.substring(0,i):n;c=s&&s.includes(".")?decodeURIComponent(s):`file-${A+1}`}else c=`file-${A+1}`;if(o=c||`file-${A+1}`,l.startsWith("data:")){const t=l.indexOf(";");a=t>5?l.substring(5,t):"application/octet-stream"}else{const t=l.match(/\.(jpg|jpeg|png|gif|webp|svg|pdf|doc|docx|xls|xlsx|zip|rar)$/i)||o.match(/\.(jpg|jpeg|png|gif|webp|svg|pdf|doc|docx|xls|xlsx|zip|rar)$/i);if(t){a={jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",pdf:"application/pdf",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",xls:"application/vnd.ms-excel",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",zip:"application/zip",rar:"application/x-rar-compressed"}[t[1].toLowerCase()]||"application/octet-stream"}else a=s?"image/png":"application/octet-stream"}(l.startsWith("data:image")||l.startsWith("http://")||l.startsWith("https://")||l.startsWith("blob:"))&&(n=l),i=new File([],o,{type:a})}else{if(!e||"object"!=typeof e)return;{const t=e;if(o=t.name||t.fileName||`file-${A}`,s=t.size||t.fileSize||0,a=t.type||t.fileType||t.mimeType||"",t.url||t.path)n=t.url||t.path;else if(a.startsWith("image/")&&t.data){const e=t.data;if("string"==typeof e)if(e.startsWith("data:"))n=e;else{const t=e.replace(/\s/g,"");n=/^[A-Za-z0-9+/=]+$/.test(t)&&t.length>50?`data:${a};base64,${t}`:e}else n=void 0}i=new File([],o,{type:a})}}r.push({file:i,id:`${t}-file-${A}`,size:s,type:a,name:o,preview:n})}),r},[t]),O=r(()=>({isValid:!0,errors:{}}),[]),k=r(e=>{var A;if(o||l)return;const r=_(e),n=Q.length>0?[...Q,...r]:r,s=(null===(A=null==i?void 0:i.validation)||void 0===A?void 0:A.maxFiles)||1/0,a=n.slice(0,s);if(U(a),L(!0),d){const e=O(),A={id:t,value:a.map(t=>t.file),isValid:e.isValid,errors:e.errors};d(A)}},[Q,i,o,l,d,O,_,t]),T=t=>{if(0===t)return"0 Bytes";const e=Math.floor(Math.log(t)/Math.log(1024));return parseFloat((t/Math.pow(1024,e)).toFixed(2))+" "+["Bytes","KB","MB","GB"][e]},j=t=>t.startsWith("image/")?"🖼️":t.startsWith("video/")?"🎥":t.startsWith("audio/")?"🎵":t.includes("pdf")?"📄":t.includes("word")||t.includes("document")?"📝":t.includes("excel")||t.includes("spreadsheet")?"📊":t.includes("zip")||t.includes("rar")?"📦":"📁";A(()=>{S&&(c[t]=!0)},[S,t,c]),A(()=>{("edit"===h||"test"===h)&&L(!1)},[h]),A(()=>{const t=_(a);null!=a&&(Array.isArray(a)&&a.length>0||"string"==typeof a&&""!==String(a).trim()||"object"==typeof a&&!Array.isArray(a)&&Object.keys(a).length>0)||0===Q.length&&null!=a?U(t):(null==a||Array.isArray(a)&&0===a.length)&&Q.length>0&&U([])},[a,_,Q.length]),A(()=>{u&&L(!0)},[u]),A(()=>()=>{Q.forEach(t=>{if(t.preview&&t.preview.startsWith("blob:"))try{URL.revokeObjectURL(t.preview)}catch(t){console.error("Error revoking object URL:",t)}})},[Q]);const H=()=>{var t;return"left"===(null===(t=null==i?void 0:i.styles)||void 0===t?void 0:t.labelAlignment)?"label-left":"label-top"},P=l||o||(null===(v=null==i?void 0:i.validation)||void 0===v?void 0:v.readonly),D=(null===(w=null==i?void 0:i.validation)||void 0===w?void 0:w.multiple)||!1,M=(null===(B=null==i?void 0:i.validation)||void 0===B?void 0:B.accept)||"*/*",R=(null===(b=null==i?void 0:i.validation)||void 0===b?void 0:b.maxFiles)||1/0,K=Q.length<R&&(D||R>1),V="edit"===h,z="preview"===h||"test"===h,G=Q.filter(t=>t.type.startsWith("image/")),q=Q.filter(t=>!t.type.startsWith("image/")),W=G.length>0;return z&&W?X.jsxs("div",{className:`form-group ${H()}`,children:[!m&&X.jsxs("label",{htmlFor:t,className:"form-label",children:[(null===(y=i.basic)||void 0===y?void 0:y.label)||"Attachments",(null===(C=i.validation)||void 0===C?void 0:C.required)&&X.jsx("span",{className:"required-indicator",children:"*"})]}),X.jsxs("div",{className:"file-upload-wrapper",children:[X.jsxs("div",{className:"file-image-display",children:[G.map(t=>X.jsxs("div",{className:"file-image-container",children:[t.preview&&X.jsx("img",{src:t.preview,alt:t.name,className:"file-image-preview"}),X.jsxs("div",{className:"file-image-info",children:[X.jsx("div",{className:"file-name",title:t.name,children:t.name}),X.jsx("div",{className:"file-size",children:T(t.size)})]})]},t.id)),q.length>0&&X.jsxs("div",{className:"file-other-files",children:[X.jsx("div",{className:"file-other-files-label",children:"Other Files:"}),q.map(t=>X.jsxs("div",{className:"file-item-minimal",children:[X.jsx("div",{className:"file-icon",children:j(t.type)}),X.jsxs("div",{className:"file-info",children:[X.jsx("div",{className:"file-name",title:t.name,children:t.name}),X.jsx("div",{className:"file-size",children:T(t.size)})]})]},t.id))]})]}),X.jsx(Z,{validationErrors:s,fieldId:t,touchedFields:c,formSubmitted:u,properties:i,localValidation:O(),isTouched:S,mode:h})]})]}):X.jsxs("div",{className:`form-group ${H()}`,children:[!m&&X.jsxs("label",{htmlFor:t,className:"form-label",children:[(null===(x=i.basic)||void 0===x?void 0:x.label)||"Attachments",(null===(F=i.validation)||void 0===F?void 0:F.required)&&X.jsx("span",{className:"required-indicator",children:"*"})]}),X.jsxs("div",{className:"file-upload-wrapper",children:[X.jsxs("div",{className:`file-upload-area ${E?"drag-over":""} ${o?"readonly":""} ${l?"disabled":""} ${g}`.trim(),onDragOver:t=>{t.preventDefault(),o||l||N(!0)},onDragLeave:t=>{t.preventDefault(),N(!1)},onDrop:t=>{if(t.preventDefault(),N(!1),o||l)return;const e=t.dataTransfer.files;e.length>0&&k(e)},onClick:t=>{var e;const A=t.target,r=null!==A.closest(".file-item"),n=null!==A.closest(".file-remove");!V||P||0!==Q.length||r||n||null===(e=I.current)||void 0===e||e.click()},onFocus:()=>{p&&p()},onBlur:()=>{if(L(!0),"test"===h&&d){const e=O(),A={id:t,value:Q.map(t=>t.file),isValid:e.isValid,errors:e.errors};d(A)}f&&f()},tabIndex:P?-1:0,children:[X.jsx("input",{ref:I,type:"file",id:t,multiple:D,accept:M,onChange:t=>{const e=t.target.files;e&&e.length>0&&(k(e),t.target.value="")},disabled:P,style:{display:"none"}}),0===Q.length?X.jsxs("div",{className:"upload-placeholder",onClick:t=>{var e;t.stopPropagation(),V&&!P&&(null===(e=I.current)||void 0===e||e.click())},children:[X.jsx("div",{className:"upload-icon",children:"📁"}),X.jsx("div",{className:"upload-text",children:i.basic.placeholder&&X.jsx("p",{className:"upload-hint",children:i.basic.placeholder})})]}):X.jsx("div",{className:"file-list",children:Q.map(e=>X.jsxs("div",{className:"file-item",children:[X.jsx("div",{className:"file-preview",children:e.preview?X.jsx("img",{src:e.preview,alt:e.name,className:"file-image"}):X.jsx("div",{className:"file-icon",children:j(e.type)})}),X.jsxs("div",{className:"file-info",children:[X.jsx("div",{className:"file-name",title:e.name,children:e.name}),X.jsx("div",{className:"file-size",children:T(e.size)})]}),V&&!P&&X.jsx("button",{type:"button",className:"file-remove",onClick:A=>{A.stopPropagation(),(e=>{if(o||l)return;const A=Q.filter(t=>t.id!==e);if(U(A),L(!0),d){const e=O(),r={id:t,value:A.map(t=>t.file),isValid:e.isValid,errors:e.errors};d(r)}})(e.id)},"aria-label":`Remove ${e.name}`,children:"✕"})]},e.id))})]}),Q.length>0&&K&&!P&&V&&X.jsxs("button",{type:"button",className:"file-add-more",onClick:t=>{t.stopPropagation(),!P&&I.current&&V&&(I.current.value="",I.current.click())},"aria-label":"Add more files",children:[X.jsx("svg",{className:"file-add-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:X.jsx("path",{d:"M12 5v14M5 12h14"})}),X.jsx("span",{className:"file-add-text",children:"Add More Files"})]}),X.jsx(Z,{validationErrors:s,fieldId:t,touchedFields:c,formSubmitted:u,properties:i,localValidation:O(),isTouched:S,mode:h})]})]})},ft=({id:t,properties:i,validationErrors:s={},formValue:o=null,readonly:l=!1,disabled:c=!1,touchedFields:u={},formSubmitted:h=!1,mode:g="test",onValueChange:m,onBlur:v,onFocus:w,className:B="",hideLabel:b=!1})=>{var y,C,x,F;const[Q,U]=e(o),[E,N]=e(!1),[S,L]=e(""),[I,_]=e(!1),[O,k]=e(!1),[T,j]=e({lat:40.7128,lng:-74.006}),[H,P]=e(null),[D,M]=e(10),[R,K]=e(""),[V,z]=e(!1),G=n(null),[q,W]=e(!1),[Y,J]=e(null),[$,At]=e(!1);A(()=>{if(o&&o.latitude&&o.longitude){40.7128===o.latitude&&-74.006===o.longitude||(U(o),P({lat:o.latitude,lng:o.longitude,isCurrentLocation:!1}),j({lat:o.latitude,lng:o.longitude}))}else null==o&&(U(null),P(null))},[o]),A(()=>{O&&40.7128===T.lat&&T.lng},[O,T]),A(()=>{(l||c)&&(O&&k(!1),R&&K(""),q&&(W(!1),J(null)))},[l,c]);const rt=r((t,e)=>tt(void 0,void 0,void 0,function*(){At(!0);try{const A=yield fetch(`https://nominatim.openstreetmap.org/reverse?format=json&lat=${t}&lon=${e}&addressdetails=1&zoom=18`),r=yield A.json();if(r&&r.address){const t=r.address;return{placeName:r.display_name||"",city:t.city||t.town||t.village||t.municipality||"",country:t.country||""}}}catch(t){console.error("Reverse geocoding failed:",t)}finally{At(!1)}return{placeName:"",city:"",country:""}}),[]),nt=r((e,A,r)=>tt(void 0,void 0,void 0,function*(){const n=yield rt(e,A),i=Object.assign({latitude:e,longitude:A,timestamp:Date.now(),placeName:n.placeName,city:n.city,country:n.country,address:n.placeName},r);if(U(i),P({lat:e,lng:A,isCurrentLocation:!1}),_(!0),m){m({id:t,value:i,isValid:!0,errors:{}})}}),[rt,t,m]),it=r(()=>tt(void 0,void 0,void 0,function*(){var t,e,A,r,n,s,a,o,u,h,d,f,p,g,m;if(l||c)return;N(!0),L("");if(void 0!==window.Capacitor)try{const{Geolocation:l}=window.Capacitor.Plugins;if(l)try{if("granted"!==(yield l.requestPermissions()).location)return N(!1),void L("Location permission is required. Please enable location access in your device settings.");const a=yield l.getCurrentPosition({enableHighAccuracy:null===(e=null===(t=i.validation)||void 0===t?void 0:t.enableHighAccuracy)||void 0===e||e,timeout:null!==(r=null===(A=i.validation)||void 0===A?void 0:A.timeout)&&void 0!==r?r:1e4,maximumAge:null!==(s=null===(n=i.validation)||void 0===n?void 0:n.maximumAge)&&void 0!==s?s:3e5}),o=a.coords.latitude,c=a.coords.longitude;return P({lat:o,lng:c,isCurrentLocation:!0}),j({lat:o,lng:c}),_(!0),yield nt(o,c,{accuracy:a.coords.accuracy,timestamp:Date.now()}),N(!1),void L("")}catch(t){return N(!1),void((null===(a=t.message)||void 0===a?void 0:a.includes("permission"))||(null===(o=t.message)||void 0===o?void 0:o.includes("denied"))?L("Location permission is required. Please enable location access in your device settings."):(null===(u=t.message)||void 0===u?void 0:u.includes("timeout"))?L("Location request timed out. Please try again."):L("Unable to retrieve your location. Please try again."))}}catch(t){console.warn("Capacitor Geolocation not available, falling back to web geolocation")}if(!navigator.geolocation)return N(!1),void L("Geolocation is not supported by this browser.");const v={enableHighAccuracy:null===(d=null===(h=i.validation)||void 0===h?void 0:h.enableHighAccuracy)||void 0===d||d,timeout:null!==(p=null===(f=i.validation)||void 0===f?void 0:f.timeout)&&void 0!==p?p:1e4,maximumAge:null!==(m=null===(g=i.validation)||void 0===g?void 0:g.maximumAge)&&void 0!==m?m:3e5};navigator.geolocation.getCurrentPosition(t=>tt(void 0,void 0,void 0,function*(){const e=t.coords.latitude,A=t.coords.longitude;P({lat:e,lng:A,isCurrentLocation:!0}),j({lat:e,lng:A}),_(!0),yield nt(e,A,{accuracy:t.coords.accuracy,timestamp:t.timestamp}),N(!1),L("")}),t=>{N(!1);let e="Unable to retrieve your location.";switch(t.code){case t.PERMISSION_DENIED:e="Location access denied by user. Please enable location access in your browser/device settings.";break;case t.POSITION_UNAVAILABLE:e="Location information is unavailable.";break;case t.TIMEOUT:e="Location request timed out. Please try again."}L(e)},v)}),[l,c,i,nt]),st=r(()=>{if(!l&&!c&&(U(null),P(null),L(""),_(!0),m)){m({id:t,value:null,isValid:!0,errors:{}})}},[l,c,t,m]),at=r(()=>{l||c||k(!O)},[l,c,O]),ot=r((t,e,A,r,n,i)=>{const s=t-n/2,a=e-i/2,o=156543.03392*Math.cos(A.lat*Math.PI/180)/Math.pow(2,r),l=s*o,c=a*o;return{lat:A.lat+c/111320,lng:A.lng+l/(111320*Math.cos(A.lat*Math.PI/180))}},[]),lt=r(t=>{l||c||!G.current||0===t.button&&(W(!0),J({x:t.clientX,y:t.clientY}),t.preventDefault())},[l,c]),ct=r(t=>{if(!q||!Y||!G.current)return;const e=t.clientX-Y.x,A=t.clientY-Y.y,r=156543.03392*Math.cos(T.lat*Math.PI/180)/Math.pow(2,D),n=-A*r/111320,i=e*r/(111320*Math.cos(T.lat*Math.PI/180));j({lat:T.lat+n,lng:T.lng+i}),J({x:t.clientX,y:t.clientY})},[q,Y,T,D]),ut=r(t=>tt(void 0,void 0,void 0,function*(){if(!G.current)return;if(q&&Y){const e=Math.abs(t.clientX-Y.x),A=Math.abs(t.clientY-Y.y);if(e>5||A>5)return W(!1),void J(null)}if(l||c)return W(!1),void J(null);const e=G.current.getBoundingClientRect(),A=t.clientX-e.left,r=t.clientY-e.top,{lat:n,lng:i}=ot(A,r,T,D,e.width,e.height);yield nt(n,i),W(!1),J(null)}),[l,c,G,T,D,ot,nt,q,Y]),ht=r(e=>tt(void 0,void 0,void 0,function*(){if(e.trim()&&!l&&!c){z(!0),L("");try{const A=yield fetch(`https://nominatim.openstreetmap.org/search?format=json&q=${encodeURIComponent(e)}&limit=5&addressdetails=1`),r=yield A.json();if(r&&r.length>0){const e=r[0],A=parseFloat(e.lat),n=parseFloat(e.lon),i=e.address||{},s={latitude:A,longitude:n,address:e.display_name,placeName:e.display_name,city:i.city||i.town||i.village||i.municipality||"",country:i.country||"",timestamp:Date.now()};if(U(s),P({lat:A,lng:n,isCurrentLocation:!1}),j({lat:A,lng:n}),_(!0),m){m({id:t,value:s,isValid:!0,errors:{}})}}else L("No locations found for your search.")}catch(t){L("Failed to search for location. Please try again.")}finally{z(!1)}}}),[l,c,t,m]),dt=()=>{w&&w()},ft=()=>{_(!0),v&&v()},pt=c||l||(null===(y=null==i?void 0:i.validation)||void 0===y?void 0:y.readonly),gt=(null===(C=null==i?void 0:i.basic)||void 0===C?void 0:C.label)||"Location",mt=(null===(x=null==i?void 0:i.basic)||void 0===x?void 0:x.description)||"";return X.jsxs("div",{className:`form-group ${b?"no-label":""} ${B}`,children:[!b&&X.jsxs("label",{htmlFor:t,className:"form-label",children:[gt,(null===(F=null==i?void 0:i.validation)||void 0===F?void 0:F.required)&&X.jsx("span",{className:"required-indicator",children:"*"})]}),mt&&X.jsx("div",{className:"form-group-description",children:mt}),X.jsxs("div",{className:"location-wrapper",children:[!(l&&Q)&&X.jsxs("div",{className:"location-controls",children:[X.jsx("button",{type:"button",className:"location-btn "+(E?"loading":""),onClick:it,disabled:pt||E,onFocus:dt,onBlur:ft,tabIndex:pt?-1:0,children:E?X.jsxs(X.Fragment,{children:[X.jsx(d,{size:16,className:"loading-spinner"}),"Getting Location..."]}):X.jsxs(X.Fragment,{children:[X.jsx(f,{size:16}),"Get Current Location"]})}),X.jsxs("button",{type:"button",className:"location-btn secondary",onClick:at,disabled:pt,onFocus:dt,onBlur:ft,tabIndex:pt?-1:0,children:[X.jsx(p,{size:16}),O?"Hide Map":"Choose on Map"]})]}),Q&&X.jsxs("div",{className:"location-display",children:[!l&&X.jsx("button",{type:"button",className:"location-clear-btn",onClick:st,disabled:pt,title:"Clear location",children:X.jsx(a,{size:16})}),Q.placeName&&X.jsxs("div",{className:"location-place-name",children:[X.jsx("strong",{children:"Place:"})," ",Q.placeName]}),(Q.city||Q.country)&&X.jsxs("div",{className:"location-address",children:[X.jsx("strong",{children:"Address:"})," ",[Q.city,Q.country].filter(Boolean).join(", ")]}),X.jsxs("div",{className:"location-coordinates",children:[X.jsx("strong",{children:"Coordinates:"})," ",(wt=Q.latitude,Bt=Q.longitude,void 0===wt||void 0===Bt||isNaN(wt)||isNaN(Bt)?"":`${Number(wt).toFixed(6)}, ${Number(Bt).toFixed(6)}`)]}),Q.accuracy&&X.jsxs("div",{className:"location-accuracy",children:[X.jsx("strong",{children:"Accuracy:"})," ",(vt=Q.accuracy,vt?`±${Math.round(vt)}m`:"")]}),Q.timestamp&&X.jsxs("div",{className:"location-timestamp",children:[X.jsx("strong",{children:"Captured:"})," ",(et(Q.timestamp)||new Date).toLocaleString()]})]}),O&&!l&&X.jsxs("div",{className:"location-map-container",children:[X.jsxs("div",{className:"location-map-header",children:[X.jsx("h4",{children:"Select Location on Map"}),X.jsx("p",{children:"Search for a place or click on the map to select a location"})]}),X.jsx("div",{className:"location-search",children:X.jsx("form",{onSubmit:t=>{t.preventDefault(),R.trim()&&ht(R)},className:"search-form",children:X.jsxs("div",{className:"search-input-group",children:[X.jsx("input",{type:"text",value:R,onChange:t=>{K(t.target.value)},placeholder:"Search for a place (e.g., New York, Paris, Tokyo)",className:"search-input",disabled:pt||V}),X.jsx("button",{type:"submit",className:"search-btn",disabled:pt||V||!R.trim(),children:V?X.jsx(d,{size:16,className:"loading-spinner"}):"Search"})]})})}),X.jsxs("div",{ref:G,className:"location-map "+(q?"dragging":""),onMouseDown:lt,onMouseMove:ct,onMouseUp:ut,onMouseLeave:()=>{W(!1),J(null)},style:{position:"relative",height:"400px",border:"2px solid var(--df-color-fb-border)",borderRadius:"8px",overflow:"hidden",cursor:q?"grabbing":"grab",background:`url(https://tile.openstreetmap.org/${D}/${Math.floor((T.lng+180)/360*Math.pow(2,D))}/${Math.floor((1-Math.log(Math.tan(T.lat*Math.PI/180)+1/Math.cos(T.lat*Math.PI/180))/Math.PI)/2*Math.pow(2,D))}.png) center/cover no-repeat`,userSelect:"none"},children:[H&&X.jsx("div",{className:"map-marker "+(H.isCurrentLocation?"current-location":"selected-location"),style:{position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -100%)",zIndex:10},children:X.jsx(p,{size:24})}),X.jsx("div",{className:"map-center-indicator",style:{position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)",width:"4px",height:"4px",backgroundColor:"var(--df-color-primary)",borderRadius:"50%",zIndex:5}}),X.jsxs("div",{className:"map-controls",children:[X.jsx("button",{type:"button",className:"map-zoom-btn",onClick:()=>M(t=>Math.min(18,t+1)),disabled:D>=18,children:"+"}),X.jsx("button",{type:"button",className:"map-zoom-btn",onClick:()=>M(t=>Math.max(1,t-1)),disabled:D<=1,children:"−"})]})]}),X.jsxs("div",{className:"location-map-instructions",children:[X.jsx("p",{children:X.jsx("strong",{children:"Instructions:"})}),X.jsxs("ul",{children:[X.jsx("li",{children:"Search for a place using the search box above"}),X.jsx("li",{children:"Click anywhere on the map to select a location"}),X.jsx("li",{children:"Drag the map to pan around"}),X.jsx("li",{children:"Use the zoom buttons (+/−) to zoom in/out"}),X.jsx("li",{children:'Use "Get Current Location" to automatically detect your position'})]})]}),$&&X.jsxs("div",{className:"location-loading",children:[X.jsx(d,{size:16,className:"loading-spinner"}),X.jsx("span",{children:"Loading address details..."})]})]}),S&&X.jsx("div",{className:"location-error",children:S})]}),X.jsx(Z,{validationErrors:s,fieldId:t,touchedFields:u,formSubmitted:h,properties:i,localValidation:{isValid:!0,errors:{}},isTouched:I,mode:g})]});var vt,wt,Bt},pt=({id:t,properties:e,className:A="",hideLabel:r=!1})=>{var n,i,s;const a=null!==(s=null!==(i=null===(n=e.styles)||void 0===n?void 0:n.level)&&void 0!==i?i:e.basic.level)&&void 0!==s?s:1,o=e.basic.label,l=()=>{var t;return`form-heading ${`h${a}`} ${(null===(t=null==e?void 0:e.styles)||void 0===t?void 0:t.textAlign)?`text-${e.styles.textAlign}`:""} ${A}`.trim()},c=()=>{var t,A;const r={};return(null===(t=null==e?void 0:e.styles)||void 0===t?void 0:t.fontSize)&&(r.fontSize=e.styles.fontSize),(null===(A=null==e?void 0:e.styles)||void 0===A?void 0:A.color)&&(r.color=e.styles.color),r};return r?null:(()=>{const e={id:t,className:l(),style:c()};switch(a){case 1:default:return X.jsx("h1",Object.assign({},e,{children:o}));case 2:return X.jsx("h2",Object.assign({},e,{children:o}));case 3:return X.jsx("h3",Object.assign({},e,{children:o}));case 4:return X.jsx("h4",Object.assign({},e,{children:o}));case 5:return X.jsx("h5",Object.assign({},e,{children:o}));case 6:return X.jsx("h6",Object.assign({},e,{children:o}))}})()},gt=({id:t,properties:i,mode:s="preview",formValue:a,onValueChange:o,className:l="",hideLabel:c=!1})=>{var u,h,d;const[f,p]=e(""),[b,y]=e((null===(u=i.validation)||void 0===u?void 0:u.listStyle)||"numbers"),[C,x]=e("#000000"),F=n(null),Q=n(null),U=n(!1),E="edit"===s,N=n({instructions:[],listStyle:"numbers",formValue:void 0}),S=n(s);A(()=>{var t,e,A,r,n;let o=[],l="numbers";if(null!=a&&("object"==typeof a&&a.instructions?(Array.isArray(a.instructions)?o=a.instructions:"string"==typeof a.instructions&&(o=[a.instructions]),a.listStyle&&(l=a.listStyle)):Array.isArray(a)?o=a:"string"==typeof a&&(o=[a])),0===o.length&&(null===(t=i.basic)||void 0===t?void 0:t.value)){const t=i.basic.value;t&&"object"==typeof t&&!Array.isArray(t)&&t.instructions?(Array.isArray(t.instructions)?o=t.instructions:"string"==typeof t.instructions&&(o=[t.instructions]),t.listStyle&&"string"==typeof t.listStyle&&(l=t.listStyle)):Array.isArray(t)?o=t:"string"==typeof t&&(o=[t])}0===o.length&&(null===(e=i.basic)||void 0===e?void 0:e.instructions)&&(Array.isArray(i.basic.instructions)?o=i.basic.instructions:"string"==typeof i.basic.instructions&&(o=[i.basic.instructions])),l&&"numbers"!==l||(l=(null===(A=i.validation)||void 0===A?void 0:A.listStyle)||(null===(n=null===(r=i.basic)||void 0===r?void 0:r.value)||void 0===n?void 0:n.listStyle)||"numbers");const c=JSON.stringify(o)!==JSON.stringify(N.current.instructions)||l!==N.current.listStyle,u=s!==S.current,h=JSON.stringify(a)!==JSON.stringify(N.current.formValue),d=!N.current.formValue||Array.isArray(N.current.formValue)&&0===N.current.formValue.length||"string"==typeof N.current.formValue&&""===N.current.formValue.trim(),f=null!=a&&(Array.isArray(a)&&a.length>0||"string"==typeof a&&""!==a.trim()||"object"==typeof a&&Object.keys(a).length>0);if(c||u||h||d&&f){const t=t=>"string"!=typeof t?t:t.replace(/\\u([0-9a-fA-F]{4})/g,(t,e)=>String.fromCharCode(parseInt(e,16))),e=o.map(e=>"string"==typeof e?t(e):e),A=e.some(t=>"string"==typeof t&&/<[^>]+>/.test(t));let r="";if(e.length>0)if(A)r=e.join("");else{const t="numbers"===l?"ol":"bullets"===l?"ul":"div",A=e.filter(t=>t&&"string"==typeof t).map(t=>`<li>${t.replace(/\n/g,"<br>")}</li>`).join("");r="div"===t?e.filter(t=>t&&"string"==typeof t).map(t=>`<div>${t.replace(/\n/g,"<br>")}</div>`).join(""):`<${t}>${A}</${t}>`}y(l),p(r),E&&F.current&&(u||c&&F.current.innerHTML.trim()!==r.trim())&&(F.current.innerHTML=r),N.current={instructions:o,listStyle:l,formValue:a},S.current=s}},[a,null===(h=i.basic)||void 0===h?void 0:h.instructions,null===(d=i.validation)||void 0===d?void 0:d.listStyle,s,E]),A(()=>{if(E&&F.current){const t=F.current.innerHTML.trim();f.trim()===t||U.current||(F.current.innerHTML=f)}if(U.current){const t=setTimeout(()=>{U.current=!1},200);return()=>clearTimeout(t)}},[f,E]);const L=r(()=>{if(!F.current)return;U.current=!0;const e=F.current.innerHTML.trim();if(o){o({id:t,value:{instructions:e?[e]:[],listStyle:b},isValid:!0,errors:{}})}e!==f&&p(e)},[t,b,o,f]),I=r(()=>{if(!F.current)return;const e=F.current.innerHTML.trim();if(o){o({id:t,value:{instructions:e?[e]:[],listStyle:b},isValid:!0,errors:{}})}p(e),U.current=!1},[t,b,o]),_=r((t,e)=>{var A;document.execCommand(t,!1,e),null===(A=F.current)||void 0===A||A.focus(),L()},[L]),O=r(()=>{_("bold")},[_]),k=r(()=>{_("italic")},[_]),T=r(t=>{const e=t.target.value;x(e),_("foreColor",e)},[_]),j=r(e=>{if(y(e),!F.current)return;const A=window.getSelection(),r=A&&A.rangeCount>0?A.getRangeAt(0):null;let n=F.current.innerHTML;if("numbers"===e){if(n=n.replace(/<ul>/gi,"<ol>").replace(/<\/ul>/gi,"</ol>"),!n.includes("<ol>")&&!n.includes("<ul>")){const t=n.split(/<br\s*\/?>/i).filter(t=>t.trim());t.length>0&&(n="<ol>"+t.map(t=>`<li>${t}</li>`).join("")+"</ol>")}}else if("bullets"===e){if(n=n.replace(/<ol>/gi,"<ul>").replace(/<\/ol>/gi,"</ul>"),!n.includes("<ol>")&&!n.includes("<ul>")){const t=n.split(/<br\s*\/?>/i).filter(t=>t.trim());t.length>0&&(n="<ul>"+t.map(t=>`<li>${t}</li>`).join("")+"</ul>")}}else n=n.replace(/<\/?[ou]l>/gi,"").replace(/<li>/gi,"<div>").replace(/<\/li>/gi,"</div>");if(F.current.innerHTML=n,p(n),r&&A)try{A.removeAllRanges(),A.addRange(r)}catch(t){}if(L(),o){o({id:t,value:{instructions:n?[n]:[],listStyle:e},isValid:!0,errors:{}})}},[t,L,o]),H=r(t=>{var e;const A=null===(e=t.target.files)||void 0===e?void 0:e[0];if(!A||!A.type.startsWith("image/"))return;const r=new FileReader;r.onload=t=>{var e;const A=null===(e=t.target)||void 0===e?void 0:e.result;if(A&&F.current){const t=document.createElement("img");t.src=A,t.style.maxWidth="100%",t.style.height="auto";const e=window.getSelection();if(e&&e.rangeCount>0){const A=e.getRangeAt(0);A.deleteContents(),A.insertNode(t)}else F.current.appendChild(t);L()}},r.readAsDataURL(A),Q.current&&(Q.current.value="")},[L]),P=r(t=>{t.preventDefault();const e=t.clipboardData.getData("text/plain"),A=window.getSelection();if(A&&A.rangeCount>0){const t=A.getRangeAt(0);t.deleteContents();const r=document.createTextNode(e);t.insertNode(r),t.setStartAfter(r),t.collapse(!0),A.removeAllRanges(),A.addRange(t)}L()},[L]),D=r(t=>document.queryCommandState(t),[]);return X.jsxs("div",{className:`form-group instruction-group ${l}`,children:[!c&&X.jsx("label",{htmlFor:t,className:"instruction-label",children:"Instructions"}),E?X.jsxs("div",{className:"instruction-rich-editor",children:[X.jsxs("div",{className:"instruction-toolbar",children:[X.jsxs("div",{className:"toolbar-group",children:[X.jsx("button",{type:"button",className:"toolbar-btn "+(D("bold")?"active":""),onClick:O,title:"Bold","aria-label":"Bold",children:X.jsx(g,{size:16})}),X.jsx("button",{type:"button",className:"toolbar-btn "+(D("italic")?"active":""),onClick:k,title:"Italic","aria-label":"Italic",children:X.jsx(m,{size:16})})]}),X.jsx("div",{className:"toolbar-separator"}),X.jsx("div",{className:"toolbar-group",children:X.jsxs("div",{className:"color-picker-wrapper",children:[X.jsx("input",{type:"color",value:C,onChange:T,className:"color-picker-input",title:"Text Color"}),X.jsx("label",{className:"color-picker-label",title:"Text Color",children:X.jsx("span",{style:{color:C},children:"A"})})]})}),X.jsx("div",{className:"toolbar-separator"}),X.jsxs("div",{className:"toolbar-group",children:[X.jsx("button",{type:"button",className:"toolbar-btn "+("bullets"===b?"active":""),onClick:()=>j("bullets"),title:"Bullet List","aria-label":"Bullet List",children:X.jsx(v,{size:16})}),X.jsx("button",{type:"button",className:"toolbar-btn "+("numbers"===b?"active":""),onClick:()=>j("numbers"),title:"Numbered List","aria-label":"Numbered List",children:X.jsx(w,{size:16})})]}),X.jsx("div",{className:"toolbar-separator"}),X.jsxs("div",{className:"toolbar-group",children:[X.jsx("button",{type:"button",className:"toolbar-btn",onClick:()=>{var t;return null===(t=Q.current)||void 0===t?void 0:t.click()},title:"Insert Image","aria-label":"Insert Image",children:X.jsx(B,{size:16})}),X.jsx("input",{ref:Q,type:"file",accept:"image/*",onChange:H,style:{display:"none"}})]})]}),X.jsx("div",{ref:F,contentEditable:!0,className:"instruction-editor-content",onInput:L,onBlur:I,onPaste:P,"data-placeholder":"Enter instructions (press Enter for a new line)...",suppressContentEditableWarning:!0})]}):X.jsx("div",{className:"instruction-preview-wrapper "+("numbers"===b?"instruction-list-numbers":"bullets"===b?"instruction-list-bullets":""),children:f?X.jsx("div",{className:"instruction-preview-content",dangerouslySetInnerHTML:{__html:f}}):X.jsx("div",{className:"instruction-empty",children:X.jsx("p",{children:"No instructions provided"})})})]})},mt=({attachments:t,onRemove:r})=>{const[n,i]=e(new Map);return A(()=>{if(!t)return void i(t=>(t.forEach(t=>URL.revokeObjectURL(t)),new Map));const e=new Map;return t.forEach((t,A)=>{if(t&&t.type&&"string"==typeof t.type&&t.type.startsWith("image/")){const r=URL.createObjectURL(t);e.set(A,r)}}),i(t=>(t.forEach((t,A)=>{e.has(A)||URL.revokeObjectURL(t)}),e)),()=>{e.forEach(t=>URL.revokeObjectURL(t))}},[t]),t&&0!==t.length?X.jsx("div",{className:"attachment-thumbnails-container",children:t.map((t,e)=>{const A=t&&t.type&&"string"==typeof t.type&&t.type.startsWith("image/"),i=n.get(e);return X.jsx("div",{className:"attachment-thumbnail",children:A&&i?X.jsxs(X.Fragment,{children:[X.jsx("img",{src:i,alt:t?t.name:"Attachment"}),X.jsx("button",{type:"button",className:"thumbnail-remove-btn",onClick:()=>r(e),title:"Remove attachment",children:X.jsx(a,{size:14})})]}):X.jsxs(X.Fragment,{children:[X.jsx("div",{className:"file-icon-placeholder",children:X.jsx(h,{size:20})}),X.jsx("span",{className:"file-name",children:t?t.name:"Unknown File"}),X.jsx("button",{type:"button",className:"thumbnail-remove-btn",onClick:()=>r(e),title:"Remove attachment",children:X.jsx(a,{size:14})})]})},e)})}):null},vt=({component:t,mode:i,formTemplateId:s,formValue:a,formData:o,onNotesChange:l,onAttachmentChange:u,notes:d="",attachments:f=null,onThresholdActionCompletion:p,onThresholdIssueRaised:g,onBasicPropertyActionCompletion:m,workOrderNumber:v,assetNumber:w,isStandalone:B,user:Q,onCreateIssue:U,onUpdateIssue:E})=>{var N;const S=void 0!==a?a:o?o[t.id]:void 0,[L,I]=e(d||""),[_,O]=e(f||null),[k,T]=e(!1),[j,H]=e(!1),[P,D]=e(!1),[M,R]=e(!1),[K,V]=e(null),[z,G]=e(!1),q=n(null),W=n(S),Y=n(!1),J=n(!1);A(()=>{d&&d!==L&&!Y.current&&(I(d),Y.current=!0)},[d,L]),A(()=>{f&&f!==_&&!J.current&&(O(f),J.current=!0)},[f,_]),A(()=>{if(Y.current&&!k&&null!=d){const t="string"==typeof d?d:String(d||"");L&&""!==String(L||"").trim()||!t||""===t.trim()?t&&""!==t.trim()&&t!==L&&I(t):I(t)}},[d,k,L]),A(()=>{J.current&&void 0!==f&&(!_||f&&f.length>0&&f!==_)&&O(f)},[f,_]),A(()=>{const e=["select","radio","checkbox","segment"].includes(t.name||"");if(e){const e=W.current,A=S;let r=!1;if("checkbox"===t.name){const t=Array.isArray(e)?e:e?[e]:[],n=Array.isArray(A)?A:A?[A]:[];r=JSON.stringify(t.sort())!==JSON.stringify(n.sort())}else r=e!==A&&void 0!==e;r&&(D(!1),R(!1),V(null),H(!1),T(!1),G(!1),d&&""!==d.trim()||I(""),f&&0!==f.length||O(null)),W.current=A}e||(W.current=S)},[S,t.name,d,f]);const $=r((t,e)=>{const{operator:A,value:r}=t,n=String(e).toLowerCase(),i=String(r).toLowerCase();switch(A){case"equals":return n===i||String(e)===String(r);case"notEquals":return n!==i&&String(e)!==String(r);case"greaterThan":return Number(e)>Number(r);case"lessThan":return Number(e)<Number(r);case"greaterThanOrEqual":return Number(e)>=Number(r);case"lessThanOrEqual":return Number(e)<=Number(r);default:return!1}},[]),Z=r(()=>{if(!(null!=S&&""!==S&&!(Array.isArray(S)&&0===S.length)))return[];const e=t.condition;if(!e||!e.conditions||0===e.conditions.length)return[];const A=[];if("checkbox"===t.name&&Array.isArray(S))S.forEach(t=>{const r=e.conditions.find(e=>$(e,t));r&&!A.find(t=>t.id===r.id)&&A.push(r)});else{const t=e.conditions.find(t=>$(t,S));t&&A.push(t)}return A},[t,S,$]),tt=r(e=>{const A=e.target.value;I(A),l&&l(A);const r=Z(),n=A.trim().length>0;r.forEach(t=>{!0===t.enableNotes&&p&&p(t.id,"notes",n)});const i=t.condition;!(i&&i.conditions&&i.conditions.length>0)&&m&&m("notes",n)},[l,Z,p,t,m]),et=r(()=>{if(l){const t="string"==typeof L?L:String(L||"");l(t),setTimeout(()=>{T(!1)},0)}else T(!1)},[L,l]),At=r(()=>{et()},[et]),nt=r(t=>{(t.ctrlKey||t.metaKey)&&"Enter"===t.key&&(t.preventDefault(),et())},[et]),it=r(()=>{T(!0)},[]),st=r(()=>{T(!0)},[]),at=r(()=>{var t;null===(t=q.current)||void 0===t||t.click()},[]),ot=r(e=>{const A=e.target.files;if(A&&A.length>0){const e=Array.from(A);O(e),u&&u(e);Z().forEach(t=>{!0===t.enableAttachment&&p&&p(t.id,"attachments",!0)});const r=t.condition;!(r&&r.conditions&&r.conditions.length>0)&&m&&m("attachments",!0)}q.current&&(q.current.value="")},[u,Z,p,t,m]),lt=r(e=>{if(_){const A=_.filter((t,A)=>A!==e);if(0===A.length){O(null),u&&u(null);Z().forEach(t=>{!0===t.enableAttachment&&p&&p(t.id,"attachments",!1)});const e=t.condition;!(e&&e.conditions&&e.conditions.length>0)&&m&&m("attachments",!1)}else O(A),u&&u(A)}},[_,u,Z,p,t,m]),ct=r(()=>{D(!0);Z().forEach(t=>{!0===t.enableSendEmail&&p&&p(t.id,"email",!0)});const e=t.condition;!(e&&e.conditions&&e.conditions.length>0)&&m&&m("email",!0),setTimeout(()=>{D(!1)},3e3)},[Z,p,t,m]),ut=r(()=>{M||H(!0)},[M]),ht=r(()=>{H(!1)},[]),dt=r(e=>{H(!1),R(!0),e&&V(e);const A=t.condition;if(A&&A.conditions&&A.conditions.length>0){Z().forEach(t=>{!0===t.enableRaiseIssue&&g&&g(t.id)})}else m&&m("issue",!0)},[t,m,Z,g]);if("test"!==i)return null;const ft=["select","radio","checkbox","segment"].includes(t.name||""),pt=(null===(N=t.basic)||void 0===N?void 0:N.options)||t.options||[];let gt=!1,vt=!1,wt=!1,Bt=!1,bt=null;const yt=null!=S&&""!==S&&!(Array.isArray(S)&&0===S.length),Ct=t.condition,xt=Ct&&Ct.conditions&&Ct.conditions.length>0;if(xt&&yt)if("checkbox"===t.name&&Array.isArray(S)){const t=S;for(const e of t){const t=Ct.conditions.find(t=>$(t,e));t&&(gt=gt||!0===t.enableNotes,vt=vt||!0===t.enableAttachment,wt=wt||!0===t.enableRaiseIssue,Bt=Bt||!0===t.enableSendEmail)}}else if(ft){const t=Ct.conditions.find(t=>$(t,S));t&&(gt=!0===t.enableNotes,vt=!0===t.enableAttachment,wt=!0===t.enableRaiseIssue,Bt=!0===t.enableSendEmail)}else{const t=Ct.conditions.find(t=>$(t,S));t&&(gt=!0===t.enableNotes,vt=!0===t.enableAttachment,wt=!0===t.enableRaiseIssue,Bt=!0===t.enableSendEmail)}if(!xt){const e=t.basic,A=!0===(null==e?void 0:e.enableNotes),r=!0===(null==e?void 0:e.enableAttachment),n=!0===(null==e?void 0:e.enableRaiseIssue),i=!0===(null==e?void 0:e.enableSendEmail);if(ft)if(yt)if("checkbox"===t.name){(Array.isArray(S)?S:[S]).forEach(t=>{const e=pt.find(e=>!(!e||!e.value)&&(e.value===t||(String(e.value)===String(t)||(e.label===t||String(e.label)===String(t)))));e&&(gt=gt||!0===e.enableNotes,vt=vt||!0===e.enableAttachment,wt=wt||!0===e.enableRaiseIssue,Bt=Bt||!0===e.enableSendEmail,bt||(bt=e))}),gt=gt||A,vt=vt||r,wt=wt||n,Bt=Bt||i}else if(bt=pt.find(t=>!(!t||!t.value)&&(t.value===S||(String(t.value)===String(S)||(t.label===S||String(t.label)===String(S))))),bt){const t=!0===bt.enableNotes,e=!0===bt.enableAttachment,s=!0===bt.enableRaiseIssue,a=!0===bt.enableSendEmail;gt=t||A,vt=e||r,wt=s||n,Bt=a||i}else gt=A,vt=r,wt=n,Bt=i;else gt=A,vt=r,wt=n,Bt=i;else gt=A,vt=r,wt=n,Bt=i}if(!(gt||vt||wt||Bt))return null;const Ft=Z(),Qt=t.condition,Ut=Qt&&Qt.conditions&&Qt.conditions.length>0,Et=!!Ut&&Ft.some(t=>!0===t.enableNotes),Nt=!!Ut&&Ft.some(t=>!0===t.enableAttachment),St=!!Ut&&Ft.some(t=>!0===t.enableSendEmail),Lt=!!Ut&&Ft.some(t=>!0===t.enableRaiseIssue),It=L.trim().length>0,_t=_&&_.length>0,Ot=_?_.length:0;return X.jsxs(X.Fragment,{children:[X.jsxs("div",{className:"component-action-features",children:[X.jsxs("div",{className:"action-icons-toolbar",children:[gt&&X.jsxs("button",{type:"button",className:`action-icon-button ${It?"active":""} ${Et?"mandatory":""}`,onClick:it,title:"Add Notes",children:[X.jsx(c,{size:14,fill:It?"currentColor":"none"}),Et&&X.jsx("span",{className:"mandatory-indicator",children:"*"})]}),vt&&X.jsxs("button",{type:"button",className:`action-icon-button ${_t?"active":""} ${Nt?"mandatory":""}`,onClick:at,title:"Add Attachment",children:[X.jsx(h,{size:14,fill:_t?"currentColor":"none"}),Ot>0&&X.jsx("span",{className:"attachment-count-badge",children:Ot}),Nt&&X.jsx("span",{className:"mandatory-indicator",children:"*"})]}),Bt&&X.jsxs("button",{type:"button",className:`action-icon-button ${P?"active sent":""} ${St?"mandatory":""}`,onClick:ct,disabled:P,title:"Send Email",children:[P?X.jsx(X.Fragment,{children:X.jsx(b,{size:14})}):X.jsx(y,{size:14,fill:P?"currentColor":"none"}),St&&X.jsx("span",{className:"mandatory-indicator",children:"*"})]}),wt&&X.jsxs("button",{type:"button",className:`action-icon-button ${M?"active":""} ${Lt?"mandatory":""}`,onClick:ut,title:"Raise an Issue",children:[X.jsx(C,{size:14,fill:M?"currentColor":"none"}),Lt&&X.jsx("span",{className:"mandatory-indicator",children:"*"})]}),(It&&gt||_t&&vt)&&X.jsx("button",{type:"button",className:"action-icon-button accordion-toggle",onClick:()=>G(!z),title:z?"Collapse":"Expand",children:z?X.jsx(x,{size:14}):X.jsx(F,{size:14})})]}),k&&gt&&X.jsxs("div",{className:"notes-input-overlay",children:[X.jsx("textarea",{className:"action-notes-textarea",value:L,onChange:tt,onBlur:At,onKeyDown:nt,placeholder:"Explain which protocols were not followed (Press Ctrl+Enter to save)",rows:4,autoFocus:!0}),X.jsxs("div",{className:"notes-input-actions",children:[X.jsx("button",{type:"button",className:"notes-save-button",onClick:et,title:"Save notes (Ctrl+Enter)",children:"Save"}),X.jsx("button",{type:"button",className:"notes-cancel-button",onClick:()=>{T(!1)},title:"Cancel",children:"Cancel"})]})]}),z&&X.jsxs("div",{className:"actions-content",children:[!k&&It&&gt&&X.jsx("div",{className:"notes-summary-section",children:X.jsxs("div",{className:"notes-full-text",onClick:st,children:[X.jsx("span",{className:"notes-label",children:"Notes:"})," ",L]})}),_t&&vt&&X.jsx("div",{className:"attachments-section",children:X.jsx(mt,{attachments:_,onRemove:lt})})]}),vt&&X.jsx("input",{ref:q,type:"file",multiple:!0,accept:"image/*,.pdf",onChange:ot,style:{display:"none"}})]}),j&&X.jsx(rt,{isOpen:j,onClose:ht,onSuccess:dt,issue:K,component:(()=>{var e,A;const r=null!=S?Array.isArray(S)?S.join(", "):String(S):(null===(e=t.basic)||void 0===e?void 0:e.value)||"",n=Object.assign(Object.assign({},t),{basic:Object.assign(Object.assign({},t.basic||{}),{value:r})});return bt&&(n.basic.label=`${(null===(A=t.basic)||void 0===A?void 0:A.label)||"Component"} - ${bt.label||bt.value}`,n.basic.value=bt.value||r),n})(),formTemplateId:s||"",notes:L,attachments:_,isStandalone:B,workOrderNumber:v,assetNumber:w,user:Q,onCreateIssue:U,onUpdateIssue:E})]})},wt=({attachments:t})=>t&&0!==t.length?X.jsx("div",{className:"attachment-thumbnails-container",children:t.map((t,e)=>{var A;const r=(null===(A=t.type)||void 0===A?void 0:A.startsWith("image/"))||!1,n=r?(t=>t.data?t.data.startsWith("data:")?t.data:`data:${t.type||"image/png"};base64,${t.data}`:"")(t):"";return X.jsx("div",{className:"attachment-thumbnail",children:r&&n?X.jsx("img",{src:n,alt:t.name||`Attachment ${e+1}`}):X.jsxs("div",{className:"file-icon-placeholder",children:[X.jsx(h,{size:20}),X.jsx("span",{className:"file-name",children:t.name||`File ${e+1}`})]})},e)})}):null,Bt=({component:t})=>{var e,A;const r=(null===(e=t.basic)||void 0===e?void 0:e.notes)||"",n=(null===(A=t.basic)||void 0===A?void 0:A.attachments)||[],i=r&&r.trim().length>0,s=n&&n.length>0;return i||s?X.jsx("div",{className:"component-submission-actions",children:X.jsxs("div",{className:"actions-content",children:[i&&X.jsx("div",{className:"notes-summary-section",children:X.jsxs("div",{className:"notes-full-text",children:[X.jsx("span",{className:"notes-label",children:"Notes:"})," ",r]})}),s&&X.jsx("div",{className:"attachments-section",children:X.jsx(wt,{attachments:n})})]})}):null},bt=({child:t,selectedChild:e,mode:A,onChildSelect:r,onChildDelete:n,renderFormComponent:i,isOverlay:s=!1,isChildrenEditMode:a=!1,formData:o={},formTemplateId:l,onThresholdActionCompletion:c,onThresholdIssueRaised:u,onNotesChange:h,onAttachmentChange:d,workOrderNumber:f,assetNumber:p,user:g,onCreateIssue:m,onUpdateIssue:v})=>{var w,B;const b=o[t.id],y="preview"===A&&((null===(w=t.basic)||void 0===w?void 0:w.notes)&&t.basic.notes.trim().length>0||(null===(B=t.basic)||void 0===B?void 0:B.attachments)&&Array.isArray(t.basic.attachments)&&t.basic.attachments.length>0),{attributes:C,listeners:x,setNodeRef:F,transform:Q,transition:S,isDragging:L,isSorting:I}=j({id:t.id,disabled:s||"edit"!==A}),_={transform:P.Transform.toString(Q),transition:S,zIndex:L?1e3:"auto"};return X.jsxs("div",{ref:F,style:_,className:`form-component section-child ${(null==e?void 0:e.id)===t.id?"selected":""} ${L?"dragging":""} ${I?"sorting":""} ${a?"children-edit-active":""}`,onClick:()=>!L&&r(t),role:"button",tabIndex:0,children:[("edit"===A||a)&&X.jsx("div",Object.assign({className:"child-drag-handle"},x,C,{onClick:t=>t.stopPropagation(),onMouseDown:t=>t.stopPropagation(),children:X.jsx(U,{size:14})})),X.jsxs("div",{className:"form-component-content section-child-content",children:[("edit"===A||a)&&X.jsxs("div",{className:"component-actions child-actions",children:[X.jsx("button",{className:"btn edit-btn",onClick:e=>{e.stopPropagation(),r(t)},onMouseDown:t=>t.stopPropagation(),title:"Edit properties",children:X.jsx(E,{size:12})}),X.jsx("button",{className:"btn delete-btn",onClick:e=>n(t,e),onMouseDown:t=>t.stopPropagation(),title:"Delete component",children:X.jsx(N,{size:12})})]}),X.jsxs("div",{className:"component-preview child-preview",children:[i(t),!["section","table","heading","file","instructions","signature","location","datagrid"].includes(t.name)&&X.jsx(vt,{component:t,mode:"test",formTemplateId:l,formValue:b,formData:o,onThresholdActionCompletion:c,onThresholdIssueRaised:u,onNotesChange:h?e=>h(t.id,e):void 0,onAttachmentChange:d?e=>d(t.id,e):void 0,workOrderNumber:f,assetNumber:p,user:g,onCreateIssue:m,onUpdateIssue:v}),y&&X.jsx(Bt,{component:t})]})]})]})},yt=({id:t,properties:n,mode:i="edit",formData:s={},onValueChange:a,onSelect:o,isSelected:l=!1,className:c="",onSectionSelect:u,onChildSelect:h,onChildDelete:d,selectedChild:f,renderFormComponent:p,formTemplateId:g,onThresholdActionCompletion:m,onThresholdIssueRaised:v,onNotesChange:w,onAttachmentChange:B,workOrderNumber:b,assetNumber:y,user:C,onCreateIssue:x,onUpdateIssue:U})=>{var E,N,S,L,I,_;const[j,H]=e(n.basic.collapsed),[P,D]=e(!1),[M,R]=e(!1),[K,V]=e(n.basic.label),[z,G]=e(n.basic.description),[q,W]=e(n.children||[]),[Y,J]=e(!1);A(()=>{W(n.children||[])},[n.children]),A(()=>{V(n.basic.label),G(n.basic.description)},[n.basic.label,n.basic.description]);const{setNodeRef:$,isOver:Z}=O({id:`section-${t}`,disabled:"edit"!==i}),tt=!("preview"!==i&&"test"!==i||n.children&&n.children.length>0),et=r(e=>{V(e),null==a||a({id:t,value:Object.assign(Object.assign({},n),{basic:Object.assign(Object.assign({},n.basic),{label:e})})})},[t,n,a]),At=r(e=>{G(e),null==a||a({id:t,value:Object.assign(Object.assign({},n),{basic:Object.assign(Object.assign({},n.basic),{description:e})})})},[t,n,a]),rt=r(t=>{null==h||h(t)},[h]),nt=r((t,e)=>{e.stopPropagation();const A=q.filter(e=>e.id!==t.id);W(A),null==d||d(t.id)},[d,q,t]),ct=r(()=>{null==u||u(n),null==o||o()},[u,o,n]),dt=r(t=>{t.stopPropagation(),"edit"===i&&q.length>0&&J(!Y)},[i,q.length,Y]),ft=r(e=>{e.stopPropagation(),H(!j),null==a||a({id:t,value:Object.assign(Object.assign({},n),{basic:Object.assign(Object.assign({},n.basic),{collapsed:!j})})})},[j,t,n,a]),gt=p||r(t=>{var e,A,r;const n=s[t.id]||"defaultValue"in t.basic&&t.basic.defaultValue||"";let o=n;"number-input"===t.name&&"number"==typeof n?o=String(n):"number-input"===t.name&&null==n&&(o="");const l={id:t.id,properties:t,validationErrors:{},formValue:o,touchedFields:{},formSubmitted:!1,mode:i,onValueChange:a,onBlur:()=>{},onFocus:()=>{}};switch(t.name){case"text-input":case"email-input":case"number-input":return X.jsx(it,Object.assign({},l,{properties:t,inputType:"text-input"===t.name?"text":"number-input"===t.name?"number":"email",readonly:!1,disabled:!1}));case"textarea":return X.jsx(st,Object.assign({},l,{properties:t,readonly:!1,disabled:!1}));case"select":const n=Object.assign(Object.assign({},t),{options:(null===(e=t.basic)||void 0===e?void 0:e.options)||[]});return X.jsx(at,Object.assign({},l,{properties:n,disabled:!1}));case"checkbox":const i=Object.assign(Object.assign({},t),{options:(null===(A=t.basic)||void 0===A?void 0:A.options)||[]});return X.jsx(ot,Object.assign({},l,{properties:i,formValue:[],disabled:!1}));case"radio":const s=Object.assign(Object.assign({},t),{options:(null===(r=t.basic)||void 0===r?void 0:r.options)||[]});return X.jsx(lt,Object.assign({},l,{properties:s,readonly:!1,disabled:!1}));case"date":case"date-picker":case"datetime-picker":return X.jsx(ut,Object.assign({},l,{properties:t,readonly:!1,disabled:!1}));case"signature":return X.jsx(ht,Object.assign({},l,{properties:t}));case"heading":return X.jsx(pt,Object.assign({},l,{properties:t}));default:return X.jsx("div",{className:"form-group",children:X.jsxs("div",{className:"form-group-label",children:["Unsupported Component: ",t.name]})})}},[i,a,s]);if(tt)return null;const mt={backgroundColor:(null===(E=n.styles)||void 0===E?void 0:E.backgroundColor)||"var(--df-color-fb-container)",borderColor:(null===(N=n.styles)||void 0===N?void 0:N.borderColor)||"var(--df-color-fb-border)",borderWidth:(null===(S=n.styles)||void 0===S?void 0:S.borderWidth)||"2px",borderRadius:(null===(L=n.styles)||void 0===L?void 0:L.borderRadius)||"8px",padding:(null===(I=n.styles)||void 0===I?void 0:I.padding)||"16px",margin:(null===(_=n.styles)||void 0===_?void 0:_.margin)||"16px 0"};return X.jsxs("div",{ref:$,className:`df-form-section ${l?"selected":""} ${Z?"drag-over":""} ${c}`,style:mt,children:[X.jsxs("div",{className:"section-header "+(Y?"children-edit-mode":""),onClick:ct,onDoubleClick:dt,children:[X.jsx("div",{className:"section-header-content",children:X.jsxs("div",{className:"section-title",children:[X.jsx("span",{className:"section-toggle",title:j?"Expand section":"Collapse section",role:"button",tabIndex:0,onClick:t=>{t.stopPropagation(),ft(t)},onKeyDown:t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),ft(t))},style:{marginRight:"8px",display:"inline-flex",alignItems:"center"},children:j?X.jsx(Q,{size:18}):X.jsx(F,{size:18})}),"edit"===i&&P?X.jsx("input",{type:"text",value:K,onChange:t=>V(t.target.value),onBlur:()=>{D(!1),et(K)},onKeyDown:t=>{"Enter"===t.key&&(D(!1),et(K))},className:"section-title-input",autoFocus:!0}):X.jsx("h3",{className:"section-title-text",onDoubleClick:()=>"edit"===i&&D(!0),style:{display:"inline",margin:0},children:K||"Untitled Section"})]})}),(z||"edit"===i)&&X.jsx("div",{className:"section-description",children:"edit"===i&&M?X.jsx("textarea",{value:z,onChange:t=>G(t.target.value),onBlur:()=>{R(!1),At(z)},onKeyDown:t=>{"Enter"===t.key&&t.ctrlKey&&(R(!1),At(z))},className:"section-description-input",placeholder:"Section description (optional)",autoFocus:!0}):X.jsx("p",{className:"section-description-text",onDoubleClick:()=>"edit"===i&&R(!0),children:z||"Section description"})})]}),!j&&X.jsx("div",{className:`section-content ${Z?"drag-over":""} ${0===q.length?"empty":"has-children"}`,onClick:t=>{t.target===t.currentTarget&&ct()},children:X.jsx(k,{items:q.map(t=>t.id),strategy:T,children:0===q.length?X.jsxs("div",{className:"section-empty-state",onClick:ct,style:{textAlign:"center",color:"#6b7280",fontSize:"14px",padding:"40px 20px",display:"flex",flexDirection:"column",alignItems:"center",gap:"8px",cursor:"pointer",border:"2px dotted #d1d5db",borderRadius:"8px",backgroundColor:"var(--df-color-fb-container)",transition:"all 0.3s ease",margin:"16px 0"},children:[X.jsx("div",{style:{fontWeight:"500",color:Z?"#3b82f6":"#374151"},children:Z?"Drop components here":"Empty Section"}),X.jsx("div",{style:{fontSize:"12px",color:"#9ca3af"},children:"Drag and drop components here to create your section"})]}):q.map(t=>X.jsx(bt,{child:t,selectedChild:f||null,mode:i,onChildSelect:rt,onChildDelete:nt,renderFormComponent:gt,isChildrenEditMode:Y,formData:s,formTemplateId:g,onNotesChange:w,onAttachmentChange:B,onThresholdActionCompletion:m,onThresholdIssueRaised:v,workOrderNumber:b,assetNumber:y,user:C,onCreateIssue:x,onUpdateIssue:U},t.id))})})]})},Ct=({component:t,selectedComponent:e,mode:A,onComponentSelect:r,onComponentDelete:n,onComponentEdit:i,renderFormComponent:s,isOverlay:a=!1,formData:o={},formTemplateId:l,onThresholdActionCompletion:c,onThresholdIssueRaised:u,onNotesChange:h,onAttachmentChange:d,workOrderNumber:f,assetNumber:p,user:g,onCreateIssue:m,onUpdateIssue:v})=>{var w,B;const b=o[t.id],y="preview"===A&&((null===(w=t.basic)||void 0===w?void 0:w.notes)&&t.basic.notes.trim().length>0||(null===(B=t.basic)||void 0===B?void 0:B.attachments)&&Array.isArray(t.basic.attachments)&&t.basic.attachments.length>0),{attributes:C,listeners:x,setNodeRef:F,transform:Q,transition:S,isDragging:L,isSorting:I}=j({id:t.id,disabled:a}),_={transform:P.Transform.toString(Q),transition:S,opacity:L?.3:1,zIndex:L?1e3:"auto"};return X.jsxs("div",{ref:F,style:Object.assign(Object.assign({},_),{border:(null==e?void 0:e.id)===t.id?"2px solid #3b82f6":"1px solid var(--df-color-fb-border)",borderRadius:"8px",backgroundColor:"var(--df-color-fb-container)",padding:"12px",position:"relative",minHeight:"80px",transition:"all 0.2s ease",boxShadow:(null==e?void 0:e.id)===t.id?"0 4px 12px rgba(59, 130, 246, 0.15)":"0 1px 3px rgba(0, 0, 0, 0.1)",cursor:"pointer"}),className:`form-component grid-component ${(null==e?void 0:e.id)===t.id?"selected":""} ${L?"dragging":""} ${I?"sorting":""}`,onClick:()=>!L&&r(t),role:"button",tabIndex:0,children:["edit"===A&&X.jsx("div",Object.assign({className:"component-drag-handle"},x,C,{onClick:t=>t.stopPropagation(),style:{position:"absolute",top:"50%",left:"4px",transform:"translateY(-50%)",padding:"4px",backgroundColor:"#f3f4f6",borderRadius:"4px",cursor:"grab",opacity:1,zIndex:10,display:"flex",alignItems:"center",justifyContent:"center"},children:X.jsx(U,{size:12,color:"var(--df-color-text-light)"})})),X.jsxs("div",{className:"component-content",style:{paddingTop:"edit"===A?"24px":"0",paddingLeft:"edit"===A?"28px":"0",minHeight:"60px"},children:[s(t),!["section","table","heading","file","instructions","signature","location","datagrid"].includes(t.name)&&X.jsx(vt,{component:t,mode:"test",formTemplateId:l,formValue:b,formData:o,onThresholdActionCompletion:c,onThresholdIssueRaised:u,onNotesChange:h?e=>h(t.id,e):void 0,onAttachmentChange:d?e=>d(t.id,e):void 0,workOrderNumber:f,assetNumber:p,user:g,onCreateIssue:m,onUpdateIssue:v}),y&&X.jsx(Bt,{component:t})]}),"edit"===A&&X.jsxs("div",{className:"component-actions",style:{position:"absolute",top:"4px",right:"4px",display:"flex",gap:"4px",opacity:1,zIndex:10},children:[i&&X.jsx("button",{className:"component-edit-btn",onClick:e=>{e.stopPropagation(),i(t)},type:"button",title:"Edit Component",style:{padding:"4px",backgroundColor:"#3b82f6",color:"#ffffff",border:"none",borderRadius:"4px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s ease"},onMouseEnter:t=>{t.currentTarget.style.backgroundColor="#2563eb"},onMouseLeave:t=>{t.currentTarget.style.backgroundColor="#3b82f6"},children:X.jsx(E,{size:12})}),X.jsx("button",{className:"component-delete-btn",onClick:e=>{e.stopPropagation(),n(t,e)},type:"button",title:"Delete Component",style:{padding:"4px",backgroundColor:"#ef4444",color:"#ffffff",border:"none",borderRadius:"4px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s ease"},onMouseEnter:t=>{t.currentTarget.style.backgroundColor="#dc2626"},onMouseLeave:t=>{t.currentTarget.style.backgroundColor="#ef4444"},children:X.jsx(N,{size:12})})]})]})},xt=({gridComponents:t,mode:e,onComponentSelect:A,onComponentDelete:r,onComponentEdit:n,onComponentUpdate:i,selectedComponent:s,renderFormComponent:a,gridId:o,formData:l={},formTemplateId:c,onThresholdActionCompletion:u,onThresholdIssueRaised:h,onNotesChange:d,onAttachmentChange:f,workOrderNumber:p,assetNumber:g,user:m,onCreateIssue:v,onUpdateIssue:w})=>{const{setNodeRef:B,isOver:b}=O({id:`grid-drop-zone-${o}`,disabled:"edit"!==e});return X.jsx("div",{ref:B,className:"grid-drop-zone",style:{border:b?"2px dashed #3b82f6":"2px dashed #d1d5db",borderRadius:"8px",padding:"16px",backgroundColor:b?"var(--df-color-primary-light)":"var(--df-color-fb-container)",minHeight:"120px",transition:"all 0.2s ease",position:"relative"},children:t.length>0?X.jsxs(X.Fragment,{children:[X.jsx(k,{items:t.map(t=>t.id),strategy:H,children:X.jsx("div",{style:{display:"flex",flexDirection:"row",flexWrap:"nowrap",gap:"12px",alignItems:"start",marginBottom:t.length>0?"12px":"0",overflowX:"auto",width:"100%"},children:t.map(t=>X.jsx("div",{style:{flex:"1 1 0",minWidth:"200px",maxWidth:"100%"},children:X.jsx(Ct,{component:t,selectedComponent:s,mode:e,onComponentSelect:A,onComponentDelete:r,onComponentEdit:n,onComponentUpdate:i,renderFormComponent:a,formData:l,formTemplateId:c,onThresholdActionCompletion:u,onThresholdIssueRaised:h,onNotesChange:d,onAttachmentChange:f,workOrderNumber:p,assetNumber:g,user:m,onCreateIssue:v,onUpdateIssue:w})},t.id))})}),X.jsx("div",{style:{border:b?"2px dashed #3b82f6":"1px dashed var(--df-color-fb-border)",borderRadius:"6px",padding:"12px",backgroundColor:b?"var(--df-color-primary-light)":"var(--df-color-fb-container)",textAlign:"center",color:"var(--df-color-text-light)",fontSize:"12px",transition:"all 0.2s ease",minHeight:"40px",display:"flex",alignItems:"center",justifyContent:"center"},children:b?X.jsx("span",{style:{color:"#3b82f6",fontWeight:"500"},children:"Drop component here to add to grid"}):X.jsx("span",{children:"+ Drop more components here"})})]}):X.jsxs("div",{style:{textAlign:"center",color:"var(--df-color-text-light)",fontSize:"14px",padding:"40px 20px",display:"flex",flexDirection:"column",alignItems:"center",gap:"8px",backgroundColor:"var(--df-color-fb-container)",border:"1px dashed var(--df-color-fb-border)",borderRadius:"8px"},children:[X.jsx("div",{style:{fontWeight:"500",color:b?"var(--df-color-primary)":"var(--df-color-text-dark)"},children:b?"Drop components here":"Empty DataGrid"}),X.jsx("div",{style:{fontSize:"12px",color:"#9ca3af"},children:"Drag and drop components here to create your grid"})]})})},Ft=({templateComponents:t,dataEntries:e,renderFormComponent:A,renderComponent:r,mode:n="preview",allowAddRemoveEntries:i=!0,addAnotherText:s="Add Another",removeText:a="Remove",maxEntries:o=10,minEntries:l=1,displayAsGrid:c=!0,onAddEntry:u,onRemoveEntry:h,formData:d={},formTemplateId:f,onThresholdActionCompletion:p,onThresholdIssueRaised:g,onNotesChange:m,onAttachmentChange:v,datagridId:w="",workOrderNumber:B,assetNumber:b,user:y,onCreateIssue:C,onUpdateIssue:x})=>0===t.length?X.jsxs("div",{style:{textAlign:"center",padding:"40px",color:"var(--df-color-text-light)",border:"1px dashed #d1d5db",borderRadius:"8px",backgroundColor:"var(--df-color-fb-container)"},children:["No components defined. Add components to see the ",c?"table":"list"," view."]}):c?X.jsxs("div",{className:"datagrid-table-view",style:{border:"1px solid var(--df-color-fb-border)",borderRadius:"8px",overflow:"hidden",backgroundColor:"var(--df-color-fb-container)",maxWidth:"100%"},children:[X.jsx("div",{style:{position:"absolute",top:"8px",right:"8px",zIndex:10,fontSize:"12px",color:"var(--df-color-text-light)",backgroundColor:"var(--df-color-fb-container)",padding:"4px 8px",borderRadius:"4px",border:"1px solid var(--df-color-fb-border)",opacity:t.length>4?1:0,transition:"opacity 0.2s ease"},children:"← Scroll →"}),X.jsxs("div",{className:"table-scroll-container",style:{overflowX:"auto",overflowY:"hidden",maxWidth:"100%",scrollbarWidth:"thin",scrollbarColor:"var(--df-color-fb-border) var(--df-color-fb-icon-bg)",position:"relative"},children:[X.jsx("div",{className:"table-headers",style:{display:"grid",gridTemplateColumns:`repeat(${t.length}, minmax(150px, 1fr))`,backgroundColor:"var(--df-color-fb-container)",borderBottom:"2px solid var(--df-color-fb-border)",minWidth:150*t.length+"px"},children:t.map((e,A)=>{var r;return X.jsx("div",{style:{padding:"12px 16px",fontWeight:"600",color:"var(--df-color-text-dark)",borderRight:A<t.length-1?"1px solid var(--df-color-fb-border)":"none",fontSize:"14px",minWidth:"150px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:(null===(r=e.basic)||void 0===r?void 0:r.label)||`Column ${A+1}`},`header-${e.id}`)})}),e.length>0?e.map((s,o)=>X.jsxs("div",{className:"table-row",style:{display:"grid",gridTemplateColumns:`repeat(${t.length}, minmax(150px, 1fr))`,borderBottom:o<e.length-1?"1px solid var(--df-color-fb-border)":"none",backgroundColor:o%2==0?"var(--df-color-fb-container)":"var(--df-color-fb-bg)",position:"relative",minWidth:150*t.length+"px",isolation:"isolate"},children:[t.map((e,i)=>{var a,l,c,u,h,F,Q;let U=null===(a=s.components)||void 0===a?void 0:a[i];const E=`${e.id||`component-${i}`}-entry-${w}-${o}-${i}`;return U=U?U.id!==E?Object.assign(Object.assign({},U),{id:E,basic:Object.assign(Object.assign({},U.basic),{showLabel:!1})}):Object.assign(Object.assign({},U),{id:U.id,basic:Object.assign(Object.assign({},U.basic),{showLabel:!1})}):Object.assign(Object.assign({},e),{id:E,basic:Object.assign(Object.assign({},e.basic),{showLabel:!1,defaultValue:void 0,value:void 0})}),X.jsxs("div",{style:{padding:"12px 16px",borderRight:i<t.length-1?"1px solid var(--df-color-fb-border)":"none",minHeight:"60px",minWidth:"150px",display:"flex",flexDirection:"column",alignItems:"flex-start",justifyContent:"center",overflow:"visible",position:"relative",zIndex:1},children:[X.jsx("div",{style:{width:"100%",minWidth:"120px",overflow:"hidden",position:"relative",zIndex:1},children:r?r(U,!0):A(U,!0)}),!["section","table","heading","file","instructions","signature","location","datagrid"].includes(U.name)&&X.jsxs("div",{style:{marginTop:"8px",width:"100%"},children:[X.jsx(vt,{component:U,mode:"test",formTemplateId:f,formValue:d[U.id],formData:d,onThresholdActionCompletion:p,onThresholdIssueRaised:g,onNotesChange:m?t=>m(U.id,t):void 0,onAttachmentChange:v?t=>v(U.id,t):void 0,notes:(null===(l=U.basic)||void 0===l?void 0:l.notes)||(null===(c=d[U.id])||void 0===c?void 0:c.notes),attachments:(null===(u=U.basic)||void 0===u?void 0:u.attachments)||(null===(h=d[U.id])||void 0===h?void 0:h.attachments),workOrderNumber:B,assetNumber:b,user:y,onCreateIssue:C,onUpdateIssue:x}),"preview"===n&&((null===(F=U.basic)||void 0===F?void 0:F.notes)||(null===(Q=U.basic)||void 0===Q?void 0:Q.attachments))&&X.jsx(Bt,{component:U})]})]},`${s.id}-${i}`)}),i&&e.length>l&&X.jsx("button",{type:"button",onClick:t=>{if(t.preventDefault(),t.stopPropagation(),!(e.length<=l)&&h)try{h(o)}catch(t){console.error("Error removing entry:",t)}},disabled:e.length<=l,style:{position:"absolute",top:"8px",right:"8px",padding:"4px 8px",backgroundColor:e.length<=l?"#f3f4f6":"#ef4444",color:e.length<=l?"#9ca3af":"#ffffff",border:"none",borderRadius:"4px",fontSize:"12px",fontWeight:"500",cursor:e.length<=l?"not-allowed":"pointer",display:"flex",alignItems:"center",gap:"4px",zIndex:1e3,minWidth:"24px",height:"24px",justifyContent:"center",transition:"all 0.2s ease",pointerEvents:"auto"},title:a,onMouseEnter:t=>{e.length>l&&(t.currentTarget.style.backgroundColor="#dc2626")},onMouseLeave:t=>{e.length>l&&(t.currentTarget.style.backgroundColor="#ef4444")},children:X.jsx("span",{style:{fontSize:"14px"},children:"×"})})]},s.id)):X.jsxs("div",{style:{padding:"40px",textAlign:"center",color:"var(--df-color-text-light)",backgroundColor:"var(--df-color-fb-container)",borderTop:"1px solid var(--df-color-fb-border)"},children:["No data entries. ",i?'Click "Add Another" to add entries.':"Use the properties panel to add entries."]})]}),i&&X.jsx("div",{style:{padding:"16px",backgroundColor:"var(--df-color-fb-bg)",borderTop:"1px solid var(--df-color-fb-border)",display:"flex",justifyContent:"center",position:"sticky",bottom:0,zIndex:5},children:X.jsxs("button",{type:"button",onClick:t=>{if(t.preventDefault(),t.stopPropagation(),!(e.length>=o)&&u)try{u()}catch(t){console.error("Error adding entry:",t)}},disabled:e.length>=o,style:{padding:"8px 16px",backgroundColor:e.length>=o?"#f3f4f6":"#10b981",color:e.length>=o?"#9ca3af":"#ffffff",border:"none",borderRadius:"6px",fontSize:"14px",fontWeight:"500",cursor:e.length>=o?"not-allowed":"pointer",display:"flex",alignItems:"center",gap:"6px",transition:"all 0.2s ease",pointerEvents:"auto",zIndex:1e3},onMouseEnter:t=>{e.length<o&&(t.currentTarget.style.backgroundColor="#059669")},onMouseLeave:t=>{e.length<o&&(t.currentTarget.style.backgroundColor="#10b981")},children:[X.jsx("span",{style:{fontSize:"16px"},children:"+"}),s]})})]}):X.jsxs("div",{className:"datagrid-list-view",style:{display:"flex",flexDirection:"column",gap:"12px",backgroundColor:"var(--df-color-fb-container)"},children:[e.length>0?e.map((s,o)=>X.jsxs("div",{className:"list-entry",style:{border:"1px solid var(--df-color-fb-border)",borderRadius:"8px",padding:"16px",backgroundColor:"var(--df-color-fb-container)",position:"relative",transition:"all 0.2s ease"},children:[X.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",paddingBottom:"8px",borderBottom:"1px solid var(--df-color-fb-border)"},children:[X.jsxs("span",{style:{fontWeight:"600",color:"var(--df-color-text-dark)",fontSize:"14px"},children:["Entry #",o+1]}),i&&e.length>1&&X.jsx("button",{type:"button",onClick:t=>{if(t.preventDefault(),t.stopPropagation(),!(e.length<=l)&&h)try{h(o)}catch(t){console.error("Error removing entry:",t)}},disabled:e.length<=l,style:{padding:"4px 8px",backgroundColor:e.length<=l?"#f3f4f6":"#ef4444",color:e.length<=l?"#9ca3af":"#ffffff",border:"none",borderRadius:"4px",fontSize:"12px",fontWeight:"500",cursor:e.length<=l?"not-allowed":"pointer",display:"flex",alignItems:"center",gap:"4px",minWidth:"24px",height:"24px",justifyContent:"center",transition:"all 0.2s ease",pointerEvents:"auto",zIndex:1e3},title:a,onMouseEnter:t=>{e.length>l&&(t.currentTarget.style.backgroundColor="#dc2626")},onMouseLeave:t=>{e.length>l&&(t.currentTarget.style.backgroundColor="#ef4444")},children:X.jsx("span",{style:{fontSize:"14px"},children:"×"})})]}),X.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:"16px"},children:t.map((t,e)=>{var i,a,l;let c=null===(i=s.components)||void 0===i?void 0:i[e];const u=`${t.id||`component-${e}`}-entry-${w}-${o}-${e}`;return c||(c=null===(a=s.components)||void 0===a?void 0:a.find(e=>{var A,r;return e.name===t.name&&(null===(A=e.basic)||void 0===A?void 0:A.label)===(null===(r=t.basic)||void 0===r?void 0:r.label)})),c=c?c.id!==u?Object.assign(Object.assign({},c),{id:u,basic:Object.assign(Object.assign({},c.basic),{showLabel:!1})}):Object.assign(Object.assign({},c),{id:c.id,basic:Object.assign(Object.assign({},c.basic),{showLabel:!1})}):Object.assign(Object.assign({},t),{id:u,basic:Object.assign(Object.assign({},t.basic),{showLabel:!1,defaultValue:void 0,value:void 0})}),X.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[X.jsx("label",{style:{fontSize:"12px",fontWeight:"500",color:"var(--df-color-text-light)",textTransform:"uppercase",letterSpacing:"0.05em"},children:(null===(l=t.basic)||void 0===l?void 0:l.label)||`Field ${e+1}`}),X.jsxs("div",{style:{minHeight:"40px",display:"flex",alignItems:"center",flexDirection:"column",width:"100%"},children:[r?r(c):A(c),!["section","table","heading","file","instructions","signature","location","datagrid"].includes(c.name)&&X.jsx(vt,{component:c,mode:"test",formTemplateId:f,formValue:d[c.id],onThresholdActionCompletion:p,onThresholdIssueRaised:g,onNotesChange:m?t=>m(c.id,t):void 0,onAttachmentChange:v?t=>v(c.id,t):void 0}),"preview"===n&&(()=>{var t,e;return(null===(t=c.basic)||void 0===t?void 0:t.notes)&&c.basic.notes.trim().length>0||(null===(e=c.basic)||void 0===e?void 0:e.attachments)&&Array.isArray(c.basic.attachments)&&c.basic.attachments.length>0?X.jsx(Bt,{component:c}):null})()]})]},`${s.id}-${e}`)})})]},s.id)):X.jsxs("div",{style:{padding:"40px",textAlign:"center",color:"var(--df-color-text-light)",backgroundColor:"var(--df-color-fb-container)",border:"1px dashed #d1d5db",borderRadius:"8px"},children:["No data entries. ",i?'Click "Add Another" to add entries.':"Use the properties panel to add entries."]}),"test"===n&&i&&X.jsx("div",{style:{padding:"16px",backgroundColor:"#f8f9fa",border:"1px solid var(--df-color-fb-border)",borderRadius:"8px",display:"flex",justifyContent:"center"},children:X.jsxs("button",{type:"button",onClick:t=>{if(t.preventDefault(),t.stopPropagation(),!(e.length>=o)&&u)try{u()}catch(t){console.error("Error adding entry:",t)}},disabled:e.length>=o,style:{padding:"8px 16px",backgroundColor:e.length>=o?"#f3f4f6":"#10b981",color:e.length>=o?"#9ca3af":"#ffffff",border:"none",borderRadius:"6px",fontSize:"14px",fontWeight:"500",cursor:e.length>=o?"not-allowed":"pointer",display:"flex",alignItems:"center",gap:"8px",transition:"all 0.2s ease",pointerEvents:"auto",zIndex:1e3},onMouseEnter:t=>{e.length<o&&(t.currentTarget.style.backgroundColor="#059669")},onMouseLeave:t=>{e.length<o&&(t.currentTarget.style.backgroundColor="#10b981")},children:[X.jsx("span",{children:"+"}),s]})})]}),Qt=({id:t,properties:i,mode:s="edit",formData:a={},validationErrors:o={},touchedFields:l={},formSubmitted:c=!1,onValueChange:u,onSelect:h,isSelected:d=!1,className:f="",onDataGridSelect:p,onComponentSelect:g,onComponentDelete:m,onComponentEdit:v,onComponentUpdate:w,selectedComponent:B,renderFormComponent:b,onEntryAdd:y,onEntryRemove:C,formTemplateId:x,onThresholdActionCompletion:U,onThresholdIssueRaised:E,onNotesChange:N,onAttachmentChange:L,workOrderNumber:I,assetNumber:_,onCreateIssue:O,onUpdateIssue:k})=>{var T,j,H,P,D,M,R,K,V,z,G,q;const[W,Y]=e(!1),J=n(!1);let $=i.templateComponents||[];const Z=i.entries||[];0===$.length&&Z.length>0&&Z[0].components&&($=Z[0].components.map(t=>{var e;return Object.assign(Object.assign({},t),{id:(null===(e=t.id)||void 0===e?void 0:e.replace(/-entry-\d+$/,""))||t.id,basic:Object.assign(Object.assign({},t.basic),{showLabel:!0})})})),A(()=>{if("edit"===s&&!i.templateComponents&&u&&J.current){const e=Object.assign(Object.assign({},i),{templateComponents:[]});JSON.stringify(e)!==JSON.stringify(i)&&u({id:t,value:e})}J.current=!0},[i.templateComponents,t,u,i,s]),A(()=>{if($.length>0){if("test"===s&&0===Z.length&&J.current){const e={id:`entry-${t}-0`,index:0,components:$.map((e,A)=>{const r=e.id||`component-${A}`;return Object.assign(Object.assign({},e),{id:`${r}-entry-${t}-0-${A}`,basic:Object.assign(Object.assign({},e.basic),{showLabel:!1,defaultValue:void 0,value:void 0})})}),styles:{}};if(u){const A=Object.assign(Object.assign({},i),{entries:[e]});JSON.stringify(A)!==JSON.stringify(i)&&u({id:t,value:A})}return}if("edit"!==s||!J.current)return;const e=Z.some(t=>{var e;return null===(e=t.components)||void 0===e?void 0:e.some((e,A)=>{var r;const n=`${null===(r=$[A])||void 0===r?void 0:r.id}-entry-${t.index}-${A}`;return e.id!==n})});if(e&&u){const e=Z.map(t=>{var e;return Object.assign(Object.assign({},t),{components:(null===(e=t.components)||void 0===e?void 0:e.map((e,A)=>{var r;return Object.assign(Object.assign({},e),{id:`${null===(r=$[A])||void 0===r?void 0:r.id}-entry-${t.index}-${A}`})}))||[]})}),A=Object.assign(Object.assign({},i),{entries:e});return void(JSON.stringify(A)!==JSON.stringify(i)&&u({id:t,value:A}))}if(0===Z.length&&"edit"===s){const e={id:`entry-${t}-0`,index:0,components:$.map((e,A)=>{const r=e.id||`component-${A}`;return Object.assign(Object.assign({},e),{id:`${r}-entry-${t}-0-${A}`,basic:Object.assign(Object.assign({},e.basic),{showLabel:!1,defaultValue:void 0,value:void 0})})}),styles:{}};if(u){const A=Object.assign(Object.assign({},i),{entries:[e]});JSON.stringify(A)!==JSON.stringify(i)&&u({id:t,value:A})}}else if(Z.length>0){const e=Z.some(t=>$.some((e,A)=>{var r,n,i,s,a,o,l,c,u,h,d;const f=null===(r=t.components)||void 0===r?void 0:r[A];if(!f)return!0;const p=`${e.id}-entry-${t.index}-${A}`,g=f.id===p,m=JSON.stringify(null===(n=f.basic)||void 0===n?void 0:n.options)!==JSON.stringify(null===(i=e.basic)||void 0===i?void 0:i.options)||(null===(s=f.basic)||void 0===s?void 0:s.placeholder)!==(null===(a=e.basic)||void 0===a?void 0:a.placeholder)||(null===(o=f.basic)||void 0===o?void 0:o.defaultValue)!==(null===(l=e.basic)||void 0===l?void 0:l.defaultValue)||(null===(c=f.basic)||void 0===c?void 0:c.label)!==(null===(u=e.basic)||void 0===u?void 0:u.label)||(null===(h=f.validation)||void 0===h?void 0:h.required)!==(null===(d=e.validation)||void 0===d?void 0:d.required);return!g||m}));if(e&&u){const e=Z.map(e=>{const A=$.map((A,r)=>{var n,i;let s=null===(n=e.components)||void 0===n?void 0:n[r];s||(s=null===(i=e.components)||void 0===i?void 0:i.find(t=>{var e,r;return t.name===A.name&&(null===(e=t.basic)||void 0===e?void 0:e.label)===(null===(r=A.basic)||void 0===r?void 0:r.label)}));const a=`${A.id||`component-${r}`}-entry-${t}-${e.index}-${r}`;if(s){return Object.assign(Object.assign({},A),{id:a,basic:Object.assign(Object.assign({},A.basic),{showLabel:!1,defaultValue:void 0,value:void 0})})}return Object.assign(Object.assign({},A),{id:a,basic:Object.assign(Object.assign({},A.basic),{showLabel:!1,defaultValue:void 0,value:void 0})})});return Object.assign(Object.assign({},e),{components:A})}),A=Object.assign(Object.assign({},i),{entries:e});JSON.stringify(A)!==JSON.stringify(i)&&u({id:t,value:A})}}}},[$,Z,t,u,i,s,i.templateComponents]);const tt=r(t=>{t.stopPropagation(),null==h||h(),null==p||p(i)},[h,p,i]),et=r((e,A)=>{A.stopPropagation(),m&&m(e,A);const r=$.filter(t=>t.id!==e.id),n=Z.map(t=>{var A;return Object.assign(Object.assign({},t),{components:(null===(A=t.components)||void 0===A?void 0:A.filter(t=>{var A,r;return!(t.name===e.name&&(null===(A=t.basic)||void 0===A?void 0:A.label)===(null===(r=e.basic)||void 0===r?void 0:r.label))}))||[]})});u&&u({id:t,value:Object.assign(Object.assign({},i),{templateComponents:r,entries:n})})},[m,i,u,t,$,Z]),At=r((e,A)=>{w&&w(e,A);const r=$.map(t=>t.id===e?Object.assign(Object.assign({},t),A):t);u&&u({id:t,value:Object.assign(Object.assign({},i),{templateComponents:r})})},[w,i,u,t,$]),rt=r(t=>{"test"===s&&u&&u({id:t.id,value:t.value})},[u]),nt=r(()=>{const e=i.entries||[],A=e.length,r={id:`entry-${t}-${A}`,index:A,components:$.map((e,r)=>{const n=`${e.id||`component-${r}`}-entry-${t}-${A}-${r}`;return Object.assign(Object.assign({},e),{id:n,basic:Object.assign(Object.assign({},e.basic),{showLabel:!1,defaultValue:void 0,value:void 0})})}),styles:{}},n=[...e,r];u&&u({id:t,value:Object.assign(Object.assign({},i),{entries:n})}),null==y||y()},[i,u,t,y,$]),ct=r(e=>{const A=i.entries.filter((t,A)=>A!==e).map((e,A)=>Object.assign(Object.assign({},e),{index:A,id:`entry-${t}-${A}`}));u&&u({id:t,value:Object.assign(Object.assign({},i),{entries:A})})},[i,u,t,C]),dt=r((t,e=!1)=>{var A,r,n;const i=a[t.id]||"defaultValue"in t.basic&&t.basic.defaultValue||"";let u=i;"number-input"===t.name&&"number"==typeof i?u=String(i):"number-input"===t.name&&null==i&&(u="");const h={id:t.id,properties:t,validationErrors:o||{},formValue:u,touchedFields:l||{},formSubmitted:c||!1,mode:s,hideLabel:e,onValueChange:rt,onBlur:()=>{},onFocus:()=>{}};switch(t.name){case"text-input":case"email-input":case"number-input":return X.jsx(it,Object.assign({},h,{properties:t,inputType:"text-input"===t.name?"text":"number-input"===t.name?"number":"email",readonly:!1,disabled:!1,hideLabel:e}));case"textarea":return X.jsx(st,Object.assign({},h,{properties:t,readonly:!1,disabled:!1,hideLabel:e}));case"select":const i=Object.assign(Object.assign({},t),{options:(null===(A=t.basic)||void 0===A?void 0:A.options)||[]});return X.jsx(at,Object.assign({},h,{properties:i,disabled:!1,hideLabel:e}));case"checkbox":const s=Object.assign(Object.assign({},t),{options:(null===(r=t.basic)||void 0===r?void 0:r.options)||[]});return X.jsx(ot,Object.assign({},h,{properties:s,formValue:[],disabled:!1,hideLabel:e}));case"radio":const a=Object.assign(Object.assign({},t),{options:(null===(n=t.basic)||void 0===n?void 0:n.options)||[]});return X.jsx(lt,Object.assign({},h,{properties:a,readonly:!1,disabled:!1,hideLabel:e}));case"date":case"date-picker":case"datetime-picker":return X.jsx(ut,Object.assign({},h,{properties:t,readonly:!1,disabled:!1,hideLabel:e}));case"signature":return X.jsx(ht,Object.assign({},h,{properties:t,hideLabel:e}));case"heading":return X.jsx(pt,Object.assign({},h,{properties:t,hideLabel:e}));case"instructions":return X.jsx(gt,Object.assign({},h,{properties:t,hideLabel:e}));default:return X.jsxs("div",{className:"unknown-component",children:["Unknown component: ",t.name]})}},[s,rt,a,o,l,c]),ft={backgroundColor:i.styles.backgroundColor||"var(--df-color-fb-container)",borderColor:i.styles.borderColor||"var(--df-color-fb-border)",borderWidth:i.styles.borderWidth||"2px",borderRadius:i.styles.borderRadius||"8px",padding:i.styles.padding||"16px",margin:i.styles.margin||"16px 0"};return X.jsxs("div",{className:`form-group df-form-datagrid ${d?"selected":""} ${f}`,onClick:tt,style:ft,children:[X.jsx("div",{className:"grid-header",children:X.jsx("div",{className:"grid-title",onClick:e=>{e.stopPropagation(),Y(!W),null==u||u({id:t,value:Object.assign(Object.assign({},i),{basic:Object.assign(Object.assign({},i.basic),{collapsed:!W})})})},children:X.jsxs("div",{className:"title-content",style:{display:"flex",alignItems:"center",gap:"8px"},children:[W?X.jsx(Q,{size:16}):X.jsx(F,{size:16}),X.jsx(S,{size:16}),X.jsx("span",{className:"grid-label",style:{fontWeight:"600"},children:i.basic.label}),i.validation.required&&X.jsx("span",{className:"required-indicator",style:{color:"#ef4444"},children:"*"})]})})}),i.basic.description&&!W&&X.jsx("div",{className:"grid-description",style:{marginTop:"8px",color:"var(--df-color-text-light)",fontSize:"14px"},children:i.basic.description}),!W&&X.jsx("div",{className:"grid-content",style:{marginTop:"16px"},children:"edit"===s?X.jsx(xt,{gridComponents:$,mode:s,onComponentSelect:g||(()=>{}),onComponentDelete:et,onComponentEdit:v,onComponentUpdate:At,selectedComponent:B||null,renderFormComponent:b||dt,gridId:t,formData:a,formTemplateId:x,onThresholdActionCompletion:U,onThresholdIssueRaised:E,onNotesChange:N,onAttachmentChange:L,workOrderNumber:I,assetNumber:_,user:user,onCreateIssue:O,onUpdateIssue:k}):X.jsx(Ft,{templateComponents:$,dataEntries:Z,renderFormComponent:b||dt,mode:s,allowAddRemoveEntries:null===(j=null===(T=i.datagrid)||void 0===T?void 0:T.allowAddRemoveEntries)||void 0===j||j,addAnotherText:null!==(P=null===(H=i.datagrid)||void 0===H?void 0:H.addAnotherText)&&void 0!==P?P:"Add Entry",removeText:null!==(M=null===(D=i.datagrid)||void 0===D?void 0:D.removeText)&&void 0!==M?M:"Remove",maxEntries:null!==(K=null===(R=i.datagrid)||void 0===R?void 0:R.maxEntries)&&void 0!==K?K:10,minEntries:null!==(z=null===(V=i.datagrid)||void 0===V?void 0:V.minEntries)&&void 0!==z?z:1,displayAsGrid:null===(q=null===(G=i.datagrid)||void 0===G?void 0:G.displayAsGrid)||void 0===q||q,onAddEntry:y||nt,onRemoveEntry:C||ct,formData:a,formTemplateId:x,onThresholdActionCompletion:U,onThresholdIssueRaised:E,onNotesChange:N,onAttachmentChange:L,datagridId:t,workOrderNumber:I,assetNumber:_,user:user,onCreateIssue:O,onUpdateIssue:k})})]})},Ut=t.lazy(()=>Promise.resolve().then(function(){return kt})),Et=({formComponents:i=[],currentDevice:s="desktop",isPreviewMode:a=!1,initialFormData:o=[],onSubmit:l,onFormDataChange:c,formTitle:u,formDescription:h,formTemplateId:d,onComponentSelect:f,onComponentDelete:p,onComponentEdit:g,onComponentUpdate:m,selectedComponent:v,workOrderNumber:w,assetNumber:B,isStandalone:b,user:y,onCreateIssue:C,onUpdateIssue:x})=>{const[F,Q]=e({}),[U,E]=e({}),[N,S]=e(!1),[L,I]=e({}),[_,O]=e({}),[k,T]=e(new Set),[j,H]=e(new Map),[P,D]=e({isValid:!0}),[M,R]=e({}),[K,V]=e({});A(()=>{G()},[i,o]);const z=(t,e)=>{t.forEach(t=>{if(t.id&&(void 0!==e[t.id]||(t.basic&&"value"in t.basic&&void 0!==t.basic.value&&""!==t.basic.value&&null!==t.basic.value?e[t.id]=t.basic.value:t.basic&&"defaultValue"in t.basic&&void 0!==t.basic.defaultValue&&""!==t.basic.defaultValue&&null!==t.basic.defaultValue?e[t.id]=t.basic.defaultValue:"checkbox"===t.name||"select"===t.name?e[t.id]=[]:e[t.id]="")),t.cells&&Array.isArray(t.cells)&&t.cells.forEach((t,A)=>{Array.isArray(t)&&t.forEach((t,A)=>{t&&t.components&&Array.isArray(t.components)&&z(t.components,e)})}),t.entries&&Array.isArray(t.entries)&&t.entries.forEach((t,A)=>{t&&t.components&&Array.isArray(t.components)&&z(t.components,e)}),"file"===t.name&&t.basic){const A=t.basic.files||t.basic.attachments||t.basic.value;A&&(e[t.id]=A)}if(t.id&&t.basic&&t.basic.notes,"instructions"===t.name&&t.basic){t.basic.instructions||(t.basic.instructions=[]);const A=t.basic.value||t.basic.instructions;A&&(e[t.id]=A)}t.children&&Array.isArray(t.children)&&z(t.children,e)})},G=r(()=>{const t={},e={},A={},r=new Set,n=t=>{t.forEach(t=>{var r,i,s,a,o;t.id&&(((null===(r=t.basic)||void 0===r?void 0:r.notes)||(null===(i=t.basic)||void 0===i?void 0:i.comments))&&(e[t.id]=(null===(s=t.basic)||void 0===s?void 0:s.notes)||(null===(a=t.basic)||void 0===a?void 0:a.comments)),(null===(o=t.basic)||void 0===o?void 0:o.attachments)&&(A[t.id]=t.basic.attachments)),t.children&&n(t.children),t.cells&&t.cells.forEach(t=>t.forEach(t=>{t.components&&n(t.components)})),t.entries&&t.entries.forEach(t=>{t.components&&n(t.components)})})},s=t=>{t.forEach((t,e)=>{var A;if(t.id&&"string"==typeof t.id&&""!==t.id.trim())r.has(t.id)&&(console.error(`[DfFormPreview] Duplicate component ID detected: ${t.id}. Component:`,t),t.id=`${t.id}-duplicate-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,console.warn(`[DfFormPreview] Generated new unique ID: ${t.id}`));else{const r=t.name||"component",n=((null===(A=t.basic)||void 0===A?void 0:A.label)||"").replace(/[^a-zA-Z0-9]/g,"").toLowerCase().substring(0,10);t.id=`${r}-${n||"gen"}-${Date.now()}-${Math.random().toString(36).substr(2,6)}-${e}`}r.add(t.id),t.children&&Array.isArray(t.children)&&s(t.children),t.cells&&Array.isArray(t.cells)&&t.cells.forEach(t=>{Array.isArray(t)&&t.forEach(t=>{t&&t.components&&Array.isArray(t.components)&&s(t.components)})}),t.entries&&Array.isArray(t.entries)&&t.entries.forEach(t=>{t&&t.components&&Array.isArray(t.components)&&s(t.components)})})};i&&i.length>0&&s(i),o&&o.length>0&&s(o),o&&o.length>0&&z(o,t),o&&o.length>0&&z(o,t),i&&i.length>0&&(z(i,t),n(i)),Q(e=>Object.assign(Object.assign({},t),e)),R(t=>Object.assign(Object.assign({},e),t)),V(t=>Object.assign(Object.assign({},A),t)),W()},[o,i]),q=(t,e)=>{t.forEach(t=>{if(t.id)if("table"===t.name||"datagrid"===t.name)e[t.id]=!0;else if(t.conditional){const A=J.evaluateConditionalLogic(t.conditional,i,F);e[t.id]=A.shouldShow}else e[t.id]=!0;t.cells&&Array.isArray(t.cells)&&t.cells.forEach(t=>{t.forEach(t=>{t.components&&Array.isArray(t.components)&&q(t.components,e)})}),t.entries&&Array.isArray(t.entries)&&t.entries.forEach(t=>{t.components&&Array.isArray(t.components)&&q(t.components,e)}),t.children&&Array.isArray(t.children)&&q(t.children,e)})},W=r(()=>{const t={};i&&i.length>0&&q(i,t),O(t)},[i,F]),Y=r(t=>{const e=i.find(e=>e.id===t);if(e&&("table"===e.name||"datagrid"===e.name))return!0;return!1!==_[t]},[_,i]),Z=r(t=>{if(!t.id||"string"!=typeof t.id||""===t.id.trim())return void console.error("[DfFormPreview] Invalid component ID in onFormValueChange:",t);const e=i.filter(e=>e.id===t.id);if(e.length>1)return void console.error(`[DfFormPreview] ID COLLISION DETECTED! Multiple components share ID "${t.id}":`,e.map(t=>{var e;return{id:t.id,name:t.name,label:null===(e=t.basic)||void 0===e?void 0:e.label}}));const A=F[t.id];void 0!==A&&A!==t.value&&console.log("[DfFormPreview] Updating form value:",{id:t.id,oldValue:A,newValue:t.value});const r=Object.assign(Object.assign({},F),{[t.id]:t.value});Q(r);const n=i.find(e=>e.id===t.id);if(n){const t=null==n?void 0:n.threshold;t&&t.conditions&&t.conditions.length>0&&T(e=>{const A=new Set(e);return t.conditions.forEach(t=>{A.delete(t.id)}),A})}const s=e=>e.map(e=>{var A;return e.id===t.id&&"defaultValue"in e.basic?Object.assign(Object.assign({},e),{basic:Object.assign(Object.assign({},e.basic),{value:null!==(A=t.value)&&void 0!==A?A:e.basic.defaultValue,defaultValue:t.value})}):"section"===e.name&&e.children?Object.assign(Object.assign({},e),{children:s(e.children)}):"table"===e.name&&e.cells?Object.assign(Object.assign({},e),{cells:e.cells.map(t=>t.map(t=>{const e=Object.assign({},t);return e.components&&(e.components=s(e.components)),e}))}):"datagrid"===e.name&&e.entries?Object.assign(Object.assign({},e),{entries:e.entries.map(t=>{const e=Object.assign({},t);return e.components&&(e.components=s(e.components)),e})}):e}),o=s(i);if(null==c||c(o),U[t.id]&&E(e=>Object.assign(Object.assign({},e),{[t.id]:""})),!a){if(t.isValid)return void E(e=>{const A=e[t.id];return A&&""!==A.trim()?Object.assign(Object.assign({},e),{[t.id]:""}):e});setTimeout(()=>{et(t.id)},150)}setTimeout(()=>{const t={};i.forEach(e=>{if("table"===e.name||"datagrid"===e.name)t[e.id]=!0;else if(e.conditional){const A=J.evaluateConditionalLogic(e.conditional,i,r);t[e.id]=A.shouldShow}else t[e.id]=!0}),O(t)},0)},[i,F,U,c]),tt=r((t,e)=>{for(const A of t){if(A.id===e)return A;if("section"===A.name&&A.children){const t=tt(A.children,e);if(t)return t}if("table"===A.name&&A.cells)for(const t of A.cells)for(const A of t)if(A.components){const t=tt(A.components,e);if(t)return t}if("datagrid"===A.name&&A.entries)for(const t of A.entries)if(t.components){const A=tt(t.components,e);if(A)return A}}return null},[]),et=r(t=>{if(a)return;const e=tt(i,t);if(!e)return;const A=F[t]||"";if("number-input"===e.name&&(!A||""===A)){if(e.validation.required){const A=e.validation.customValidationMessage,r=e.basic.label||"This field",n=A||`${r} is required`;E(e=>Object.assign(Object.assign({},e),{[t]:n}))}else E(e=>Object.assign(Object.assign({},e),{[t]:""}));return}let r=!1;r=Array.isArray(A)?A.length>0:"string"==typeof A?""!==A.trim():null!=A;let n="";if(e.validation.required&&!r){const t=e.validation.customValidationMessage,A=e.basic.label||"This field";n=t||`${A} is required`}else if("email-input"===e.name&&r&&!/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(A)){const t=e.validation.customValidationMessage,A=e.basic.label||"This field";n=t||`${A} must be a valid email`}else if(e.validation.minLength&&r&&A.length<e.validation.minLength){const t=e.validation.customValidationMessage,A=e.basic.label||"This field";n=t||`${A} must be at least ${e.validation.minLength} characters`}else if(e.validation.maxLength&&r&&A.length>e.validation.maxLength){const t=e.validation.customValidationMessage,A=e.basic.label||"This field";n=t||`${A} must be no more than ${e.validation.maxLength} characters`}else if("number-input"===e.name&&r){const t=String(A).trim(),r=parseFloat(t);if(!isNaN(r)){const t=e.validation;t&&"lowerLimit"in t&&void 0!==t.lowerLimit&&null!==t.lowerLimit&&0!==t.lowerLimit&&r<t.lowerLimit?n="Number is below the lower limit":t&&"upperLimit"in t&&void 0!==t.upperLimit&&null!==t.upperLimit&&0!==t.upperLimit&&r>t.upperLimit&&(n="Number is above the upper limit")}}E(e=>Object.assign(Object.assign({},e),{[t]:n}))},[i,a,F,tt]),At=r(t=>{I(e=>Object.assign(Object.assign({},e),{[t]:!0})),a||setTimeout(()=>{et(t)},0)},[a,et]),rt=r(t=>{U[t]&&E(e=>Object.assign(Object.assign({},e),{[t]:""}))},[U]),nt=r(()=>!Object.values(U).some(t=>t&&"string"==typeof t&&""!==t.trim())&&i.every(t=>{const e=F[t.id]||"";let A=!1;if(A=Array.isArray(e)?e.length>0:"string"==typeof e?""!==e.trim():null!=e,t.validation.required&&!A)return!1;if("number-input"===t.name&&A){const A=String(e).trim(),r=parseFloat(A);if(!isNaN(r)){const e=t.validation;if(e&&"lowerLimit"in e&&void 0!==e.lowerLimit&&null!==e.lowerLimit&&0!==e.lowerLimit&&r<e.lowerLimit)return!1;if(e&&"upperLimit"in e&&void 0!==e.upperLimit&&null!==e.upperLimit&&0!==e.upperLimit&&r>e.upperLimit)return!1}}return!0}),[i,F,U]),mt=r((t,e)=>{if(Array.isArray(e))return e.some(e=>mt(t,e));if(null==e||""===e)return!1;const A="string"==typeof e?parseFloat(e):e,r="string"==typeof t.value?parseFloat(t.value):t.value;if(!isNaN(A)&&!isNaN(r))switch(t.operator){case"greaterThan":return A>r;case"lessThan":return A<r;case"greaterThanOrEqual":return A>=r;case"lessThanOrEqual":return A<=r;case"equals":return A===r;case"notEquals":return A!==r;default:return!1}const n=String(e).toLowerCase(),i=String(t.value).toLowerCase();switch(t.operator){case"equals":return n===i||String(e)===String(t.value);case"notEquals":return n!==i&&String(e)!==String(t.value);default:return!1}},[]),wt=r(()=>{if(a)return[];const t=[];return i.forEach(e=>{const A=null==e?void 0:e.condition;if(!A||!A.conditions||0===A.conditions.length)return;const r=F[e.id];null!=r&&""!==r&&!(Array.isArray(r)&&0===r.length)&&A.conditions.forEach(A=>{var n;mt(A,r)&&t.push({componentId:e.id,condition:A,componentLabel:(null===(n=e.basic)||void 0===n?void 0:n.label)||"Field"})})}),t},[i,F,a,mt]),bt=r(()=>{if(a)return{isValid:!0};const t=wt();if(0===t.length)return{isValid:!0};for(const{condition:e,componentLabel:A}of t){const t=j.get(e.id)||{notesCompleted:!1,attachmentsCompleted:!1,emailSent:!1},r=[];if(!0!==e.enableRaiseIssue||k.has(e.id)||r.push("raise an issue"),!0!==e.enableNotes||t.notesCompleted||r.push("add notes"),!0!==e.enableAttachment||t.attachmentsCompleted||r.push("add attachments"),!0!==e.enableSendEmail||t.emailSent||r.push("send email"),r.length>0){return{isValid:!1,errorMessage:`Please ${1===r.length?r[0]:r.slice(0,-1).join(", ")+" and "+r[r.length-1]} for the threshold condition met in "${A}". You cannot submit the form until all required actions are completed.`}}}return{isValid:!0}},[a,wt,k,j]),Ct=r(t=>{t&&T(e=>{const A=new Set(e);return A.add(t),A})},[]),xt=r((t,e,A)=>{t&&H(r=>{const n=new Map(r),i=n.get(t)||{notesCompleted:!1,attachmentsCompleted:!1,emailSent:!1};return"notes"===e?n.set(t,Object.assign(Object.assign({},i),{notesCompleted:A})):"attachments"===e?n.set(t,Object.assign(Object.assign({},i),{attachmentsCompleted:A})):"email"===e&&n.set(t,Object.assign(Object.assign({},i),{emailSent:A})),n})},[]);A(()=>{if(!a){const t=bt();D(t)}},[F,k,j,a,bt]);const Ft=r(()=>{if(a)return!0;let t=!0;S(!0);const e={};return i.forEach(A=>{const r=F[A.id]||"";let n=!1;if(n=Array.isArray(r)?r.length>0:"string"==typeof r?""!==r.trim():null!=r,A.validation.required&&!n){const r=A.validation.customValidationMessage,n=A.basic.label||"This field",i=r||`${n} is required`;e[A.id]=i,t=!1}else if("number-input"===A.name&&n){const n=String(r).trim(),i=parseFloat(n);if(isNaN(i))e[A.id]="";else{const r=A.validation;r&&"lowerLimit"in r&&void 0!==r.lowerLimit&&null!==r.lowerLimit&&0!==r.lowerLimit&&i<r.lowerLimit?(e[A.id]="Number is below the lower limit",t=!1):r&&"upperLimit"in r&&void 0!==r.upperLimit&&null!==r.upperLimit&&0!==r.upperLimit&&i>r.upperLimit?(e[A.id]="Number is above the upper limit",t=!1):e[A.id]=""}}else e[A.id]="";I(t=>Object.assign(Object.assign({},t),{[A.id]:!0}))}),E(e),t},[i,a,F]),Et=r((t="Submitted")=>{if(S(!0),!Ft()){const t=i.find(t=>{const e=F[t.id]||"";let A=!1;return A=Array.isArray(e)?e.length>0:"string"==typeof e?""!==e.trim():null!=e,t.validation.required&&!A});if(t){const e=document.getElementById(t.id);e&&e.focus()}return}const e=bt();if(!e.isValid){e.errorMessage&&$.showError(e.errorMessage);const t=wt().find(({condition:t})=>!k.has(t.id));if(t){const e=document.getElementById(t.componentId);e&&e.scrollIntoView({behavior:"smooth",block:"center"})}return}const A=t=>t.map(t=>{var e,r,n,i,s,a;let o=F[t.id];"text-input"===t.name&&(null===(e=t.basic)||void 0===e||e.label),void 0===o&&(o="value"in t.basic&&void 0!==t.basic.value?t.basic.value:"defaultValue"in t.basic&&void 0!==t.basic.defaultValue?t.basic.defaultValue:""),"text-input"===t.name&&(null===(r=t.basic)||void 0===r||r.label);const l=Object.assign(Object.assign({},t),{basic:Object.assign(Object.assign({},t.basic),{value:o,defaultValue:o,notes:void 0!==M[t.id]?M[t.id]:null===(n=t.basic)||void 0===n?void 0:n.notes,comments:void 0!==M[t.id]?M[t.id]:(null===(i=t.basic)||void 0===i?void 0:i.comments)||(null===(s=t.basic)||void 0===s?void 0:s.notes),attachments:void 0!==K[t.id]?K[t.id]:null===(a=t.basic)||void 0===a?void 0:a.attachments})});return"section"===l.name&&l.children&&(l.children=A(l.children)),"table"===l.name&&l.cells&&(l.cells=l.cells.map(t=>t.map(t=>{const e=Object.assign({},t);return e.components&&(e.components=A(e.components)),e}))),"datagrid"===l.name&&l.entries&&(l.entries=l.entries.map(t=>{const e=Object.assign({},t);return e.components&&(e.components=A(e.components)),e})),l}),r=A(i),n=Object.assign(Object.assign({},F),{status:t});null==l||l(r,n)},[i,F,Ft,l,M,K]),Nt=r(()=>({[`device-${s}`]:!0,readonly:a}),[s,a]),St=r((t,e)=>{R(A=>Object.assign(Object.assign({},A),{[t]:e}))},[]),Lt=r((t,e)=>{V(A=>Object.assign(Object.assign({},A),{[t]:e||[]}))},[]),It=n(new Map),_t=n(0),Ot=e=>{var A,r,n,s,a,o,l,u,h,b,E,S,I;let _;if(e.id&&"string"==typeof e.id&&""!==e.id.trim())_=e.id;else{const t=(null===(A=e.basic)||void 0===A?void 0:A.label)||"",r=e.name||"unknown",n=`${r}-${t}`;let i=It.current.get(n);i||(_t.current+=1,i=`generated-${r}-${_t.current}-${Math.random().toString(36).substr(2,9)}`,It.current.set(n,i),console.warn("[DfFormPreview] Generated and cached ID for component:",i,"key:",n)),_=i,e=Object.assign(Object.assign({},e),{id:_})}const O=_,T=F[O];if(void 0!==T){const t=i.filter(t=>t.id!==O&&F[t.id]===T);t.length>0&&console.warn(`[DfFormPreview] Component ${O} shares form value with other components:`,t.map(t=>t.id))}const j={id:O,validationErrors:U,formValue:T,touchedFields:L,formSubmitted:N,mode:"test",readonly:!1,onValueChange:Z,onBlur:()=>At(O),onFocus:()=>rt(O)};switch(e.name){case"text-input":case"number-input":case"email-input":return X.jsx(it,Object.assign({},j,{properties:e,inputType:"text-input"===e.name?"text":"number-input"===e.name?"number":"email",formTemplateId:d,onThresholdIssueRaised:Ct,raisedThresholdIssues:k,workOrderNumber:w,assetNumber:B,user:y}));case"textarea":return X.jsx(st,Object.assign({},j,{properties:e}));case"select":const A=Object.assign(Object.assign({},e),{options:(null===(r=e.basic)||void 0===r?void 0:r.options)||[],basic:Object.assign(Object.assign({},e.basic),{comments:(null===(n=e.basic)||void 0===n?void 0:n.comments)||""})});return X.jsx(at,Object.assign({},j,{properties:A}));case"checkbox":const _=Object.assign(Object.assign({},e),{options:(null===(s=e.basic)||void 0===s?void 0:s.options)||[],basic:Object.assign(Object.assign({},e.basic),{comments:(null===(a=e.basic)||void 0===a?void 0:a.comments)||""})});return X.jsx(ot,Object.assign({},j,{properties:_}));case"radio":const O=Object.assign(Object.assign({},e),{options:(null===(o=e.basic)||void 0===o?void 0:o.options)||[],basic:Object.assign(Object.assign({},e.basic),{comments:(null===(l=e.basic)||void 0===l?void 0:l.comments)||""})});return X.jsx(lt,Object.assign({},j,{properties:O}));case"segment":const H=Object.assign(Object.assign({},e),{options:(null===(u=e.basic)||void 0===u?void 0:u.options)||[],basic:Object.assign(Object.assign({},e.basic),{comments:(null===(h=e.basic)||void 0===h?void 0:h.comments)||""})});return X.jsx(ct,Object.assign({},j,{properties:H}));case"date":case"date-picker":case"datetime-picker":return X.jsx(ut,Object.assign({},j,{properties:e}));case"signature":return X.jsx(ht,Object.assign({},j,{properties:e}));case"heading":return X.jsx(pt,Object.assign({},j,{properties:e}));case"instructions":const P=T||(null===(b=e.basic)||void 0===b?void 0:b.value)||null;return X.jsx(gt,Object.assign({},j,{properties:e,formValue:P}));case"location":return X.jsx(ft,Object.assign({},j,{properties:e}));case"section":return X.jsx(yt,Object.assign({},j,{properties:e,formData:F,formTemplateId:d,onThresholdActionCompletion:xt,onThresholdIssueRaised:Ct,onNotesChange:St,onAttachmentChange:Lt,workOrderNumber:w,assetNumber:B,user:y,onCreateIssue:C,onUpdateIssue:x,renderFormComponent:t=>Ot(t)}));case"table":return X.jsx(t.Suspense,{fallback:X.jsx("div",{children:"Loading table..."}),children:X.jsx(Ut,Object.assign({},j,{properties:e,formData:F,formTemplateId:d,mode:j.mode,validationErrors:U,touchedFields:L,formSubmitted:N,onThresholdActionCompletion:xt,onThresholdIssueRaised:Ct,workOrderNumber:w,assetNumber:B,onCreateIssue:C,onUpdateIssue:x,onNotesChange:(t,A)=>{const r=i.map(r=>{if(r.id===e.id&&r.cells){const e=r.cells.map(e=>e.map(e=>{if(e.components){const r=e.components.map(e=>e.id===t?Object.assign(Object.assign({},e),{basic:Object.assign(Object.assign({},e.basic),{notes:A})}):e);return Object.assign(Object.assign({},e),{components:r})}return e}));return Object.assign(Object.assign({},r),{cells:e})}return r});null==c||c(r)},onAttachmentChange:(t,A)=>{const r=i.map(r=>{if(r.id===e.id&&r.cells){const e=r.cells.map(e=>e.map(e=>{if(e.components){const r=e.components.map(e=>e.id===t?Object.assign(Object.assign({},e),{basic:Object.assign(Object.assign({},e.basic),{attachments:A||[]})}):e);return Object.assign(Object.assign({},e),{components:r})}return e}));return Object.assign(Object.assign({},r),{cells:e})}return r});null==c||c(r)},renderFormComponent:t=>Ot(t)}))});case"datagrid":return X.jsx(Qt,Object.assign({},j,{properties:e,formData:F,formTemplateId:d,mode:j.mode,validationErrors:U,touchedFields:L,formSubmitted:N,onThresholdActionCompletion:xt,onThresholdIssueRaised:Ct,workOrderNumber:w,assetNumber:B,user:y,onComponentSelect:f,onComponentDelete:p,onComponentEdit:g,onCreateIssue:C,onUpdateIssue:x,onComponentUpdate:m,selectedComponent:v,onNotesChange:(t,A)=>{St(t,A);const r=i.map(r=>{if(r.id===e.id&&r.entries){const e=r.entries.map(e=>{if(e.components){const r=e.components.map(e=>e.id===t?Object.assign(Object.assign({},e),{basic:Object.assign(Object.assign({},e.basic),{notes:A||""})}):e);return Object.assign(Object.assign({},e),{components:r})}return e});return Object.assign(Object.assign({},r),{entries:e})}return r});null==c||c(r)},onAttachmentChange:(t,A)=>{Lt(t,A);const r=i.map(r=>{if(r.id===e.id&&r.entries){const e=r.entries.map(e=>{if(e.components){const r=e.components.map(e=>e.id===t?Object.assign(Object.assign({},e),{basic:Object.assign(Object.assign({},e.basic),{attachments:A||[]})}):e);return Object.assign(Object.assign({},e),{components:r})}return e});return Object.assign(Object.assign({},r),{entries:e})}return r});null==c||c(r)},onValueChange:t=>{if(t.id===e.id&&t.value&&"object"==typeof t.value&&"entries"in t.value){const A=i.map(A=>A.id===e.id?Object.assign(Object.assign({},A),t.value):A);null==c||c(A),t.value.entries&&Array.isArray(t.value.entries)&&t.value.entries.forEach(t=>{t.components&&Array.isArray(t.components)&&t.components.forEach(t=>{var e;if(void 0!==F[t.id]);else{const A=null===(e=t.basic)||void 0===e?void 0:e.defaultValue;void 0!==A&&Q(e=>Object.assign(Object.assign({},e),{[t.id]:A}))}})})}else Z(t)},onEntryAdd:()=>{const t=i.find(t=>t.id===e.id);if(t&&t.entries){const t=i.map(t=>t.id===e.id?Object.assign(Object.assign({},t),{entries:t.entries||[]}):t);null==c||c(t)}else setTimeout(()=>{const t=F[e.id];if(t&&"object"==typeof t&&"entries"in t){const A=i.map(A=>A.id===e.id?Object.assign(Object.assign({},A),{entries:t.entries}):A);null==c||c(A)}},100)},onEntryRemove:t=>{const A=i.map(A=>{if(A.id===e.id&&A.entries){const e=(A.entries||[]).filter((e,A)=>A!==t).map((t,e)=>{var r;return Object.assign(Object.assign({},t),{index:e,id:`entry-${A.id}-${e}`,components:(null===(r=t.components)||void 0===r?void 0:r.map((t,A)=>{const r=(t.templateComponents||[])[A];return Object.assign(Object.assign({},t),{id:r?`${r.id}-entry-${e}-${A}`:t.id})}))||[]})});return Object.assign(Object.assign({},A),{entries:e})}return A});null==c||c(A)},renderFormComponent:t=>Ot(t)}));case"file":const D=T||(null===(E=e.basic)||void 0===E?void 0:E.value)||(null===(S=e.basic)||void 0===S?void 0:S.files)||(null===(I=e.basic)||void 0===I?void 0:I.attachments)||null;return X.jsx(dt,Object.assign({},j,{properties:e,formValue:D}));default:return X.jsx("div",{className:"form-group",children:X.jsxs("div",{className:"form-group-label",children:["Unsupported Component: ",e.name]})})}};return X.jsx("div",{className:"form-preview-container",children:X.jsx("div",{className:"form-preview-wrapper",children:X.jsxs("div",{className:`form-preview ${Object.entries(Nt()).map(([t,e])=>e?t:"").join(" ")}`,children:[X.jsx("div",{className:"form-canvas-header"}),0===i.length?X.jsx("div",{className:"empty-state",children:X.jsx("div",{className:"empty-state-card",children:X.jsx("div",{className:"empty-state-preview-area",children:X.jsx("span",{className:"empty-state-placeholder",children:"Add components to see the form preview"})})})}):X.jsxs("form",{className:"form-preview-form",onSubmit:t=>{t.preventDefault(),Et()},children:[(u||h)&&X.jsxs("div",{className:"form-header",children:[u&&X.jsx("h1",{className:"form-title",children:u}),h&&X.jsx("p",{className:"form-description",children:h})]}),i.map(t=>{var e,A,r,n;const s=t.basic,o=F[t.id],l=["select","radio","checkbox","segment"].includes(t.name||""),u=t.options||(null==s?void 0:s.options)||[],h=(()=>{var e;const A=null===(e=null==t?void 0:t.styles)||void 0===e?void 0:e.column;return"section"===t.name||"table"===t.name||"datagrid"===t.name?"col-12":3===A?"col-3":6===A?"col-6":9===A?"col-9":"col-12"})();let f=!1;if(!a)if(l&&null!=o&&""!==o)if("checkbox"===t.name){f=(Array.isArray(o)?o:[o]).some(t=>{const e=u.find(e=>e.value===t);return e&&(e.enableNotes||e.enableAttachment||e.enableRaiseIssue||e.enableSendEmail)})}else{const t=u.find(t=>t.value===o);f=t&&(t.enableNotes||t.enableAttachment||t.enableRaiseIssue||t.enableSendEmail)}else f=(null==s?void 0:s.enableNotes)||(null==s?void 0:s.enableAttachment)||(null==s?void 0:s.enableRaiseIssue)||(null==s?void 0:s.enableSendEmail);const p=a&&((null===(e=t.basic)||void 0===e?void 0:e.notes)&&t.basic.notes.trim().length>0||(null===(A=t.basic)||void 0===A?void 0:A.attachments)&&Array.isArray(t.basic.attachments)&&t.basic.attachments.length>0);return X.jsxs("div",{className:`form-group ${h} ${f||p?"has-action-features":""}`,style:{display:Y(t.id)?"block":"none"},children:[Ot(t),!a&&!["section","table","heading","file","instructions","signature","location","datagrid"].includes(t.name)&&X.jsx(vt,{component:t,mode:a?"preview":"test",formTemplateId:d,formValue:o,onThresholdActionCompletion:xt,onThresholdIssueRaised:Ct,onNotesChange:e=>{R(A=>Object.assign(Object.assign({},A),{[t.id]:e}));const A=i.map(A=>A.id===t.id?Object.assign(Object.assign({},A),{basic:Object.assign(Object.assign({},A.basic),{notes:e||""})}):A);null==c||c(A)},onAttachmentChange:e=>{V(A=>Object.assign(Object.assign({},A),{[t.id]:e||[]}));const A=i.map(A=>A.id===t.id?Object.assign(Object.assign({},A),{basic:Object.assign(Object.assign({},A.basic),{attachments:e||[]})}):A);null==c||c(A)},notes:void 0!==M[t.id]?M[t.id]:(null===(r=t.basic)||void 0===r?void 0:r.notes)||"",attachments:void 0!==K[t.id]?K[t.id]:(null===(n=t.basic)||void 0===n?void 0:n.attachments)||null,workOrderNumber:w,assetNumber:B,isStandalone:b,user:y,onCreateIssue:C,onUpdateIssue:x}),a&&p&&X.jsx(Bt,{component:t})]},t.id)}),!a&&X.jsxs("div",{className:"form-actions",children:[X.jsx("button",{type:"button",onClick:()=>Et("Saved"),className:"form-save-button",disabled:N&&!nt(),children:"Save"}),X.jsx("button",{type:"button",disabled:!nt()||!P.isValid,className:"form-submit-button",title:P.isValid?"":P.errorMessage,onClick:()=>Et("Submitted"),children:"Submit"})]})]})]})})})},Nt=({comment:t="",onSave:n,placeholder:i="Enter your reason...",className:s="",disabled:a=!1})=>{const[o,l]=e(!0),[c,u]=e(t),[h,d]=e(!1);A(()=>{u(t),d(!1)},[t]);const f=r(e=>{const A=e.target.value;u(A),d(A!==t)},[t]),p=r(()=>{h&&n&&!a&&(n(c),d(!1))},[h,n,c,a]),g=r(()=>{},[]),m=r(()=>{a||l(!o)},[o,a]);return X.jsxs("div",{className:`df-form-comments ${s}`,children:[X.jsxs("div",{className:"df-form-comments__header",children:[X.jsx("h3",{className:"df-form-comments__title",children:"Comments"}),X.jsx("button",{className:"df-form-comments__toggle",type:"button",onClick:m,"aria-expanded":o,"aria-label":"Toggle comments section",disabled:a,children:o?X.jsx("span",{className:"df-form-comments__toggle-icon",children:"▼"}):X.jsx("span",{className:"df-form-comments__toggle-icon",children:"▶"})})]}),X.jsx("div",{className:"df-form-comments__content "+(o?"df-form-comments__content--expanded":""),children:X.jsx("div",{className:"df-form-comments__input-container",children:X.jsx("div",{className:"df-form-comments__input-line",children:X.jsx("input",{type:"text",id:"comment-input",className:"df-form-comments__input",value:c,onChange:f,onBlur:p,onFocus:g,placeholder:i,disabled:a})})})})]})},St=t=>t.id?t:Object.assign(Object.assign({},t),{id:D()}),Lt=({component:t,mode:e,renderFormComponent:A,formData:r={},formTemplateId:n,onThresholdActionCompletion:i,onThresholdIssueRaised:s,onNotesChange:a,onAttachmentChange:o,workOrderNumber:l,assetNumber:c,user:u,onCreateIssue:h,onUpdateIssue:d})=>{var f,p;const g=r[t.id],m="preview"===e&&((null===(f=t.basic)||void 0===f?void 0:f.notes)&&t.basic.notes.trim().length>0||(null===(p=t.basic)||void 0===p?void 0:p.attachments)&&Array.isArray(t.basic.attachments)&&t.basic.attachments.length>0);return X.jsxs("div",{className:"simple-table-component",children:[A(t),!["section","table","heading","file","instructions","signature","location","datagrid"].includes(t.name)&&X.jsx(vt,{component:t,mode:"test",formTemplateId:n,formValue:g,formData:r,onThresholdActionCompletion:i,onThresholdIssueRaised:s,onNotesChange:a?e=>a(t.id,e):void 0,onAttachmentChange:o?e=>o(t.id,e):void 0,workOrderNumber:l,assetNumber:c,user:u,onCreateIssue:h,onUpdateIssue:d}),m&&X.jsx(Bt,{component:t})]})},It=({component:t,selectedComponent:e,mode:A,onComponentSelect:r,onComponentDelete:n,onComponentEdit:i,renderFormComponent:s,isOverlay:a=!1})=>{const{attributes:o,listeners:l,setNodeRef:c,transform:u,transition:h,isDragging:d,isSorting:f}=j({id:t.id,disabled:a}),p={transform:P.Transform.toString(u),transition:h,opacity:d?.3:1,zIndex:d?1e3:"auto"};return X.jsxs("div",{ref:c,style:p,className:`form-component table-component ${(null==e?void 0:e.id)===t.id?"selected":""} ${d?"dragging":""} ${f?"sorting":""}`,onClick:()=>!d&&r(t),role:"button",tabIndex:0,children:["edit"===A&&X.jsx("div",Object.assign({className:"component-drag-handle"},l,o,{onClick:t=>t.stopPropagation(),style:{opacity:1},children:X.jsx(U,{size:14})})),X.jsx("div",{className:"component-content",children:s(t)}),"edit"===A&&X.jsxs("div",{className:"component-actions",style:{opacity:1},children:[i&&X.jsx("button",{className:"component-edit-btn",onClick:e=>{e.stopPropagation(),i(t)},type:"button",title:"Edit Component",children:X.jsx(E,{size:12})}),X.jsx("button",{className:"component-delete-btn",onClick:e=>{e.stopPropagation(),n(t,e)},type:"button",title:"Delete Component",children:X.jsx(N,{size:12})})]})]})},_t=({cell:t,mode:e,onComponentSelect:A,onComponentDelete:r,onComponentEdit:n,selectedComponent:i,renderFormComponent:s,formData:a={},formTemplateId:o,onThresholdActionCompletion:l,onThresholdIssueRaised:c,tableId:u,onNotesChange:h,onAttachmentChange:d,workOrderNumber:f,assetNumber:p,user:g,onCreateIssue:m,onUpdateIssue:v})=>{var w,B,b,y,C;const x=`table-cell-${u}-${t.row}-${t.column}`,{setNodeRef:F,isOver:Q}=O({id:x,disabled:"edit"!==e,data:{type:"table-cell",tableId:u,cell:t,row:t.row,column:t.column}}),U=Object.assign(Object.assign({},t.styles),{backgroundColor:Q?"var(--df-color-primary-light)":(null===(w=t.styles)||void 0===w?void 0:w.backgroundColor)||"transparent",minHeight:(null===(B=t.styles)||void 0===B?void 0:B.minHeight)||"preview"===e||"test"===e?"40px":"60px",padding:(null===(b=t.styles)||void 0===b||b.padding,"8px"),border:"preview"===e||"test"===e?"none":Q?"2px dashed var(--df-color-primary)":(null===(y=t.styles)||void 0===y?void 0:y.borderColor)?`1px solid ${t.styles.borderColor}`:"1px solid var(--df-color-fb-border)",borderRadius:"preview"===e||"test"===e?"0":"4px",position:"relative",verticalAlign:(null===(C=t.styles)||void 0===C?void 0:C.verticalAlign)||"top"});return X.jsx("td",{ref:F,style:U,className:"table-cell "+(Q?"drag-over":""),children:X.jsx("div",{className:"cell-content",children:t.components&&Array.isArray(t.components)&&t.components.length>0?"edit"===e?X.jsx(k,{items:t.components.map(t=>t.id||D()),strategy:T,children:t.components.map(t=>{const a=St(t);return X.jsx(It,{component:a,selectedComponent:i,mode:e,onComponentSelect:A,onComponentDelete:r,onComponentEdit:n,renderFormComponent:s},a.id)})}):t.components.map(t=>{const A=t.id?t:St(t);return X.jsx(Lt,{component:A,mode:e,renderFormComponent:s,formData:a,formTemplateId:o,onThresholdActionCompletion:l,onThresholdIssueRaised:c,onNotesChange:h,onAttachmentChange:d,workOrderNumber:f,assetNumber:p,user:g,onCreateIssue:m,onUpdateIssue:v},A.id)}):"edit"===e?X.jsx("div",{className:"empty-cell-placeholder",children:X.jsxs("div",{className:"cell-info",children:[X.jsx("span",{className:"drop-zone-text",children:"Drag and Drop a form component"}),X.jsxs("span",{className:"cell-coordinates",children:["Cell (",t.row+1,", ",t.column+1,")"]})]})}):X.jsx("div",{style:{minHeight:"20px",backgroundColor:"transparent",visibility:"hidden"},children:" "})})})},Ot=({id:t,properties:n,mode:s="edit",formData:a={},validationErrors:o={},touchedFields:l={},formSubmitted:c=!1,onValueChange:u,onSelect:h,isSelected:d=!1,className:f="",onTableSelect:p,onComponentSelect:g,onComponentDelete:m,onComponentEdit:v,selectedComponent:w,renderFormComponent:B,formTemplateId:b,onThresholdActionCompletion:y,onThresholdIssueRaised:C,onNotesChange:x,onAttachmentChange:U,workOrderNumber:E,assetNumber:N,user:S,onCreateIssue:I,onUpdateIssue:_})=>{var O,k,T,j,H,P,D,M,R,K,V,z,G,q,W,Y,J,$;const[Z,tt]=e(!1),et=(null===(O=n.cells)||void 0===O?void 0:O.some(t=>t.some(t=>t.components&&t.components.length>0)))||!1;A(()=>{},[null===(k=n.table)||void 0===k?void 0:k.rows,null===(T=n.table)||void 0===T?void 0:T.columns,null===(j=n.basic)||void 0===j?void 0:j.rows,null===(H=n.basic)||void 0===H?void 0:H.columns,n.cells,t,u]);const At=r(t=>{t.stopPropagation(),null==h||h(),null==p||p(n)},[h,p,n]),rt=r((e,A)=>{A.stopPropagation();const r=n.cells.map(t=>t.map(t=>{if(t.components&&t.components.some(t=>t.id===e.id)){const A=t.components.filter(t=>t.id!==e.id);return Object.assign(Object.assign({},t),{components:A})}return t}));u&&u({id:t,value:Object.assign(Object.assign({},n),{cells:r})})},[m,n,u,t]),nt=i(()=>n.cells?n.cells.map((e,A)=>e.map((e,r)=>Object.assign(Object.assign({},e),{components:e.components&&Array.isArray(e.components)?e.components.map((e,n)=>{if(e.id&&"string"==typeof e.id&&""!==e.id.trim())return e;const i=`${e.name||"component"}-table-${t}-row-${A}-cell-${r}-comp-${n}`;return Object.assign(Object.assign({},e),{id:i})}):[]}))):[],[n.cells,t]),ct=B||r(t=>{var e,A,r;const n=t.id?t:St(t),i=a[n.id]||"defaultValue"in n.basic&&n.basic.defaultValue||"";let o=i;"number-input"===n.name&&"number"==typeof i?o=String(i):"number-input"===n.name&&null==i&&(o="");const l={id:n.id,properties:n,validationErrors:{},formValue:o,touchedFields:{},formSubmitted:!1,mode:s,onValueChange:t=>{null==u||u(t)},onBlur:()=>{},onFocus:()=>{}};switch(n.name){case"text-input":case"email-input":case"number-input":return X.jsx(it,Object.assign({},l,{properties:n,inputType:"text-input"===n.name?"text":"number-input"===n.name?"number":"email",readonly:!1,disabled:!1}));case"textarea":return X.jsx(st,Object.assign({},l,{properties:n,readonly:!1,disabled:!1}));case"select":const t=Object.assign(Object.assign({},n),{options:(null===(e=n.basic)||void 0===e?void 0:e.options)||[]});return X.jsx(at,Object.assign({},l,{properties:t,disabled:!1}));case"checkbox":const i=Object.assign(Object.assign({},n),{options:(null===(A=n.basic)||void 0===A?void 0:A.options)||[]});return X.jsx(ot,Object.assign({},l,{properties:i,formValue:[],disabled:!1}));case"radio":const s=Object.assign(Object.assign({},n),{options:(null===(r=n.basic)||void 0===r?void 0:r.options)||[]});return X.jsx(lt,Object.assign({},l,{properties:s,readonly:!1,disabled:!1}));case"date":case"date-picker":case"datetime-picker":return X.jsx(ut,Object.assign({},l,{properties:n,readonly:!1,disabled:!1}));case"signature":return X.jsx(ht,Object.assign({},l,{properties:n}));case"heading":return X.jsx(pt,Object.assign({},l,{properties:n}));default:return X.jsxs("div",{className:"unknown-component",children:["Unknown component: ",n.name]})}},[B,s,a,u]),dt={backgroundColor:(null===(P=n.styles)||void 0===P?void 0:P.backgroundColor)||"var(--df-color-fb-container)",borderColor:(null===(D=n.styles)||void 0===D?void 0:D.borderColor)||"var(--df-color-fb-border)",borderWidth:(null===(M=n.styles)||void 0===M?void 0:M.borderWidth)||"2px",borderRadius:(null===(R=n.styles)||void 0===R?void 0:R.borderRadius)||"8px",padding:(null===(K=n.styles)||void 0===K?void 0:K.padding)||"16px",margin:(null===(V=n.styles)||void 0===V?void 0:V.margin)||"16px 0"},ft={width:"100%",minWidth:"600px",borderCollapse:"preview"===s||"test"===s?"separate":"collapse",tableLayout:"fixed",border:"preview"===s||"test"===s?"1px solid var(--df-color-fb-border)":"none"};return et||"preview"!==s?X.jsxs("div",{className:`form-group df-form-table ${d?"selected":""} ${"preview"===s?"preview-mode":"test"===s?"test-mode":""} ${f}`,onClick:At,style:dt,children:[X.jsx("div",{className:"table-header",children:X.jsx("div",{className:"table-title",onClick:e=>{e.stopPropagation(),tt(!Z),null==u||u({id:t,value:Object.assign(Object.assign({},n),{basic:Object.assign(Object.assign({},n.basic||{}),{collapsed:!Z})})})},children:X.jsxs("div",{className:"title-content",children:[Z?X.jsx(Q,{size:16}):X.jsx(F,{size:16}),X.jsx(L,{size:16}),X.jsx("span",{className:"table-label",children:(null===(z=n.basic)||void 0===z?void 0:z.label)||"Table"}),(null===(G=n.validation)||void 0===G?void 0:G.required)&&X.jsx("span",{className:"required-indicator",children:"*"})]})})}),(null===(q=n.basic)||void 0===q?void 0:q.description)&&!Z&&X.jsx("div",{className:"table-description",children:n.basic.description}),!Z&&X.jsxs("div",{className:"table-content",children:[null,X.jsxs("table",{style:ft,children:[(null===(W=n.table)||void 0===W?void 0:W.displayAsTable)&&("edit"===s||(null===(Y=n.table)||void 0===Y?void 0:Y.showColumns))&&X.jsx("thead",{children:X.jsx("tr",{className:"table-header-row",children:Array.from({length:(null===(J=n.table)||void 0===J?void 0:J.columns)||(null===($=n.basic)||void 0===$?void 0:$.columns)||3},(t,e)=>{var A,r;const i=((null===(r=null===(A=n.table)||void 0===A?void 0:A.columnNames)||void 0===r?void 0:r.split(",").map(t=>t.trim()))||[])[e]||`Column ${e+1}`;return X.jsx("th",{className:"table-header-cell",style:{backgroundColor:(n.styles.headerBackgroundColor,"var(--df-color-fb-container)"),color:n.styles.headerTextColor||"var(--df-color-text-dark)",padding:"12px",border:"1px solid var(--df-color-fb-border)",fontWeight:"600",fontSize:"14px",textAlign:"center"},children:i},`header-${e}`)})})}),X.jsx("tbody",{children:nt.map((e,A)=>X.jsx("tr",{className:"table-row",children:e.map(e=>X.jsx(_t,{cell:e,mode:s,onComponentSelect:g||(()=>{}),onComponentDelete:rt,onComponentEdit:v,selectedComponent:w||null,renderFormComponent:ct,formData:a,formTemplateId:b,onThresholdActionCompletion:y,onThresholdIssueRaised:C,tableId:t,onNotesChange:x,onAttachmentChange:U,workOrderNumber:E,assetNumber:N,user:S,onCreateIssue:I,onUpdateIssue:_},e.id))},A))})]})]})]}):null};var kt=Object.freeze({__proto__:null,DfFormTable:Ot,default:Ot});const Tt={page:{fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif',padding:"30px",backgroundColor:"#ffffff",color:"#000000",lineHeight:"1.4"},header:{marginBottom:"30px",paddingBottom:"15px",borderBottom:"2px solid #303992",display:"flex",justifyContent:"space-between",alignItems:"flex-end"},title:{margin:"0 0 5px 0",fontSize:"24px",fontWeight:"bold",color:"#303992"},description:{margin:"0",fontSize:"14px",color:"#666666"},submittedBy:{fontSize:"14px",color:"#333",textAlign:"right",whiteSpace:"nowrap",marginBottom:"2px"},formGroup:{marginBottom:"20px",breakInside:"avoid"},label:{fontWeight:"400",display:"block",marginBottom:"8px",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif',fontSize:"14px",lineHeight:"1.5",fontColor:"var(--df-color-text-dark)"},labelLeft:{fontWeight:"400",display:"block",marginRight:"10px",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif',fontSize:"14px",lineHeight:"1.5",width:"60%",fontColor:"var(--df-color-text-dark)"},valueContainer:{border:"1px solid #e2e8f0",borderRadius:"6px",padding:"8px 12px",backgroundColor:"#ffffff",minHeight:"20px",fontSize:"14px",flex:1},value:{fontSize:"14px",color:"#000000"},gridRow:{display:"flex",flexWrap:"wrap",gap:"16px",marginBottom:"20px"},gridCol:t=>({flex:`0 0 calc(${t/12*100}% - 8px)`,minWidth:"0"}),img:{maxWidth:"100%",maxHeight:"300px",border:"1px solid #ddd",borderRadius:"4px",display:"block",marginTop:"5px"},table:{width:"100%",borderCollapse:"collapse",border:"1px solid #ddd",marginTop:"10px",tableLayout:"fixed"},th:{border:"1px solid #ddd",padding:"8px",backgroundColor:"#f5f5f5",fontWeight:"bold",textAlign:"left",fontSize:"13px"},td:{border:"1px solid #ddd",padding:"8px",fontSize:"13px",verticalAlign:"top"},section:{marginBottom:"25px",breakInside:"avoid"},sectionHeader:{fontSize:"18px",marginBottom:"15px",display:"block",fontWeight:"600"},sectionChildren:{marginLeft:"20px",paddingLeft:"20px",borderLeft:"2px solid #3b82f6",marginTop:"15px"},notesSection:{marginTop:"10px",padding:"10px",backgroundColor:"rgba(48, 57, 146, 0.05)",borderLeft:"3px solid #303992",borderRadius:"4px",fontSize:"13px",boxSizing:"border-box"},notesLabel:{fontWeight:"bold",color:"#303992",marginRight:"5px"},attachmentsSection:{marginTop:"10px",padding:"10px",backgroundColor:"rgba(48, 57, 146, 0.05)",borderLeft:"3px solid #303992",borderRadius:"4px",display:"flex",flexWrap:"wrap",gap:"10px",boxSizing:"border-box"},attachmentThumbnail:{width:"60px",height:"60px",border:"1px solid #e5e7eb",borderRadius:"4px",overflow:"hidden",backgroundColor:"#fff",display:"flex",alignItems:"center",justifyContent:"center"},attachmentImg:{width:"100%",height:"100%",objectFit:"cover"},segmentContainer:{display:"flex",gap:"8px",flexWrap:"wrap",alignItems:"center"},segmentButton:{display:"flex",alignItems:"center",justifyContent:"center",padding:"4px 6px",borderRadius:"6px",border:"1px solid #e0e0e0",backgroundColor:"#ffffff",fontSize:"10px",fontWeight:600,minWidth:"30px",color:"#666"},segmentIcon:{marginRight:"4px",fontSize:"9px",fontWeight:"bold",display:"inline-block",lineHeight:"1"},checkboxItem:{display:"flex",alignItems:"center",padding:"10px 14px",backgroundColor:"#f8f9fa",borderRadius:"6px",marginBottom:"8px",width:"100%",boxSizing:"border-box"}},jt=t=>{if(!t||"string"!=typeof t)return!1;const e=t.trim();return e.startsWith("data:image")||e.startsWith("iVBORw0KGgo")||e.startsWith("/9j/4AAQ")||e.startsWith("UklGR")||e.startsWith("R0lGOD")},Ht=(t,e)=>{if(!t)return"";const A=t.trim();return A.startsWith("data:")||A.startsWith("http")||A.startsWith("blob:")||A.startsWith("/")?A:A.startsWith("iVBORw0KGgo")?`data:image/png;base64,${A}`:A.startsWith("/9j/4AAQ")?`data:image/jpeg;base64,${A}`:A.startsWith("UklGR")?`data:image/webp;base64,${A}`:A.startsWith("R0lGOD")?`data:image/gif;base64,${A}`:e&&e.startsWith("image/")?`data:${e};base64,${A}`:A},Pt=t=>{const e=String(t||"").toLowerCase();return"pass"===e||"yes"===e?"pass":"fail"===e||"no"===e?"fail":"pass"},Dt=({component:t})=>{var e,A;const r=(null===(e=t.basic)||void 0===e?void 0:e.notes)||"",n=(null===(A=t.basic)||void 0===A?void 0:A.attachments)||[];return r.trim()||0!==n.length?X.jsxs("div",{style:{marginTop:"5px"},children:[r.trim().length>0&&X.jsxs("div",{style:Tt.notesSection,children:[X.jsx("span",{style:Tt.notesLabel,children:"Notes:"}),r]}),n.length>0&&X.jsx("div",{style:Tt.attachmentsSection,children:n.map((t,e)=>{var A;const r=!(!t.data&&!t.url),n=((null===(A=t.type)||void 0===A?void 0:A.startsWith("image/"))||jt(t.data||t.url||""))&&r?Ht(t.data||t.url||"",t.type):null;return X.jsx("div",{style:Tt.attachmentThumbnail,children:n?X.jsx("img",{src:n,alt:t.name||"Attachment",style:Tt.attachmentImg}):X.jsx("span",{style:{fontSize:"20px",color:"#999"},children:"📎"})},e)})})]}):null},Mt=({component:t})=>{var e,A,r,n,i,s,a,o;const l=void 0!==(null===(e=t.basic)||void 0===e?void 0:e.value)?t.basic.value:null===(A=t.basic)||void 0===A?void 0:A.defaultValue,{name:c}=t;if("signature"===c)return l&&jt(l)?X.jsx("div",{style:{marginTop:"5px"},children:X.jsx("img",{src:Ht(l),alt:"Signature",style:Object.assign(Object.assign({},Tt.img),{maxHeight:"100px",width:"auto"})})}):X.jsx("span",{style:{color:"#999",fontStyle:"italic"},children:"No signature"});if("checkbox"===c){const e=(null===(r=t.basic)||void 0===r?void 0:r.options)||[],A=(Array.isArray(l)?l:l?[l]:[]).map(t=>String(t));return X.jsx("div",{style:{marginTop:"5px",width:"100%"},children:e.map((t,e)=>{const r=A.includes(String(t.value));return X.jsxs("div",{style:Tt.checkboxItem,children:[X.jsx("div",{style:{width:"18px",height:"18px",minWidth:"18px",border:"2px solid "+(r?"#303992":"#cbd5e1"),borderRadius:"4px",marginRight:"12px",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:r?"#303992":"#ffffff"},children:r&&X.jsx("span",{style:{color:"#ffffff",fontSize:"12px",fontWeight:"bold",lineHeight:1},children:"✓"})}),X.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:"#334155"},children:t.label})]},e)})})}if("radio"===c){const e=(null===(n=t.basic)||void 0===n?void 0:n.options)||[];return X.jsx("div",{style:{marginTop:"5px",width:"100%"},children:e.map((t,e)=>{const A=String(l||"")===String(t.value||"");return X.jsxs("div",{style:Tt.checkboxItem,children:[X.jsx("div",{style:{width:"18px",height:"18px",minWidth:"18px",border:"2px solid "+(A?"#303992":"#cbd5e1"),borderRadius:"50%",marginRight:"12px",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#ffffff"},children:A&&X.jsx("div",{style:{width:"10px",height:"10px",borderRadius:"50%",backgroundColor:"#303992"}})}),X.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:"#334155"},children:t.label})]},e)})})}if("segment"===c){const e=(null===(i=t.basic)||void 0===i?void 0:i.options)||[],A=l;return X.jsx("div",{style:Tt.segmentContainer,children:e.map((t,e)=>{const r=String(A||"")===String(t.value||""),n=(t=>void 0!==(null==t?void 0:t.icon)&&null!==(null==t?void 0:t.icon)?t.icon:"pass"===Pt((null==t?void 0:t.value)||t)?"✓":"×")(t),i=t.color||t.backgroundColor,s=Pt(t.value);let a,o,l;i?r?(a=i,o="#ffffff",l=i):(a=`${i}20`,o=i,l=i):"pass"===s?r?(a="#00814b",o="#ffffff",l="#00814b"):(a="#34bd4914",o="#00814b",l="#e0e0e0"):r?(a="#dc3545",o="#ffffff",l="#dc3545"):(a="#fa323d14",o="#dc3545",l="#e0e0e0");const c=Object.assign(Object.assign({},Tt.segmentButton),{backgroundColor:a,color:o,borderColor:l,borderWidth:"1px",borderStyle:"solid"});return X.jsxs("div",{style:c,children:[X.jsx("span",{style:Tt.segmentIcon,children:n}),X.jsx("span",{children:t.value})]},e)})})}if("file"===c){const t=(Array.isArray(l)?l:l?[l]:[]).filter(t=>{const e=!(!t.data&&!t.url),A=t.type&&t.type.startsWith("image/"),r=e&&jt(t.data||t.url);return A||r});return t.length>0?X.jsx("div",{style:{marginTop:"10px"},children:t.map((t,e)=>{const A=Ht(t.data||t.url,t.type);return A?X.jsx("img",{src:A,alt:t.name||"File",style:Object.assign(Object.assign({},Tt.img),{marginBottom:"10px"})},e):null})}):X.jsx("div",{style:{color:"#999",fontStyle:"italic"},children:"No images uploaded"})}if("location"===c){if(l&&"object"==typeof l){const t=l;return X.jsxs("div",{style:{fontSize:"14px"},children:[t.placeName&&X.jsxs("div",{style:{marginBottom:"4px"},children:[X.jsx("strong",{children:"Place:"})," ",t.placeName]}),(t.city||t.country)&&X.jsxs("div",{style:{marginBottom:"4px"},children:[X.jsx("strong",{children:"Address:"})," ",[t.city,t.country].filter(Boolean).join(", ")]}),t.latitude&&t.longitude&&X.jsxs("div",{style:{marginBottom:"4px"},children:[X.jsx("strong",{children:"Coordinates:"})," ",t.latitude.toFixed(6),", ",t.longitude.toFixed(6)]}),t.timestamp&&X.jsxs("div",{children:[X.jsx("strong",{children:"Captured:"})," ",(et(t.timestamp)||new Date).toLocaleString()]})]})}return X.jsx("div",{style:{color:"#999",fontStyle:"italic"},children:"No location data"})}if("instructions"===c){const e=(null===(s=t.basic)||void 0===s?void 0:s.instructions)||[],A=(null===(a=t.validation)||void 0===a?void 0:a.listStyle)||"numbers";if(!Array.isArray(e)||0===e.length)return X.jsx("div",{style:{color:"#999",fontStyle:"italic"},children:"No instructions"});const r=()=>X.jsx("div",{dangerouslySetInnerHTML:{__html:e.join("")}});return"numbers"===A?X.jsx("ol",{style:{margin:"10px 0",paddingLeft:"25px"},children:X.jsx(r,{})}):"bullets"===A?X.jsx("ul",{style:{margin:"10px 0",paddingLeft:"25px"},children:X.jsx(r,{})}):X.jsx("div",{style:{margin:"10px 0"},children:X.jsx(r,{})})}if("select"===c){const e=(null===(o=t.basic)||void 0===o?void 0:o.options)||[],A=l;let r="";if(Array.isArray(A))r=A.map(t=>{const A=e.find(e=>String(e.value)===String(t));return A?A.label:t}).join(", ");else{const t=A,n=e.find(e=>String(e.value)===String(t));r=n?n.label||n.value:null!=t?String(t):""}return X.jsx("div",{style:Tt.valueContainer,children:X.jsx("div",{style:Tt.value,children:r})})}const u="object"==typeof l?JSON.stringify(l):String(l);if(!["signature","checkbox","radio","segment","file","instructions","heading","section","table","datagrid","select"].includes(c)){const t="textarea"===c;return X.jsx("div",{style:Object.assign(Object.assign({},Tt.valueContainer),t?{minHeight:"60px",whiteSpace:"pre-wrap"}:{}),children:X.jsx("div",{style:Tt.value,children:u})})}return X.jsx("div",{style:Tt.value,children:u})},Rt=({component:t})=>{var e,A,r;const{name:n,basic:i,styles:s,validation:a}=t,o=null==i?void 0:i.label,l=null==a?void 0:a.required,c="left"===((null==s?void 0:s.labelAlignment)||"top");if("section"===n){const e=null==s?void 0:s.headerBackgroundColor,A=null==s?void 0:s.headerTextColor,r=Object.assign(Object.assign(Object.assign(Object.assign({},Tt.sectionHeader),e?{backgroundColor:e,padding:"8px",borderRadius:"4px"}:{}),A?{color:A}:{}),{display:"flex",alignItems:"center"});return X.jsxs("div",{style:Tt.section,children:[o&&X.jsx("label",{style:r,children:X.jsxs("span",{style:{flex:1},children:[o,l&&" *"]})}),(null==i?void 0:i.description)&&X.jsx("p",{style:Object.assign(Object.assign({},Tt.description),{marginBottom:"15px"}),children:i.description}),X.jsx(Dt,{component:t}),X.jsx("div",{style:Tt.sectionChildren,children:X.jsx(Kt,{components:t.children||[]})})]})}if("heading"===n){const t=`h${Math.max(1,Math.min(6,null!==(A=null!==(e=null==s?void 0:s.level)&&void 0!==e?e:null==i?void 0:i.level)&&void 0!==A?A:1))}`,r=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},(null==s?void 0:s.headerBackgroundColor)?{backgroundColor:s.headerBackgroundColor,padding:"8px",borderRadius:"4px"}:{}),(null==s?void 0:s.headerTextColor)?{color:s.headerTextColor}:{}),(null==s?void 0:s.fontSize)?{fontSize:s.fontSize}:{}),(null==s?void 0:s.textAlign)?{textAlign:s.textAlign}:{}),{marginTop:0,marginBottom:"15px"});return X.jsx("div",{style:Tt.formGroup,children:X.jsx(t,{style:r,children:(null==i?void 0:i.label)||(null==i?void 0:i.value)})})}if("table"===n){const e=t.cells||[],A=Math.max(0,...e.map(t=>t?t.length:0)),r=A>0?100/A:100,n=null==s?void 0:s.headerBackgroundColor,i=null==s?void 0:s.headerTextColor,a=Object.assign(Object.assign(Object.assign({},Tt.label),n?{backgroundColor:n,padding:"8px",borderRadius:"4px",marginBottom:"10px"}:{}),i?{color:i}:{});return X.jsxs("div",{style:Tt.formGroup,children:[o&&X.jsxs("label",{style:a,children:[o,l&&" *"]}),X.jsx("table",{style:Tt.table,children:X.jsx("tbody",{children:e.map((t,e)=>X.jsx("tr",{children:t&&t.map((t,e)=>X.jsx("td",{style:Object.assign(Object.assign({},Tt.td),{width:`${r}%`}),children:t.components&&t.components.map((t,e)=>{var A;return X.jsxs("div",{style:{marginBottom:"8px"},children:[(null===(A=t.basic)||void 0===A?void 0:A.label)&&X.jsxs("span",{style:{fontWeight:"bold",marginRight:"5px",fontSize:"12px"},children:[t.basic.label,":"]}),X.jsx(Mt,{component:t}),X.jsx(Dt,{component:t})]},e)})},e))},e))})})]})}if("datagrid"===n){const e=t.entries||[];let A=t.templateComponents||[];0===A.length&&e.length>0&&(null===(r=e[0])||void 0===r?void 0:r.components)&&(A=e[0].components.map(t=>{var e;return Object.assign(Object.assign({},t),{basic:Object.assign(Object.assign({},t.basic),{label:(null===(e=t.basic)||void 0===e?void 0:e.label)||t.name})})}));const n=null==s?void 0:s.headerBackgroundColor,i=null==s?void 0:s.headerTextColor,a=Object.assign(Object.assign(Object.assign({},Tt.label),n?{backgroundColor:n,padding:"8px",borderRadius:"4px",marginBottom:"10px"}:{}),i?{color:i}:{}),c=e.filter(t=>!(!t.components||0===t.components.length)&&t.components.some(t=>{var e,A;const r=void 0!==(null===(e=t.basic)||void 0===e?void 0:e.value)?t.basic.value:null===(A=t.basic)||void 0===A?void 0:A.defaultValue;return Array.isArray(r)?r.length>0:null!=r&&""!==String(r).trim()}));return 0===c.length?X.jsxs("div",{style:Tt.formGroup,children:[o&&X.jsxs("label",{style:a,children:[o,l&&" *"]}),X.jsx("div",{style:{fontStyle:"italic",color:"#999"},children:"No data"})]}):X.jsxs("div",{style:Tt.formGroup,children:[o&&X.jsxs("label",{style:a,children:[o,l&&" *"]}),X.jsxs("table",{style:Tt.table,children:[X.jsx("thead",{children:X.jsx("tr",{children:A.map((t,e)=>{var A;return X.jsx("th",{style:Tt.th,children:(null===(A=t.basic)||void 0===A?void 0:A.label)||t.name},e)})})}),X.jsx("tbody",{children:c.map((t,e)=>X.jsx("tr",{children:A.map((e,A)=>{const r=t.components[A];return X.jsx("td",{style:Tt.td,children:r?X.jsxs(X.Fragment,{children:[X.jsx(Mt,{component:r}),X.jsx(Dt,{component:r})]}):"N/A"},A)})},e))})]})]})}if(c&&"instructions"!==n){const e=["segment"].includes(n);return X.jsxs("div",{style:Tt.formGroup,children:[X.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[o&&X.jsxs("label",{style:Tt.labelLeft,children:[o,l&&" *"]}),X.jsx("div",{style:Object.assign({flex:1},e?{display:"flex",justifyContent:"flex-end"}:{}),children:X.jsx(Mt,{component:t})})]}),X.jsx(Dt,{component:t})]})}return X.jsxs("div",{style:Tt.formGroup,children:[o&&X.jsxs("label",{style:Tt.label,children:[o,l&&" *"]}),X.jsx(Mt,{component:t}),X.jsx(Dt,{component:t})]})},Kt=({components:t})=>{if(!t||0===t.length)return null;const e=[];let A=[],r=0;return t.forEach(t=>{var n;const i=["section","table","datagrid","heading","instructions"].includes(t.name),s=i?12:(null===(n=t.styles)||void 0===n?void 0:n.column)||12;r+s>12&&A.length>0&&(e.push(A),A=[],r=0),A.push(t),r+=s,(i||r>=12)&&r>0&&(e.push(A),A=[],r=0)}),A.length>0&&e.push(A),X.jsx(X.Fragment,{children:e.map((t,e)=>1===t.length?X.jsx(Rt,{component:t[0]},t[0].id||e):X.jsx("div",{style:Tt.gridRow,children:t.map((t,e)=>{var A;const r=(null===(A=t.styles)||void 0===A?void 0:A.column)||12;return X.jsx("div",{style:Tt.gridCol(r),children:X.jsx(Rt,{component:t})},t.id||e)})},e))})},Vt=({formTitle:t,formDescription:e,userName:A,components:r})=>X.jsxs("div",{className:"pdf-container",style:Tt.page,children:[X.jsxs("div",{style:Tt.header,children:[X.jsxs("div",{children:[X.jsx("h1",{style:Tt.title,children:t}),e&&X.jsx("p",{style:Tt.description,children:e})]}),A&&X.jsxs("div",{style:Tt.submittedBy,children:[X.jsx("strong",{children:"Submitted By:"})," ",A]})]}),X.jsx("div",{className:"form-content",children:X.jsx(Kt,{components:r})})]});var zt,Gt=I;if("production"===process.env.NODE_ENV)zt=Gt.createRoot,Gt.hydrateRoot;else{var qt=Gt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;zt=function(t,e){qt.usingClientEntryPoint=!0;try{return Gt.createRoot(t,e)}finally{qt.usingClientEntryPoint=!1}}}var Wt={exports:{}};
11
11
  /*!
12
12
  * html2canvas 1.4.1 <https://html2canvas.hertzen.com>
13
13
  * Copyright (c) 2022 Niklas von Hertzen <https://hertzen.com>
@@ -304,7 +304,7 @@ function(t){var e=function(){return void 0===this.internal.vFS&&(this.internal.v
304
304
  * Unicode Bidi Engine based on the work of Alex Shensis (@asthensis)
305
305
  * MIT License
306
306
  */
307
- function(t){t.__bidiEngine__=t.prototype.__bidiEngine__=function(t){var A,r,n,i,s,a,o,l=e,c=[[0,3,0,1,0,0,0],[0,3,0,1,2,2,0],[0,3,0,17,2,0,1],[0,3,5,5,4,1,0],[0,3,21,21,4,0,1],[0,3,5,5,4,2,0]],u=[[2,0,1,1,0,1,0],[2,0,1,1,0,2,0],[2,0,2,1,3,2,0],[2,0,2,33,3,1,1]],h={L:0,R:1,EN:2,AN:3,N:4,B:5,S:6},d={0:0,5:1,6:2,7:3,32:4,251:5,254:6,255:7},f=["(",")","(","<",">","<","[","]","[","{","}","{","«","»","«","‹","›","‹","⁅","⁆","⁅","⁽","⁾","⁽","₍","₎","₍","≤","≥","≤","〈","〉","〈","﹙","﹚","﹙","﹛","﹜","﹛","﹝","﹞","﹝","﹤","﹥","﹤"],p=new RegExp(/^([1-4|9]|1[0-9]|2[0-9]|3[0168]|4[04589]|5[012]|7[78]|159|16[0-9]|17[0-2]|21[569]|22[03489]|250)$/),g=!1,m=0;this.__bidiEngine__={};var v=function(t){var e=t.charCodeAt(),A=e>>8,r=d[A];return void 0!==r?l[256*r+(255&e)]:252===A||253===A?"AL":p.test(A)?"L":8===A?"R":"N"},w=function(t){for(var e,A=0;A<t.length;A++){if("L"===(e=v(t.charAt(A))))return!1;if("R"===e)return!0}return!1},B=function(t,e,s,a){var o,l,c,u,h=e[a];switch(h){case"L":case"R":case"LRE":case"RLE":case"LRO":case"RLO":case"PDF":g=!1;break;case"N":case"AN":break;case"EN":g&&(h="AN");break;case"AL":g=!0,h="R";break;case"WS":case"BN":h="N";break;case"CS":a<1||a+1>=e.length||"EN"!==(o=s[a-1])&&"AN"!==o||"EN"!==(l=e[a+1])&&"AN"!==l?h="N":g&&(l="AN"),h=l===o?l:"N";break;case"ES":h="EN"===(o=a>0?s[a-1]:"B")&&a+1<e.length&&"EN"===e[a+1]?"EN":"N";break;case"ET":if(a>0&&"EN"===s[a-1]){h="EN";break}if(g){h="N";break}for(c=a+1,u=e.length;c<u&&"ET"===e[c];)c++;h=c<u&&"EN"===e[c]?"EN":"N";break;case"NSM":if(n&&!i){for(u=e.length,c=a+1;c<u&&"NSM"===e[c];)c++;if(c<u){var d=t[a],f=d>=1425&&d<=2303||64286===d;if(o=e[c],f&&("R"===o||"AL"===o)){h="R";break}}}h=a<1||"B"===(o=e[a-1])?"N":s[a-1];break;case"B":g=!1,A=!0,h=m;break;case"S":r=!0,h="N"}return h},b=function(t,e,A){var r=t.split("");return A&&y(r,A,{hiLevel:m}),r.reverse(),e&&e.reverse(),r.join("")},y=function(t,e,n){var i,s,a,o,l,d=-1,f=t.length,p=0,w=[],b=m?u:c,y=[];for(g=!1,A=!1,r=!1,s=0;s<f;s++)y[s]=v(t[s]);for(a=0;a<f;a++){if(l=p,w[a]=B(t,y,w,a),i=240&(p=b[l][h[w[a]]]),p&=15,e[a]=o=b[p][5],i>0)if(16===i){for(s=d;s<a;s++)e[s]=1;d=-1}else d=-1;if(b[p][6])-1===d&&(d=a);else if(d>-1){for(s=d;s<a;s++)e[s]=o;d=-1}"B"===y[a]&&(e[a]=0),n.hiLevel|=o}r&&function(t,e,A){for(var r=0;r<A;r++)if("S"===t[r]){e[r]=m;for(var n=r-1;n>=0&&"WS"===t[n];n--)e[n]=m}}(y,e,f)},C=function(t,e,r,n,i){if(!(i.hiLevel<t)){if(1===t&&1===m&&!A)return e.reverse(),void(r&&r.reverse());for(var s,a,o,l,c=e.length,u=0;u<c;){if(n[u]>=t){for(o=u+1;o<c&&n[o]>=t;)o++;for(l=u,a=o-1;l<a;l++,a--)s=e[l],e[l]=e[a],e[a]=s,r&&(s=r[l],r[l]=r[a],r[a]=s);u=o}u++}}},x=function(t,e,A){var r=t.split(""),n={hiLevel:m};return A||(A=[]),y(r,A,n),function(t,e,A){if(0!==A.hiLevel&&o)for(var r,n=0;n<t.length;n++)1===e[n]&&(r=f.indexOf(t[n]))>=0&&(t[n]=f[r+1])}(r,A,n),C(2,r,e,A,n),C(1,r,e,A,n),r.join("")};return this.__bidiEngine__.doBidiReorder=function(t,e,A){if(function(t,e){if(e)for(var A=0;A<t.length;A++)e[A]=A;void 0===i&&(i=w(t)),void 0===a&&(a=w(t))}(t,e),n||!s||a)if(n&&s&&i^a)m=i?1:0,t=b(t,e,A);else if(!n&&s&&a)m=i?1:0,t=x(t,e,A),t=b(t,e);else if(!n||i||s||a){if(n&&!s&&i^a)t=b(t,e),i?(m=0,t=x(t,e,A)):(m=1,t=x(t,e,A),t=b(t,e));else if(n&&i&&!s&&a)m=1,t=x(t,e,A),t=b(t,e);else if(!n&&!s&&i^a){var r=o;i?(m=1,t=x(t,e,A),m=0,o=!1,t=x(t,e,A),o=r):(m=0,t=x(t,e,A),t=b(t,e),m=1,o=!1,t=x(t,e,A),o=r,t=b(t,e))}}else m=0,t=x(t,e,A);else m=i?1:0,t=x(t,e,A);return t},this.__bidiEngine__.setOptions=function(t){t&&(n=t.isInputVisual,s=t.isOutputVisual,i=t.isInputRtl,a=t.isOutputRtl,o=t.isSymmetricSwapping)},this.__bidiEngine__.setOptions(t),this.__bidiEngine__};var e=["BN","BN","BN","BN","BN","BN","BN","BN","BN","S","B","S","WS","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","B","B","B","S","WS","N","N","ET","ET","ET","N","N","N","N","N","ES","CS","ES","CS","CS","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","CS","N","N","N","N","N","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","N","N","N","N","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","N","N","N","BN","BN","BN","BN","BN","BN","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","CS","N","ET","ET","ET","ET","N","N","N","N","L","N","N","BN","N","N","ET","ET","EN","EN","N","L","N","N","N","EN","L","N","N","N","N","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","N","L","L","L","L","L","L","L","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","L","N","N","N","N","N","ET","N","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","R","NSM","R","NSM","NSM","R","NSM","NSM","R","NSM","N","N","N","N","N","N","N","N","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","N","N","N","N","N","R","R","R","R","R","N","N","N","N","N","N","N","N","N","N","N","AN","AN","AN","AN","AN","AN","N","N","AL","ET","ET","AL","CS","AL","N","N","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","AL","AL","N","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","AN","AN","AN","AN","AN","AN","AN","AN","AN","AN","ET","AN","AN","AL","AL","AL","NSM","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","AN","N","NSM","NSM","NSM","NSM","NSM","NSM","AL","AL","NSM","NSM","N","NSM","NSM","NSM","NSM","AL","AL","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","N","AL","AL","NSM","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","N","N","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","AL","N","N","N","N","N","N","N","N","N","N","N","N","N","N","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","R","R","N","N","N","N","R","N","N","N","N","N","WS","WS","WS","WS","WS","WS","WS","WS","WS","WS","WS","BN","BN","BN","L","R","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","WS","B","LRE","RLE","PDF","LRO","RLO","CS","ET","ET","ET","ET","ET","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","CS","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","WS","BN","BN","BN","BN","BN","N","LRI","RLI","FSI","PDI","BN","BN","BN","BN","BN","BN","EN","L","N","N","EN","EN","EN","EN","EN","EN","ES","ES","N","N","N","L","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","ES","ES","N","N","N","N","L","L","L","L","L","L","L","L","L","L","L","L","L","N","N","N","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","L","L","L","L","L","L","L","N","N","N","N","N","N","N","N","N","N","N","N","L","L","L","L","L","N","N","N","N","N","R","NSM","R","R","R","R","R","R","R","R","R","R","ES","R","R","R","R","R","R","R","R","R","R","R","R","R","N","R","R","R","R","R","N","R","N","R","R","N","R","R","N","R","R","R","R","R","R","R","R","R","R","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","CS","N","CS","N","N","CS","N","N","N","N","N","N","N","N","N","ET","N","N","ES","ES","N","N","N","N","N","ET","ET","N","N","N","N","N","AL","AL","AL","AL","AL","N","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","N","N","BN","N","N","N","ET","ET","ET","N","N","N","N","N","ES","CS","ES","CS","CS","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","CS","N","N","N","N","N","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","N","N","N","N","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","N","N","N","N","N","N","N","N","N","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","N","N","L","L","L","L","L","L","N","N","L","L","L","L","L","L","N","N","L","L","L","L","L","L","N","N","L","L","L","N","N","N","ET","ET","N","N","N","ET","ET","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N"],A=new t.__bidiEngine__({isInputVisual:!0});t.API.events.push(["postProcessText",function(t){var e=t.text;t.x,t.y;var r=t.options||{};t.mutex,r.lang;var n=[];if(r.isInputVisual="boolean"!=typeof r.isInputVisual||r.isInputVisual,A.setOptions(r),"[object Array]"===Object.prototype.toString.call(e)){var i=0;for(n=[],i=0;i<e.length;i+=1)"[object Array]"===Object.prototype.toString.call(e[i])?n.push([A.doBidiReorder(e[i][0]),e[i][1],e[i][2]]):n.push([A.doBidiReorder(e[i])]);t.text=n}else t.text=A.doBidiReorder(e);A.setOptions({isInputVisual:!0})}])}(Ls),Ls.API.TTFFont=function(){function t(t){var e;if(this.rawData=t,e=this.contents=new no(t),this.contents.pos=4,"ttcf"===e.readString(4))throw new Error("TTCF not supported.");e.pos=0,this.parse(),this.subset=new xo(this),this.registerTTF()}return t.open=function(e){return new t(e)},t.prototype.parse=function(){return this.directory=new io(this.contents),this.head=new oo(this),this.name=new go(this),this.cmap=new co(this),this.toUnicode={},this.hhea=new uo(this),this.maxp=new mo(this),this.hmtx=new vo(this),this.post=new fo(this),this.os2=new ho(this),this.loca=new Co(this),this.glyf=new Bo(this),this.ascender=this.os2.exists&&this.os2.ascender||this.hhea.ascender,this.decender=this.os2.exists&&this.os2.decender||this.hhea.decender,this.lineGap=this.os2.exists&&this.os2.lineGap||this.hhea.lineGap,this.bbox=[this.head.xMin,this.head.yMin,this.head.xMax,this.head.yMax]},t.prototype.registerTTF=function(){var t,e,A,r,n;if(this.scaleFactor=1e3/this.head.unitsPerEm,this.bbox=function(){var e,A,r,n;for(n=[],e=0,A=(r=this.bbox).length;e<A;e++)t=r[e],n.push(Math.round(t*this.scaleFactor));return n}.call(this),this.stemV=0,this.post.exists?(A=255&(r=this.post.italic_angle),32768&(e=r>>16)&&(e=-(1+(65535^e))),this.italicAngle=+(e+"."+A)):this.italicAngle=0,this.ascender=Math.round(this.ascender*this.scaleFactor),this.decender=Math.round(this.decender*this.scaleFactor),this.lineGap=Math.round(this.lineGap*this.scaleFactor),this.capHeight=this.os2.exists&&this.os2.capHeight||this.ascender,this.xHeight=this.os2.exists&&this.os2.xHeight||0,this.familyClass=(this.os2.exists&&this.os2.familyClass||0)>>8,this.isSerif=1===(n=this.familyClass)||2===n||3===n||4===n||5===n||7===n,this.isScript=10===this.familyClass,this.flags=0,this.post.isFixedPitch&&(this.flags|=1),this.isSerif&&(this.flags|=2),this.isScript&&(this.flags|=8),0!==this.italicAngle&&(this.flags|=64),this.flags|=32,!this.cmap.unicode)throw new Error("No unicode cmap for font")},t.prototype.characterToGlyph=function(t){var e;return(null!=(e=this.cmap.unicode)?e.codeMap[t]:void 0)||0},t.prototype.widthOfGlyph=function(t){var e;return e=1e3/this.head.unitsPerEm,this.hmtx.forGlyph(t).advance*e},t.prototype.widthOfString=function(t,e,A){var r,n,i,s;for(i=0,n=0,s=(t=""+t).length;0<=s?n<s:n>s;n=0<=s?++n:--n)r=t.charCodeAt(n),i+=this.widthOfGlyph(this.characterToGlyph(r))+A*(1e3/e)||0;return i*(e/1e3)},t.prototype.lineHeight=function(t,e){var A;return null==e&&(e=!1),A=e?this.lineGap:0,(this.ascender+A-this.decender)/1e3*t},t}();var ro,no=function(){function t(t){this.data=null!=t?t:[],this.pos=0,this.length=this.data.length}return t.prototype.readByte=function(){return this.data[this.pos++]},t.prototype.writeByte=function(t){return this.data[this.pos++]=t},t.prototype.readUInt32=function(){return 16777216*this.readByte()+(this.readByte()<<16)+(this.readByte()<<8)+this.readByte()},t.prototype.writeUInt32=function(t){return this.writeByte(t>>>24&255),this.writeByte(t>>16&255),this.writeByte(t>>8&255),this.writeByte(255&t)},t.prototype.readInt32=function(){var t;return(t=this.readUInt32())>=2147483648?t-4294967296:t},t.prototype.writeInt32=function(t){return t<0&&(t+=4294967296),this.writeUInt32(t)},t.prototype.readUInt16=function(){return this.readByte()<<8|this.readByte()},t.prototype.writeUInt16=function(t){return this.writeByte(t>>8&255),this.writeByte(255&t)},t.prototype.readInt16=function(){var t;return(t=this.readUInt16())>=32768?t-65536:t},t.prototype.writeInt16=function(t){return t<0&&(t+=65536),this.writeUInt16(t)},t.prototype.readString=function(t){var e,A;for(A=[],e=0;0<=t?e<t:e>t;e=0<=t?++e:--e)A[e]=String.fromCharCode(this.readByte());return A.join("")},t.prototype.writeString=function(t){var e,A,r;for(r=[],e=0,A=t.length;0<=A?e<A:e>A;e=0<=A?++e:--e)r.push(this.writeByte(t.charCodeAt(e)));return r},t.prototype.readShort=function(){return this.readInt16()},t.prototype.writeShort=function(t){return this.writeInt16(t)},t.prototype.readLongLong=function(){var t,e,A,r,n,i,s,a;return t=this.readByte(),e=this.readByte(),A=this.readByte(),r=this.readByte(),n=this.readByte(),i=this.readByte(),s=this.readByte(),a=this.readByte(),128&t?-1*(72057594037927940*(255^t)+281474976710656*(255^e)+1099511627776*(255^A)+4294967296*(255^r)+16777216*(255^n)+65536*(255^i)+256*(255^s)+(255^a)+1):72057594037927940*t+281474976710656*e+1099511627776*A+4294967296*r+16777216*n+65536*i+256*s+a},t.prototype.writeLongLong=function(t){var e,A;return e=Math.floor(t/4294967296),A=4294967295&t,this.writeByte(e>>24&255),this.writeByte(e>>16&255),this.writeByte(e>>8&255),this.writeByte(255&e),this.writeByte(A>>24&255),this.writeByte(A>>16&255),this.writeByte(A>>8&255),this.writeByte(255&A)},t.prototype.readInt=function(){return this.readInt32()},t.prototype.writeInt=function(t){return this.writeInt32(t)},t.prototype.read=function(t){var e,A;for(e=[],A=0;0<=t?A<t:A>t;A=0<=t?++A:--A)e.push(this.readByte());return e},t.prototype.write=function(t){var e,A,r,n;for(n=[],A=0,r=t.length;A<r;A++)e=t[A],n.push(this.writeByte(e));return n},t}(),io=function(){var t;function e(t){var e,A,r;for(this.scalarType=t.readInt(),this.tableCount=t.readShort(),this.searchRange=t.readShort(),this.entrySelector=t.readShort(),this.rangeShift=t.readShort(),this.tables={},A=0,r=this.tableCount;0<=r?A<r:A>r;A=0<=r?++A:--A)e={tag:t.readString(4),checksum:t.readInt(),offset:t.readInt(),length:t.readInt()},this.tables[e.tag]=e}return e.prototype.encode=function(e){var A,r,n,i,s,a,o,l,c,u,h,d,f;for(f in h=Object.keys(e).length,a=Math.log(2),c=16*Math.floor(Math.log(h)/a),i=Math.floor(c/a),l=16*h-c,(r=new no).writeInt(this.scalarType),r.writeShort(h),r.writeShort(c),r.writeShort(i),r.writeShort(l),n=16*h,o=r.pos+n,s=null,d=[],e)for(u=e[f],r.writeString(f),r.writeInt(t(u)),r.writeInt(o),r.writeInt(u.length),d=d.concat(u),"head"===f&&(s=o),o+=u.length;o%4;)d.push(0),o++;return r.write(d),A=2981146554-t(r.data),r.pos=s+8,r.writeUInt32(A),r.data},t=function(t){var e,A,r,n;for(t=wo.call(t);t.length%4;)t.push(0);for(r=new no(t),A=0,e=0,n=t.length;e<n;e=e+=4)A+=r.readUInt32();return 4294967295&A},e}(),so={}.hasOwnProperty,ao=function(t,e){for(var A in e)so.call(e,A)&&(t[A]=e[A]);function r(){this.constructor=t}return r.prototype=e.prototype,t.prototype=new r,t.__super__=e.prototype,t};ro=function(){function t(t){var e;this.file=t,e=this.file.directory.tables[this.tag],this.exists=!!e,e&&(this.offset=e.offset,this.length=e.length,this.parse(this.file.contents))}return t.prototype.parse=function(){},t.prototype.encode=function(){},t.prototype.raw=function(){return this.exists?(this.file.contents.pos=this.offset,this.file.contents.read(this.length)):null},t}();var oo=function(){function t(){return t.__super__.constructor.apply(this,arguments)}return ao(t,ro),t.prototype.tag="head",t.prototype.parse=function(t){return t.pos=this.offset,this.version=t.readInt(),this.revision=t.readInt(),this.checkSumAdjustment=t.readInt(),this.magicNumber=t.readInt(),this.flags=t.readShort(),this.unitsPerEm=t.readShort(),this.created=t.readLongLong(),this.modified=t.readLongLong(),this.xMin=t.readShort(),this.yMin=t.readShort(),this.xMax=t.readShort(),this.yMax=t.readShort(),this.macStyle=t.readShort(),this.lowestRecPPEM=t.readShort(),this.fontDirectionHint=t.readShort(),this.indexToLocFormat=t.readShort(),this.glyphDataFormat=t.readShort()},t.prototype.encode=function(t){var e;return(e=new no).writeInt(this.version),e.writeInt(this.revision),e.writeInt(this.checkSumAdjustment),e.writeInt(this.magicNumber),e.writeShort(this.flags),e.writeShort(this.unitsPerEm),e.writeLongLong(this.created),e.writeLongLong(this.modified),e.writeShort(this.xMin),e.writeShort(this.yMin),e.writeShort(this.xMax),e.writeShort(this.yMax),e.writeShort(this.macStyle),e.writeShort(this.lowestRecPPEM),e.writeShort(this.fontDirectionHint),e.writeShort(t),e.writeShort(this.glyphDataFormat),e.data},t}(),lo=function(){function t(t,e){var A,r,n,i,s,a,o,l,c,u,h,d,f,p,g,m,v;switch(this.platformID=t.readUInt16(),this.encodingID=t.readShort(),this.offset=e+t.readInt(),c=t.pos,t.pos=this.offset,this.format=t.readUInt16(),this.length=t.readUInt16(),this.language=t.readUInt16(),this.isUnicode=3===this.platformID&&1===this.encodingID&&4===this.format||0===this.platformID&&4===this.format,this.codeMap={},this.format){case 0:for(a=0;a<256;++a)this.codeMap[a]=t.readByte();break;case 4:for(h=t.readUInt16(),u=h/2,t.pos+=6,n=function(){var e,A;for(A=[],a=e=0;0<=u?e<u:e>u;a=0<=u?++e:--e)A.push(t.readUInt16());return A}(),t.pos+=2,f=function(){var e,A;for(A=[],a=e=0;0<=u?e<u:e>u;a=0<=u?++e:--e)A.push(t.readUInt16());return A}(),o=function(){var e,A;for(A=[],a=e=0;0<=u?e<u:e>u;a=0<=u?++e:--e)A.push(t.readUInt16());return A}(),l=function(){var e,A;for(A=[],a=e=0;0<=u?e<u:e>u;a=0<=u?++e:--e)A.push(t.readUInt16());return A}(),r=(this.length-t.pos+this.offset)/2,s=function(){var e,A;for(A=[],a=e=0;0<=r?e<r:e>r;a=0<=r?++e:--e)A.push(t.readUInt16());return A}(),a=g=0,v=n.length;g<v;a=++g)for(p=n[a],A=m=d=f[a];d<=p?m<=p:m>=p;A=d<=p?++m:--m)0===l[a]?i=A+o[a]:0!==(i=s[l[a]/2+(A-d)-(u-a)]||0)&&(i+=o[a]),this.codeMap[A]=65535&i}t.pos=c}return t.encode=function(t,e){var A,r,n,i,s,a,o,l,c,u,h,d,f,p,g,m,v,w,B,b,y,C,x,F,Q,U,E,N,S,L,I,_,O,k,T,j,H,P,D,M,R,K,V,z,G,q;switch(N=new no,i=Object.keys(t).sort(function(t,e){return t-e}),e){case"macroman":for(f=0,p=function(){var t=[];for(d=0;d<256;++d)t.push(0);return t}(),m={0:0},n={},S=0,O=i.length;S<O;S++)null==m[V=t[r=i[S]]]&&(m[V]=++f),n[r]={old:t[r],new:m[t[r]]},p[r]=m[t[r]];return N.writeUInt16(1),N.writeUInt16(0),N.writeUInt32(12),N.writeUInt16(0),N.writeUInt16(262),N.writeUInt16(0),N.write(p),{charMap:n,subtable:N.data,maxGlyphID:f+1};case"unicode":for(U=[],c=[],v=0,m={},A={},g=o=null,L=0,k=i.length;L<k;L++)null==m[B=t[r=i[L]]]&&(m[B]=++v),A[r]={old:B,new:m[B]},s=m[B]-r,null!=g&&s===o||(g&&c.push(g),U.push(r),o=s),g=r;for(g&&c.push(g),c.push(65535),U.push(65535),F=2*(x=U.length),C=2*Math.pow(Math.log(x)/Math.LN2,2),u=Math.log(C/2)/Math.LN2,y=2*x-C,a=[],b=[],h=[],d=I=0,T=U.length;I<T;d=++I){if(Q=U[d],l=c[d],65535===Q){a.push(0),b.push(0);break}if(Q-(E=A[Q].new)>=32768)for(a.push(0),b.push(2*(h.length+x-d)),r=_=Q;Q<=l?_<=l:_>=l;r=Q<=l?++_:--_)h.push(A[r].new);else a.push(E-Q),b.push(0)}for(N.writeUInt16(3),N.writeUInt16(1),N.writeUInt32(12),N.writeUInt16(4),N.writeUInt16(16+8*x+2*h.length),N.writeUInt16(0),N.writeUInt16(F),N.writeUInt16(C),N.writeUInt16(u),N.writeUInt16(y),R=0,j=c.length;R<j;R++)r=c[R],N.writeUInt16(r);for(N.writeUInt16(0),K=0,H=U.length;K<H;K++)r=U[K],N.writeUInt16(r);for(z=0,P=a.length;z<P;z++)s=a[z],N.writeUInt16(s);for(G=0,D=b.length;G<D;G++)w=b[G],N.writeUInt16(w);for(q=0,M=h.length;q<M;q++)f=h[q],N.writeUInt16(f);return{charMap:A,subtable:N.data,maxGlyphID:v+1}}},t}(),co=function(){function t(){return t.__super__.constructor.apply(this,arguments)}return ao(t,ro),t.prototype.tag="cmap",t.prototype.parse=function(t){var e,A,r;for(t.pos=this.offset,this.version=t.readUInt16(),r=t.readUInt16(),this.tables=[],this.unicode=null,A=0;0<=r?A<r:A>r;A=0<=r?++A:--A)e=new lo(t,this.offset),this.tables.push(e),e.isUnicode&&null==this.unicode&&(this.unicode=e);return!0},t.encode=function(t,e){var A,r;return null==e&&(e="macroman"),A=lo.encode(t,e),(r=new no).writeUInt16(0),r.writeUInt16(1),A.table=r.data.concat(A.subtable),A},t}(),uo=function(){function t(){return t.__super__.constructor.apply(this,arguments)}return ao(t,ro),t.prototype.tag="hhea",t.prototype.parse=function(t){return t.pos=this.offset,this.version=t.readInt(),this.ascender=t.readShort(),this.decender=t.readShort(),this.lineGap=t.readShort(),this.advanceWidthMax=t.readShort(),this.minLeftSideBearing=t.readShort(),this.minRightSideBearing=t.readShort(),this.xMaxExtent=t.readShort(),this.caretSlopeRise=t.readShort(),this.caretSlopeRun=t.readShort(),this.caretOffset=t.readShort(),t.pos+=8,this.metricDataFormat=t.readShort(),this.numberOfMetrics=t.readUInt16()},t}(),ho=function(){function t(){return t.__super__.constructor.apply(this,arguments)}return ao(t,ro),t.prototype.tag="OS/2",t.prototype.parse=function(t){if(t.pos=this.offset,this.version=t.readUInt16(),this.averageCharWidth=t.readShort(),this.weightClass=t.readUInt16(),this.widthClass=t.readUInt16(),this.type=t.readShort(),this.ySubscriptXSize=t.readShort(),this.ySubscriptYSize=t.readShort(),this.ySubscriptXOffset=t.readShort(),this.ySubscriptYOffset=t.readShort(),this.ySuperscriptXSize=t.readShort(),this.ySuperscriptYSize=t.readShort(),this.ySuperscriptXOffset=t.readShort(),this.ySuperscriptYOffset=t.readShort(),this.yStrikeoutSize=t.readShort(),this.yStrikeoutPosition=t.readShort(),this.familyClass=t.readShort(),this.panose=function(){var e,A;for(A=[],e=0;e<10;++e)A.push(t.readByte());return A}(),this.charRange=function(){var e,A;for(A=[],e=0;e<4;++e)A.push(t.readInt());return A}(),this.vendorID=t.readString(4),this.selection=t.readShort(),this.firstCharIndex=t.readShort(),this.lastCharIndex=t.readShort(),this.version>0&&(this.ascent=t.readShort(),this.descent=t.readShort(),this.lineGap=t.readShort(),this.winAscent=t.readShort(),this.winDescent=t.readShort(),this.codePageRange=function(){var e,A;for(A=[],e=0;e<2;e=++e)A.push(t.readInt());return A}(),this.version>1))return this.xHeight=t.readShort(),this.capHeight=t.readShort(),this.defaultChar=t.readShort(),this.breakChar=t.readShort(),this.maxContext=t.readShort()},t}(),fo=function(){function t(){return t.__super__.constructor.apply(this,arguments)}return ao(t,ro),t.prototype.tag="post",t.prototype.parse=function(t){var e,A,r;switch(t.pos=this.offset,this.format=t.readInt(),this.italicAngle=t.readInt(),this.underlinePosition=t.readShort(),this.underlineThickness=t.readShort(),this.isFixedPitch=t.readInt(),this.minMemType42=t.readInt(),this.maxMemType42=t.readInt(),this.minMemType1=t.readInt(),this.maxMemType1=t.readInt(),this.format){case 65536:case 196608:break;case 131072:var n;for(A=t.readUInt16(),this.glyphNameIndex=[],n=0;0<=A?n<A:n>A;n=0<=A?++n:--n)this.glyphNameIndex.push(t.readUInt16());for(this.names=[],r=[];t.pos<this.offset+this.length;)e=t.readByte(),r.push(this.names.push(t.readString(e)));return r;case 151552:return A=t.readUInt16(),this.offsets=t.read(A);case 262144:return this.map=function(){var e,A,r;for(r=[],n=e=0,A=this.file.maxp.numGlyphs;0<=A?e<A:e>A;n=0<=A?++e:--e)r.push(t.readUInt32());return r}.call(this)}},t}(),po=function(t,e){this.raw=t,this.length=t.length,this.platformID=e.platformID,this.encodingID=e.encodingID,this.languageID=e.languageID},go=function(){function t(){return t.__super__.constructor.apply(this,arguments)}return ao(t,ro),t.prototype.tag="name",t.prototype.parse=function(t){var e,A,r,n,i,s,a,o,l,c,u;for(t.pos=this.offset,t.readShort(),e=t.readShort(),s=t.readShort(),A=[],n=0;0<=e?n<e:n>e;n=0<=e?++n:--n)A.push({platformID:t.readShort(),encodingID:t.readShort(),languageID:t.readShort(),nameID:t.readShort(),length:t.readShort(),offset:this.offset+s+t.readShort()});for(a={},n=l=0,c=A.length;l<c;n=++l)r=A[n],t.pos=r.offset,o=t.readString(r.length),i=new po(o,r),null==a[u=r.nameID]&&(a[u]=[]),a[r.nameID].push(i);this.strings=a,this.copyright=a[0],this.fontFamily=a[1],this.fontSubfamily=a[2],this.uniqueSubfamily=a[3],this.fontName=a[4],this.version=a[5];try{this.postscriptName=a[6][0].raw.replace(/[\x00-\x19\x80-\xff]/g,"")}catch(t){this.postscriptName=a[4][0].raw.replace(/[\x00-\x19\x80-\xff]/g,"")}return this.trademark=a[7],this.manufacturer=a[8],this.designer=a[9],this.description=a[10],this.vendorUrl=a[11],this.designerUrl=a[12],this.license=a[13],this.licenseUrl=a[14],this.preferredFamily=a[15],this.preferredSubfamily=a[17],this.compatibleFull=a[18],this.sampleText=a[19]},t}(),mo=function(){function t(){return t.__super__.constructor.apply(this,arguments)}return ao(t,ro),t.prototype.tag="maxp",t.prototype.parse=function(t){return t.pos=this.offset,this.version=t.readInt(),this.numGlyphs=t.readUInt16(),this.maxPoints=t.readUInt16(),this.maxContours=t.readUInt16(),this.maxCompositePoints=t.readUInt16(),this.maxComponentContours=t.readUInt16(),this.maxZones=t.readUInt16(),this.maxTwilightPoints=t.readUInt16(),this.maxStorage=t.readUInt16(),this.maxFunctionDefs=t.readUInt16(),this.maxInstructionDefs=t.readUInt16(),this.maxStackElements=t.readUInt16(),this.maxSizeOfInstructions=t.readUInt16(),this.maxComponentElements=t.readUInt16(),this.maxComponentDepth=t.readUInt16()},t}(),vo=function(){function t(){return t.__super__.constructor.apply(this,arguments)}return ao(t,ro),t.prototype.tag="hmtx",t.prototype.parse=function(t){var e,A,r,n,i,s,a;for(t.pos=this.offset,this.metrics=[],e=0,s=this.file.hhea.numberOfMetrics;0<=s?e<s:e>s;e=0<=s?++e:--e)this.metrics.push({advance:t.readUInt16(),lsb:t.readInt16()});for(r=this.file.maxp.numGlyphs-this.file.hhea.numberOfMetrics,this.leftSideBearings=function(){var A,n;for(n=[],e=A=0;0<=r?A<r:A>r;e=0<=r?++A:--A)n.push(t.readInt16());return n}(),this.widths=function(){var t,e,A,r;for(r=[],t=0,e=(A=this.metrics).length;t<e;t++)n=A[t],r.push(n.advance);return r}.call(this),A=this.widths[this.widths.length-1],a=[],e=i=0;0<=r?i<r:i>r;e=0<=r?++i:--i)a.push(this.widths.push(A));return a},t.prototype.forGlyph=function(t){return t in this.metrics?this.metrics[t]:{advance:this.metrics[this.metrics.length-1].advance,lsb:this.leftSideBearings[t-this.metrics.length]}},t}(),wo=[].slice,Bo=function(){function t(){return t.__super__.constructor.apply(this,arguments)}return ao(t,ro),t.prototype.tag="glyf",t.prototype.parse=function(){return this.cache={}},t.prototype.glyphFor=function(t){var e,A,r,n,i,s,a,o,l,c;return t in this.cache?this.cache[t]:(n=this.file.loca,e=this.file.contents,A=n.indexOf(t),0===(r=n.lengthOf(t))?this.cache[t]=null:(e.pos=this.offset+A,i=(s=new no(e.read(r))).readShort(),o=s.readShort(),c=s.readShort(),a=s.readShort(),l=s.readShort(),this.cache[t]=-1===i?new yo(s,o,c,a,l):new bo(s,i,o,c,a,l),this.cache[t]))},t.prototype.encode=function(t,e,A){var r,n,i,s,a;for(i=[],n=[],s=0,a=e.length;s<a;s++)r=t[e[s]],n.push(i.length),r&&(i=i.concat(r.encode(A)));return n.push(i.length),{table:i,offsets:n}},t}(),bo=function(){function t(t,e,A,r,n,i){this.raw=t,this.numberOfContours=e,this.xMin=A,this.yMin=r,this.xMax=n,this.yMax=i,this.compound=!1}return t.prototype.encode=function(){return this.raw.data},t}(),yo=function(){function t(t,e,A,r,n){var i,s;for(this.raw=t,this.xMin=e,this.yMin=A,this.xMax=r,this.yMax=n,this.compound=!0,this.glyphIDs=[],this.glyphOffsets=[],i=this.raw;s=i.readShort(),this.glyphOffsets.push(i.pos),this.glyphIDs.push(i.readUInt16()),32&s;)i.pos+=1&s?4:2,128&s?i.pos+=8:64&s?i.pos+=4:8&s&&(i.pos+=2)}return t.prototype.encode=function(){var t,e,A;for(e=new no(wo.call(this.raw.data)),t=0,A=this.glyphIDs.length;t<A;++t)e.pos=this.glyphOffsets[t];return e.data},t}(),Co=function(){function t(){return t.__super__.constructor.apply(this,arguments)}return ao(t,ro),t.prototype.tag="loca",t.prototype.parse=function(t){var e,A;return t.pos=this.offset,e=this.file.head.indexToLocFormat,this.offsets=0===e?function(){var e,r;for(r=[],A=0,e=this.length;A<e;A+=2)r.push(2*t.readUInt16());return r}.call(this):function(){var e,r;for(r=[],A=0,e=this.length;A<e;A+=4)r.push(t.readUInt32());return r}.call(this)},t.prototype.indexOf=function(t){return this.offsets[t]},t.prototype.lengthOf=function(t){return this.offsets[t+1]-this.offsets[t]},t.prototype.encode=function(t,e){for(var A=new Uint32Array(this.offsets.length),r=0,n=0,i=0;i<A.length;++i)if(A[i]=r,n<e.length&&e[n]==i){++n,A[i]=r;var s=this.offsets[i],a=this.offsets[i+1]-s;a>0&&(r+=a)}for(var o=new Array(4*A.length),l=0;l<A.length;++l)o[4*l+3]=255&A[l],o[4*l+2]=(65280&A[l])>>8,o[4*l+1]=(16711680&A[l])>>16,o[4*l]=(4278190080&A[l])>>24;return o},t}(),xo=function(){function t(t){this.font=t,this.subset={},this.unicodes={},this.next=33}return t.prototype.generateCmap=function(){var t,e,A,r,n;for(e in r=this.font.cmap.tables[0].codeMap,t={},n=this.subset)A=n[e],t[e]=r[A];return t},t.prototype.glyphsFor=function(t){var e,A,r,n,i,s,a;for(r={},i=0,s=t.length;i<s;i++)r[n=t[i]]=this.font.glyf.glyphFor(n);for(n in e=[],r)(null!=(A=r[n])?A.compound:void 0)&&e.push.apply(e,A.glyphIDs);if(e.length>0)for(n in a=this.glyphsFor(e))A=a[n],r[n]=A;return r},t.prototype.encode=function(t,e){var A,r,n,i,s,a,o,l,c,u,h,d,f,p,g;for(r in A=co.encode(this.generateCmap(),"unicode"),i=this.glyphsFor(t),h={0:0},g=A.charMap)h[(a=g[r]).old]=a.new;for(d in u=A.maxGlyphID,i)d in h||(h[d]=u++);return l=function(t){var e,A;for(e in A={},t)A[t[e]]=e;return A}(h),c=Object.keys(l).sort(function(t,e){return t-e}),f=function(){var t,e,A;for(A=[],t=0,e=c.length;t<e;t++)s=c[t],A.push(l[s]);return A}(),n=this.font.glyf.encode(i,f,h),o=this.font.loca.encode(n.offsets,f),p={cmap:this.font.cmap.raw(),glyf:n.table,loca:o,hmtx:this.font.hmtx.raw(),hhea:this.font.hhea.raw(),maxp:this.font.maxp.raw(),post:this.font.post.raw(),name:this.font.name.raw(),head:this.font.head.encode(e)},this.font.os2.exists&&(p["OS/2"]=this.font.os2.raw()),this.font.directory.encode(p)},t}();Ls.API.PDFObject=function(){var t;function e(){}return t=function(t,e){return(Array(e+1).join("0")+t).slice(-e)},e.convert=function(A){var r,n,i,s;if(Array.isArray(A))return"["+function(){var t,n,i;for(i=[],t=0,n=A.length;t<n;t++)r=A[t],i.push(e.convert(r));return i}().join(" ")+"]";if("string"==typeof A)return"/"+A;if(null!=A?A.isString:void 0)return"("+A+")";if(A instanceof Date)return"(D:"+t(A.getUTCFullYear(),4)+t(A.getUTCMonth(),2)+t(A.getUTCDate(),2)+t(A.getUTCHours(),2)+t(A.getUTCMinutes(),2)+t(A.getUTCSeconds(),2)+"Z)";if("[object Object]"==={}.toString.call(A)){for(n in i=["<<"],A)s=A[n],i.push("/"+n+" "+e.convert(s));return i.push(">>"),i.join("\n")}return""+A},e}();const Fo=t=>tt(void 0,void 0,void 0,function*(){return new Promise((e,A)=>tt(void 0,void 0,void 0,function*(){var r;let n=null,i=null;try{console.log("[PDF Generator] Generating PDF with options:",{formTitle:t.formTitle,userName:t.userName,componentCount:(null===(r=t.components)||void 0===r?void 0:r.length)||0}),t.components&&t.components.length>0&&console.log("[PDF Generator] Sample components (first 3):",t.components.slice(0,3).map(t=>{var e,A,r,n;return{name:t.name,label:null===(e=t.basic)||void 0===e?void 0:e.label,value:null===(A=t.basic)||void 0===A?void 0:A.value,defaultValue:null===(r=t.basic)||void 0===r?void 0:r.defaultValue,hasValue:void 0!==(null===(n=t.basic)||void 0===n?void 0:n.value)}})),n=document.createElement("div"),n.style.position="absolute",n.style.top="-9999px",n.style.left="-9999px",n.style.width="794px",n.style.backgroundColor="#ffffff",n.style.zIndex="-1000",document.body.appendChild(n),i=zt(n),i.render(X.jsx(Vt,{formTitle:t.formTitle,formDescription:t.formDescription,userName:t.userName,components:t.components})),yield new Promise(t=>setTimeout(t,1e3));const A=yield Yt(n,{scale:2,useCORS:!0,logging:!1,backgroundColor:"#ffffff",windowWidth:794}),s=A.toDataURL("image/jpeg",.95),a=new Ls({orientation:"portrait",unit:"mm",format:"a4"}),o=210,l=297,c=A.height*o/A.width;let u=c,h=0;for(a.addImage(s,"JPEG",0,h,o,c),u-=l;u>0;)h-=l,a.addPage(),a.addImage(s,"JPEG",0,h,o,c),u-=l;const d=a.output("blob");e(d)}catch(t){console.error("Error generating PDF:",t),A(t)}finally{i&&setTimeout(()=>{i.unmount(),n&&n.parentNode&&n.parentNode.removeChild(n)},100)}}))});var Qo;!function(t){t.Top="top",t.Left="left"}(Qo||(Qo={}));
307
+ function(t){t.__bidiEngine__=t.prototype.__bidiEngine__=function(t){var A,r,n,i,s,a,o,l=e,c=[[0,3,0,1,0,0,0],[0,3,0,1,2,2,0],[0,3,0,17,2,0,1],[0,3,5,5,4,1,0],[0,3,21,21,4,0,1],[0,3,5,5,4,2,0]],u=[[2,0,1,1,0,1,0],[2,0,1,1,0,2,0],[2,0,2,1,3,2,0],[2,0,2,33,3,1,1]],h={L:0,R:1,EN:2,AN:3,N:4,B:5,S:6},d={0:0,5:1,6:2,7:3,32:4,251:5,254:6,255:7},f=["(",")","(","<",">","<","[","]","[","{","}","{","«","»","«","‹","›","‹","⁅","⁆","⁅","⁽","⁾","⁽","₍","₎","₍","≤","≥","≤","〈","〉","〈","﹙","﹚","﹙","﹛","﹜","﹛","﹝","﹞","﹝","﹤","﹥","﹤"],p=new RegExp(/^([1-4|9]|1[0-9]|2[0-9]|3[0168]|4[04589]|5[012]|7[78]|159|16[0-9]|17[0-2]|21[569]|22[03489]|250)$/),g=!1,m=0;this.__bidiEngine__={};var v=function(t){var e=t.charCodeAt(),A=e>>8,r=d[A];return void 0!==r?l[256*r+(255&e)]:252===A||253===A?"AL":p.test(A)?"L":8===A?"R":"N"},w=function(t){for(var e,A=0;A<t.length;A++){if("L"===(e=v(t.charAt(A))))return!1;if("R"===e)return!0}return!1},B=function(t,e,s,a){var o,l,c,u,h=e[a];switch(h){case"L":case"R":case"LRE":case"RLE":case"LRO":case"RLO":case"PDF":g=!1;break;case"N":case"AN":break;case"EN":g&&(h="AN");break;case"AL":g=!0,h="R";break;case"WS":case"BN":h="N";break;case"CS":a<1||a+1>=e.length||"EN"!==(o=s[a-1])&&"AN"!==o||"EN"!==(l=e[a+1])&&"AN"!==l?h="N":g&&(l="AN"),h=l===o?l:"N";break;case"ES":h="EN"===(o=a>0?s[a-1]:"B")&&a+1<e.length&&"EN"===e[a+1]?"EN":"N";break;case"ET":if(a>0&&"EN"===s[a-1]){h="EN";break}if(g){h="N";break}for(c=a+1,u=e.length;c<u&&"ET"===e[c];)c++;h=c<u&&"EN"===e[c]?"EN":"N";break;case"NSM":if(n&&!i){for(u=e.length,c=a+1;c<u&&"NSM"===e[c];)c++;if(c<u){var d=t[a],f=d>=1425&&d<=2303||64286===d;if(o=e[c],f&&("R"===o||"AL"===o)){h="R";break}}}h=a<1||"B"===(o=e[a-1])?"N":s[a-1];break;case"B":g=!1,A=!0,h=m;break;case"S":r=!0,h="N"}return h},b=function(t,e,A){var r=t.split("");return A&&y(r,A,{hiLevel:m}),r.reverse(),e&&e.reverse(),r.join("")},y=function(t,e,n){var i,s,a,o,l,d=-1,f=t.length,p=0,w=[],b=m?u:c,y=[];for(g=!1,A=!1,r=!1,s=0;s<f;s++)y[s]=v(t[s]);for(a=0;a<f;a++){if(l=p,w[a]=B(t,y,w,a),i=240&(p=b[l][h[w[a]]]),p&=15,e[a]=o=b[p][5],i>0)if(16===i){for(s=d;s<a;s++)e[s]=1;d=-1}else d=-1;if(b[p][6])-1===d&&(d=a);else if(d>-1){for(s=d;s<a;s++)e[s]=o;d=-1}"B"===y[a]&&(e[a]=0),n.hiLevel|=o}r&&function(t,e,A){for(var r=0;r<A;r++)if("S"===t[r]){e[r]=m;for(var n=r-1;n>=0&&"WS"===t[n];n--)e[n]=m}}(y,e,f)},C=function(t,e,r,n,i){if(!(i.hiLevel<t)){if(1===t&&1===m&&!A)return e.reverse(),void(r&&r.reverse());for(var s,a,o,l,c=e.length,u=0;u<c;){if(n[u]>=t){for(o=u+1;o<c&&n[o]>=t;)o++;for(l=u,a=o-1;l<a;l++,a--)s=e[l],e[l]=e[a],e[a]=s,r&&(s=r[l],r[l]=r[a],r[a]=s);u=o}u++}}},x=function(t,e,A){var r=t.split(""),n={hiLevel:m};return A||(A=[]),y(r,A,n),function(t,e,A){if(0!==A.hiLevel&&o)for(var r,n=0;n<t.length;n++)1===e[n]&&(r=f.indexOf(t[n]))>=0&&(t[n]=f[r+1])}(r,A,n),C(2,r,e,A,n),C(1,r,e,A,n),r.join("")};return this.__bidiEngine__.doBidiReorder=function(t,e,A){if(function(t,e){if(e)for(var A=0;A<t.length;A++)e[A]=A;void 0===i&&(i=w(t)),void 0===a&&(a=w(t))}(t,e),n||!s||a)if(n&&s&&i^a)m=i?1:0,t=b(t,e,A);else if(!n&&s&&a)m=i?1:0,t=x(t,e,A),t=b(t,e);else if(!n||i||s||a){if(n&&!s&&i^a)t=b(t,e),i?(m=0,t=x(t,e,A)):(m=1,t=x(t,e,A),t=b(t,e));else if(n&&i&&!s&&a)m=1,t=x(t,e,A),t=b(t,e);else if(!n&&!s&&i^a){var r=o;i?(m=1,t=x(t,e,A),m=0,o=!1,t=x(t,e,A),o=r):(m=0,t=x(t,e,A),t=b(t,e),m=1,o=!1,t=x(t,e,A),o=r,t=b(t,e))}}else m=0,t=x(t,e,A);else m=i?1:0,t=x(t,e,A);return t},this.__bidiEngine__.setOptions=function(t){t&&(n=t.isInputVisual,s=t.isOutputVisual,i=t.isInputRtl,a=t.isOutputRtl,o=t.isSymmetricSwapping)},this.__bidiEngine__.setOptions(t),this.__bidiEngine__};var e=["BN","BN","BN","BN","BN","BN","BN","BN","BN","S","B","S","WS","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","B","B","B","S","WS","N","N","ET","ET","ET","N","N","N","N","N","ES","CS","ES","CS","CS","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","CS","N","N","N","N","N","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","N","N","N","N","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","N","N","N","BN","BN","BN","BN","BN","BN","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","CS","N","ET","ET","ET","ET","N","N","N","N","L","N","N","BN","N","N","ET","ET","EN","EN","N","L","N","N","N","EN","L","N","N","N","N","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","N","L","L","L","L","L","L","L","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","L","N","N","N","N","N","ET","N","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","R","NSM","R","NSM","NSM","R","NSM","NSM","R","NSM","N","N","N","N","N","N","N","N","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","N","N","N","N","N","R","R","R","R","R","N","N","N","N","N","N","N","N","N","N","N","AN","AN","AN","AN","AN","AN","N","N","AL","ET","ET","AL","CS","AL","N","N","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","AL","AL","N","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","AN","AN","AN","AN","AN","AN","AN","AN","AN","AN","ET","AN","AN","AL","AL","AL","NSM","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","AN","N","NSM","NSM","NSM","NSM","NSM","NSM","AL","AL","NSM","NSM","N","NSM","NSM","NSM","NSM","AL","AL","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","N","AL","AL","NSM","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","N","N","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","AL","N","N","N","N","N","N","N","N","N","N","N","N","N","N","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","R","R","N","N","N","N","R","N","N","N","N","N","WS","WS","WS","WS","WS","WS","WS","WS","WS","WS","WS","BN","BN","BN","L","R","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","WS","B","LRE","RLE","PDF","LRO","RLO","CS","ET","ET","ET","ET","ET","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","CS","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","WS","BN","BN","BN","BN","BN","N","LRI","RLI","FSI","PDI","BN","BN","BN","BN","BN","BN","EN","L","N","N","EN","EN","EN","EN","EN","EN","ES","ES","N","N","N","L","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","ES","ES","N","N","N","N","L","L","L","L","L","L","L","L","L","L","L","L","L","N","N","N","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","L","L","L","L","L","L","L","N","N","N","N","N","N","N","N","N","N","N","N","L","L","L","L","L","N","N","N","N","N","R","NSM","R","R","R","R","R","R","R","R","R","R","ES","R","R","R","R","R","R","R","R","R","R","R","R","R","N","R","R","R","R","R","N","R","N","R","R","N","R","R","N","R","R","R","R","R","R","R","R","R","R","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","CS","N","CS","N","N","CS","N","N","N","N","N","N","N","N","N","ET","N","N","ES","ES","N","N","N","N","N","ET","ET","N","N","N","N","N","AL","AL","AL","AL","AL","N","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","N","N","BN","N","N","N","ET","ET","ET","N","N","N","N","N","ES","CS","ES","CS","CS","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","CS","N","N","N","N","N","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","N","N","N","N","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","N","N","N","N","N","N","N","N","N","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","N","N","L","L","L","L","L","L","N","N","L","L","L","L","L","L","N","N","L","L","L","L","L","L","N","N","L","L","L","N","N","N","ET","ET","N","N","N","ET","ET","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N"],A=new t.__bidiEngine__({isInputVisual:!0});t.API.events.push(["postProcessText",function(t){var e=t.text;t.x,t.y;var r=t.options||{};t.mutex,r.lang;var n=[];if(r.isInputVisual="boolean"!=typeof r.isInputVisual||r.isInputVisual,A.setOptions(r),"[object Array]"===Object.prototype.toString.call(e)){var i=0;for(n=[],i=0;i<e.length;i+=1)"[object Array]"===Object.prototype.toString.call(e[i])?n.push([A.doBidiReorder(e[i][0]),e[i][1],e[i][2]]):n.push([A.doBidiReorder(e[i])]);t.text=n}else t.text=A.doBidiReorder(e);A.setOptions({isInputVisual:!0})}])}(Ls),Ls.API.TTFFont=function(){function t(t){var e;if(this.rawData=t,e=this.contents=new no(t),this.contents.pos=4,"ttcf"===e.readString(4))throw new Error("TTCF not supported.");e.pos=0,this.parse(),this.subset=new xo(this),this.registerTTF()}return t.open=function(e){return new t(e)},t.prototype.parse=function(){return this.directory=new io(this.contents),this.head=new oo(this),this.name=new go(this),this.cmap=new co(this),this.toUnicode={},this.hhea=new uo(this),this.maxp=new mo(this),this.hmtx=new vo(this),this.post=new fo(this),this.os2=new ho(this),this.loca=new Co(this),this.glyf=new Bo(this),this.ascender=this.os2.exists&&this.os2.ascender||this.hhea.ascender,this.decender=this.os2.exists&&this.os2.decender||this.hhea.decender,this.lineGap=this.os2.exists&&this.os2.lineGap||this.hhea.lineGap,this.bbox=[this.head.xMin,this.head.yMin,this.head.xMax,this.head.yMax]},t.prototype.registerTTF=function(){var t,e,A,r,n;if(this.scaleFactor=1e3/this.head.unitsPerEm,this.bbox=function(){var e,A,r,n;for(n=[],e=0,A=(r=this.bbox).length;e<A;e++)t=r[e],n.push(Math.round(t*this.scaleFactor));return n}.call(this),this.stemV=0,this.post.exists?(A=255&(r=this.post.italic_angle),32768&(e=r>>16)&&(e=-(1+(65535^e))),this.italicAngle=+(e+"."+A)):this.italicAngle=0,this.ascender=Math.round(this.ascender*this.scaleFactor),this.decender=Math.round(this.decender*this.scaleFactor),this.lineGap=Math.round(this.lineGap*this.scaleFactor),this.capHeight=this.os2.exists&&this.os2.capHeight||this.ascender,this.xHeight=this.os2.exists&&this.os2.xHeight||0,this.familyClass=(this.os2.exists&&this.os2.familyClass||0)>>8,this.isSerif=1===(n=this.familyClass)||2===n||3===n||4===n||5===n||7===n,this.isScript=10===this.familyClass,this.flags=0,this.post.isFixedPitch&&(this.flags|=1),this.isSerif&&(this.flags|=2),this.isScript&&(this.flags|=8),0!==this.italicAngle&&(this.flags|=64),this.flags|=32,!this.cmap.unicode)throw new Error("No unicode cmap for font")},t.prototype.characterToGlyph=function(t){var e;return(null!=(e=this.cmap.unicode)?e.codeMap[t]:void 0)||0},t.prototype.widthOfGlyph=function(t){var e;return e=1e3/this.head.unitsPerEm,this.hmtx.forGlyph(t).advance*e},t.prototype.widthOfString=function(t,e,A){var r,n,i,s;for(i=0,n=0,s=(t=""+t).length;0<=s?n<s:n>s;n=0<=s?++n:--n)r=t.charCodeAt(n),i+=this.widthOfGlyph(this.characterToGlyph(r))+A*(1e3/e)||0;return i*(e/1e3)},t.prototype.lineHeight=function(t,e){var A;return null==e&&(e=!1),A=e?this.lineGap:0,(this.ascender+A-this.decender)/1e3*t},t}();var ro,no=function(){function t(t){this.data=null!=t?t:[],this.pos=0,this.length=this.data.length}return t.prototype.readByte=function(){return this.data[this.pos++]},t.prototype.writeByte=function(t){return this.data[this.pos++]=t},t.prototype.readUInt32=function(){return 16777216*this.readByte()+(this.readByte()<<16)+(this.readByte()<<8)+this.readByte()},t.prototype.writeUInt32=function(t){return this.writeByte(t>>>24&255),this.writeByte(t>>16&255),this.writeByte(t>>8&255),this.writeByte(255&t)},t.prototype.readInt32=function(){var t;return(t=this.readUInt32())>=2147483648?t-4294967296:t},t.prototype.writeInt32=function(t){return t<0&&(t+=4294967296),this.writeUInt32(t)},t.prototype.readUInt16=function(){return this.readByte()<<8|this.readByte()},t.prototype.writeUInt16=function(t){return this.writeByte(t>>8&255),this.writeByte(255&t)},t.prototype.readInt16=function(){var t;return(t=this.readUInt16())>=32768?t-65536:t},t.prototype.writeInt16=function(t){return t<0&&(t+=65536),this.writeUInt16(t)},t.prototype.readString=function(t){var e,A;for(A=[],e=0;0<=t?e<t:e>t;e=0<=t?++e:--e)A[e]=String.fromCharCode(this.readByte());return A.join("")},t.prototype.writeString=function(t){var e,A,r;for(r=[],e=0,A=t.length;0<=A?e<A:e>A;e=0<=A?++e:--e)r.push(this.writeByte(t.charCodeAt(e)));return r},t.prototype.readShort=function(){return this.readInt16()},t.prototype.writeShort=function(t){return this.writeInt16(t)},t.prototype.readLongLong=function(){var t,e,A,r,n,i,s,a;return t=this.readByte(),e=this.readByte(),A=this.readByte(),r=this.readByte(),n=this.readByte(),i=this.readByte(),s=this.readByte(),a=this.readByte(),128&t?-1*(72057594037927940*(255^t)+281474976710656*(255^e)+1099511627776*(255^A)+4294967296*(255^r)+16777216*(255^n)+65536*(255^i)+256*(255^s)+(255^a)+1):72057594037927940*t+281474976710656*e+1099511627776*A+4294967296*r+16777216*n+65536*i+256*s+a},t.prototype.writeLongLong=function(t){var e,A;return e=Math.floor(t/4294967296),A=4294967295&t,this.writeByte(e>>24&255),this.writeByte(e>>16&255),this.writeByte(e>>8&255),this.writeByte(255&e),this.writeByte(A>>24&255),this.writeByte(A>>16&255),this.writeByte(A>>8&255),this.writeByte(255&A)},t.prototype.readInt=function(){return this.readInt32()},t.prototype.writeInt=function(t){return this.writeInt32(t)},t.prototype.read=function(t){var e,A;for(e=[],A=0;0<=t?A<t:A>t;A=0<=t?++A:--A)e.push(this.readByte());return e},t.prototype.write=function(t){var e,A,r,n;for(n=[],A=0,r=t.length;A<r;A++)e=t[A],n.push(this.writeByte(e));return n},t}(),io=function(){var t;function e(t){var e,A,r;for(this.scalarType=t.readInt(),this.tableCount=t.readShort(),this.searchRange=t.readShort(),this.entrySelector=t.readShort(),this.rangeShift=t.readShort(),this.tables={},A=0,r=this.tableCount;0<=r?A<r:A>r;A=0<=r?++A:--A)e={tag:t.readString(4),checksum:t.readInt(),offset:t.readInt(),length:t.readInt()},this.tables[e.tag]=e}return e.prototype.encode=function(e){var A,r,n,i,s,a,o,l,c,u,h,d,f;for(f in h=Object.keys(e).length,a=Math.log(2),c=16*Math.floor(Math.log(h)/a),i=Math.floor(c/a),l=16*h-c,(r=new no).writeInt(this.scalarType),r.writeShort(h),r.writeShort(c),r.writeShort(i),r.writeShort(l),n=16*h,o=r.pos+n,s=null,d=[],e)for(u=e[f],r.writeString(f),r.writeInt(t(u)),r.writeInt(o),r.writeInt(u.length),d=d.concat(u),"head"===f&&(s=o),o+=u.length;o%4;)d.push(0),o++;return r.write(d),A=2981146554-t(r.data),r.pos=s+8,r.writeUInt32(A),r.data},t=function(t){var e,A,r,n;for(t=wo.call(t);t.length%4;)t.push(0);for(r=new no(t),A=0,e=0,n=t.length;e<n;e=e+=4)A+=r.readUInt32();return 4294967295&A},e}(),so={}.hasOwnProperty,ao=function(t,e){for(var A in e)so.call(e,A)&&(t[A]=e[A]);function r(){this.constructor=t}return r.prototype=e.prototype,t.prototype=new r,t.__super__=e.prototype,t};ro=function(){function t(t){var e;this.file=t,e=this.file.directory.tables[this.tag],this.exists=!!e,e&&(this.offset=e.offset,this.length=e.length,this.parse(this.file.contents))}return t.prototype.parse=function(){},t.prototype.encode=function(){},t.prototype.raw=function(){return this.exists?(this.file.contents.pos=this.offset,this.file.contents.read(this.length)):null},t}();var oo=function(){function t(){return t.__super__.constructor.apply(this,arguments)}return ao(t,ro),t.prototype.tag="head",t.prototype.parse=function(t){return t.pos=this.offset,this.version=t.readInt(),this.revision=t.readInt(),this.checkSumAdjustment=t.readInt(),this.magicNumber=t.readInt(),this.flags=t.readShort(),this.unitsPerEm=t.readShort(),this.created=t.readLongLong(),this.modified=t.readLongLong(),this.xMin=t.readShort(),this.yMin=t.readShort(),this.xMax=t.readShort(),this.yMax=t.readShort(),this.macStyle=t.readShort(),this.lowestRecPPEM=t.readShort(),this.fontDirectionHint=t.readShort(),this.indexToLocFormat=t.readShort(),this.glyphDataFormat=t.readShort()},t.prototype.encode=function(t){var e;return(e=new no).writeInt(this.version),e.writeInt(this.revision),e.writeInt(this.checkSumAdjustment),e.writeInt(this.magicNumber),e.writeShort(this.flags),e.writeShort(this.unitsPerEm),e.writeLongLong(this.created),e.writeLongLong(this.modified),e.writeShort(this.xMin),e.writeShort(this.yMin),e.writeShort(this.xMax),e.writeShort(this.yMax),e.writeShort(this.macStyle),e.writeShort(this.lowestRecPPEM),e.writeShort(this.fontDirectionHint),e.writeShort(t),e.writeShort(this.glyphDataFormat),e.data},t}(),lo=function(){function t(t,e){var A,r,n,i,s,a,o,l,c,u,h,d,f,p,g,m,v;switch(this.platformID=t.readUInt16(),this.encodingID=t.readShort(),this.offset=e+t.readInt(),c=t.pos,t.pos=this.offset,this.format=t.readUInt16(),this.length=t.readUInt16(),this.language=t.readUInt16(),this.isUnicode=3===this.platformID&&1===this.encodingID&&4===this.format||0===this.platformID&&4===this.format,this.codeMap={},this.format){case 0:for(a=0;a<256;++a)this.codeMap[a]=t.readByte();break;case 4:for(h=t.readUInt16(),u=h/2,t.pos+=6,n=function(){var e,A;for(A=[],a=e=0;0<=u?e<u:e>u;a=0<=u?++e:--e)A.push(t.readUInt16());return A}(),t.pos+=2,f=function(){var e,A;for(A=[],a=e=0;0<=u?e<u:e>u;a=0<=u?++e:--e)A.push(t.readUInt16());return A}(),o=function(){var e,A;for(A=[],a=e=0;0<=u?e<u:e>u;a=0<=u?++e:--e)A.push(t.readUInt16());return A}(),l=function(){var e,A;for(A=[],a=e=0;0<=u?e<u:e>u;a=0<=u?++e:--e)A.push(t.readUInt16());return A}(),r=(this.length-t.pos+this.offset)/2,s=function(){var e,A;for(A=[],a=e=0;0<=r?e<r:e>r;a=0<=r?++e:--e)A.push(t.readUInt16());return A}(),a=g=0,v=n.length;g<v;a=++g)for(p=n[a],A=m=d=f[a];d<=p?m<=p:m>=p;A=d<=p?++m:--m)0===l[a]?i=A+o[a]:0!==(i=s[l[a]/2+(A-d)-(u-a)]||0)&&(i+=o[a]),this.codeMap[A]=65535&i}t.pos=c}return t.encode=function(t,e){var A,r,n,i,s,a,o,l,c,u,h,d,f,p,g,m,v,w,B,b,y,C,x,F,Q,U,E,N,S,L,I,_,O,k,T,j,H,P,D,M,R,K,V,z,G,q;switch(N=new no,i=Object.keys(t).sort(function(t,e){return t-e}),e){case"macroman":for(f=0,p=function(){var t=[];for(d=0;d<256;++d)t.push(0);return t}(),m={0:0},n={},S=0,O=i.length;S<O;S++)null==m[V=t[r=i[S]]]&&(m[V]=++f),n[r]={old:t[r],new:m[t[r]]},p[r]=m[t[r]];return N.writeUInt16(1),N.writeUInt16(0),N.writeUInt32(12),N.writeUInt16(0),N.writeUInt16(262),N.writeUInt16(0),N.write(p),{charMap:n,subtable:N.data,maxGlyphID:f+1};case"unicode":for(U=[],c=[],v=0,m={},A={},g=o=null,L=0,k=i.length;L<k;L++)null==m[B=t[r=i[L]]]&&(m[B]=++v),A[r]={old:B,new:m[B]},s=m[B]-r,null!=g&&s===o||(g&&c.push(g),U.push(r),o=s),g=r;for(g&&c.push(g),c.push(65535),U.push(65535),F=2*(x=U.length),C=2*Math.pow(Math.log(x)/Math.LN2,2),u=Math.log(C/2)/Math.LN2,y=2*x-C,a=[],b=[],h=[],d=I=0,T=U.length;I<T;d=++I){if(Q=U[d],l=c[d],65535===Q){a.push(0),b.push(0);break}if(Q-(E=A[Q].new)>=32768)for(a.push(0),b.push(2*(h.length+x-d)),r=_=Q;Q<=l?_<=l:_>=l;r=Q<=l?++_:--_)h.push(A[r].new);else a.push(E-Q),b.push(0)}for(N.writeUInt16(3),N.writeUInt16(1),N.writeUInt32(12),N.writeUInt16(4),N.writeUInt16(16+8*x+2*h.length),N.writeUInt16(0),N.writeUInt16(F),N.writeUInt16(C),N.writeUInt16(u),N.writeUInt16(y),R=0,j=c.length;R<j;R++)r=c[R],N.writeUInt16(r);for(N.writeUInt16(0),K=0,H=U.length;K<H;K++)r=U[K],N.writeUInt16(r);for(z=0,P=a.length;z<P;z++)s=a[z],N.writeUInt16(s);for(G=0,D=b.length;G<D;G++)w=b[G],N.writeUInt16(w);for(q=0,M=h.length;q<M;q++)f=h[q],N.writeUInt16(f);return{charMap:A,subtable:N.data,maxGlyphID:v+1}}},t}(),co=function(){function t(){return t.__super__.constructor.apply(this,arguments)}return ao(t,ro),t.prototype.tag="cmap",t.prototype.parse=function(t){var e,A,r;for(t.pos=this.offset,this.version=t.readUInt16(),r=t.readUInt16(),this.tables=[],this.unicode=null,A=0;0<=r?A<r:A>r;A=0<=r?++A:--A)e=new lo(t,this.offset),this.tables.push(e),e.isUnicode&&null==this.unicode&&(this.unicode=e);return!0},t.encode=function(t,e){var A,r;return null==e&&(e="macroman"),A=lo.encode(t,e),(r=new no).writeUInt16(0),r.writeUInt16(1),A.table=r.data.concat(A.subtable),A},t}(),uo=function(){function t(){return t.__super__.constructor.apply(this,arguments)}return ao(t,ro),t.prototype.tag="hhea",t.prototype.parse=function(t){return t.pos=this.offset,this.version=t.readInt(),this.ascender=t.readShort(),this.decender=t.readShort(),this.lineGap=t.readShort(),this.advanceWidthMax=t.readShort(),this.minLeftSideBearing=t.readShort(),this.minRightSideBearing=t.readShort(),this.xMaxExtent=t.readShort(),this.caretSlopeRise=t.readShort(),this.caretSlopeRun=t.readShort(),this.caretOffset=t.readShort(),t.pos+=8,this.metricDataFormat=t.readShort(),this.numberOfMetrics=t.readUInt16()},t}(),ho=function(){function t(){return t.__super__.constructor.apply(this,arguments)}return ao(t,ro),t.prototype.tag="OS/2",t.prototype.parse=function(t){if(t.pos=this.offset,this.version=t.readUInt16(),this.averageCharWidth=t.readShort(),this.weightClass=t.readUInt16(),this.widthClass=t.readUInt16(),this.type=t.readShort(),this.ySubscriptXSize=t.readShort(),this.ySubscriptYSize=t.readShort(),this.ySubscriptXOffset=t.readShort(),this.ySubscriptYOffset=t.readShort(),this.ySuperscriptXSize=t.readShort(),this.ySuperscriptYSize=t.readShort(),this.ySuperscriptXOffset=t.readShort(),this.ySuperscriptYOffset=t.readShort(),this.yStrikeoutSize=t.readShort(),this.yStrikeoutPosition=t.readShort(),this.familyClass=t.readShort(),this.panose=function(){var e,A;for(A=[],e=0;e<10;++e)A.push(t.readByte());return A}(),this.charRange=function(){var e,A;for(A=[],e=0;e<4;++e)A.push(t.readInt());return A}(),this.vendorID=t.readString(4),this.selection=t.readShort(),this.firstCharIndex=t.readShort(),this.lastCharIndex=t.readShort(),this.version>0&&(this.ascent=t.readShort(),this.descent=t.readShort(),this.lineGap=t.readShort(),this.winAscent=t.readShort(),this.winDescent=t.readShort(),this.codePageRange=function(){var e,A;for(A=[],e=0;e<2;e=++e)A.push(t.readInt());return A}(),this.version>1))return this.xHeight=t.readShort(),this.capHeight=t.readShort(),this.defaultChar=t.readShort(),this.breakChar=t.readShort(),this.maxContext=t.readShort()},t}(),fo=function(){function t(){return t.__super__.constructor.apply(this,arguments)}return ao(t,ro),t.prototype.tag="post",t.prototype.parse=function(t){var e,A,r;switch(t.pos=this.offset,this.format=t.readInt(),this.italicAngle=t.readInt(),this.underlinePosition=t.readShort(),this.underlineThickness=t.readShort(),this.isFixedPitch=t.readInt(),this.minMemType42=t.readInt(),this.maxMemType42=t.readInt(),this.minMemType1=t.readInt(),this.maxMemType1=t.readInt(),this.format){case 65536:case 196608:break;case 131072:var n;for(A=t.readUInt16(),this.glyphNameIndex=[],n=0;0<=A?n<A:n>A;n=0<=A?++n:--n)this.glyphNameIndex.push(t.readUInt16());for(this.names=[],r=[];t.pos<this.offset+this.length;)e=t.readByte(),r.push(this.names.push(t.readString(e)));return r;case 151552:return A=t.readUInt16(),this.offsets=t.read(A);case 262144:return this.map=function(){var e,A,r;for(r=[],n=e=0,A=this.file.maxp.numGlyphs;0<=A?e<A:e>A;n=0<=A?++e:--e)r.push(t.readUInt32());return r}.call(this)}},t}(),po=function(t,e){this.raw=t,this.length=t.length,this.platformID=e.platformID,this.encodingID=e.encodingID,this.languageID=e.languageID},go=function(){function t(){return t.__super__.constructor.apply(this,arguments)}return ao(t,ro),t.prototype.tag="name",t.prototype.parse=function(t){var e,A,r,n,i,s,a,o,l,c,u;for(t.pos=this.offset,t.readShort(),e=t.readShort(),s=t.readShort(),A=[],n=0;0<=e?n<e:n>e;n=0<=e?++n:--n)A.push({platformID:t.readShort(),encodingID:t.readShort(),languageID:t.readShort(),nameID:t.readShort(),length:t.readShort(),offset:this.offset+s+t.readShort()});for(a={},n=l=0,c=A.length;l<c;n=++l)r=A[n],t.pos=r.offset,o=t.readString(r.length),i=new po(o,r),null==a[u=r.nameID]&&(a[u]=[]),a[r.nameID].push(i);this.strings=a,this.copyright=a[0],this.fontFamily=a[1],this.fontSubfamily=a[2],this.uniqueSubfamily=a[3],this.fontName=a[4],this.version=a[5];try{this.postscriptName=a[6][0].raw.replace(/[\x00-\x19\x80-\xff]/g,"")}catch(t){this.postscriptName=a[4][0].raw.replace(/[\x00-\x19\x80-\xff]/g,"")}return this.trademark=a[7],this.manufacturer=a[8],this.designer=a[9],this.description=a[10],this.vendorUrl=a[11],this.designerUrl=a[12],this.license=a[13],this.licenseUrl=a[14],this.preferredFamily=a[15],this.preferredSubfamily=a[17],this.compatibleFull=a[18],this.sampleText=a[19]},t}(),mo=function(){function t(){return t.__super__.constructor.apply(this,arguments)}return ao(t,ro),t.prototype.tag="maxp",t.prototype.parse=function(t){return t.pos=this.offset,this.version=t.readInt(),this.numGlyphs=t.readUInt16(),this.maxPoints=t.readUInt16(),this.maxContours=t.readUInt16(),this.maxCompositePoints=t.readUInt16(),this.maxComponentContours=t.readUInt16(),this.maxZones=t.readUInt16(),this.maxTwilightPoints=t.readUInt16(),this.maxStorage=t.readUInt16(),this.maxFunctionDefs=t.readUInt16(),this.maxInstructionDefs=t.readUInt16(),this.maxStackElements=t.readUInt16(),this.maxSizeOfInstructions=t.readUInt16(),this.maxComponentElements=t.readUInt16(),this.maxComponentDepth=t.readUInt16()},t}(),vo=function(){function t(){return t.__super__.constructor.apply(this,arguments)}return ao(t,ro),t.prototype.tag="hmtx",t.prototype.parse=function(t){var e,A,r,n,i,s,a;for(t.pos=this.offset,this.metrics=[],e=0,s=this.file.hhea.numberOfMetrics;0<=s?e<s:e>s;e=0<=s?++e:--e)this.metrics.push({advance:t.readUInt16(),lsb:t.readInt16()});for(r=this.file.maxp.numGlyphs-this.file.hhea.numberOfMetrics,this.leftSideBearings=function(){var A,n;for(n=[],e=A=0;0<=r?A<r:A>r;e=0<=r?++A:--A)n.push(t.readInt16());return n}(),this.widths=function(){var t,e,A,r;for(r=[],t=0,e=(A=this.metrics).length;t<e;t++)n=A[t],r.push(n.advance);return r}.call(this),A=this.widths[this.widths.length-1],a=[],e=i=0;0<=r?i<r:i>r;e=0<=r?++i:--i)a.push(this.widths.push(A));return a},t.prototype.forGlyph=function(t){return t in this.metrics?this.metrics[t]:{advance:this.metrics[this.metrics.length-1].advance,lsb:this.leftSideBearings[t-this.metrics.length]}},t}(),wo=[].slice,Bo=function(){function t(){return t.__super__.constructor.apply(this,arguments)}return ao(t,ro),t.prototype.tag="glyf",t.prototype.parse=function(){return this.cache={}},t.prototype.glyphFor=function(t){var e,A,r,n,i,s,a,o,l,c;return t in this.cache?this.cache[t]:(n=this.file.loca,e=this.file.contents,A=n.indexOf(t),0===(r=n.lengthOf(t))?this.cache[t]=null:(e.pos=this.offset+A,i=(s=new no(e.read(r))).readShort(),o=s.readShort(),c=s.readShort(),a=s.readShort(),l=s.readShort(),this.cache[t]=-1===i?new yo(s,o,c,a,l):new bo(s,i,o,c,a,l),this.cache[t]))},t.prototype.encode=function(t,e,A){var r,n,i,s,a;for(i=[],n=[],s=0,a=e.length;s<a;s++)r=t[e[s]],n.push(i.length),r&&(i=i.concat(r.encode(A)));return n.push(i.length),{table:i,offsets:n}},t}(),bo=function(){function t(t,e,A,r,n,i){this.raw=t,this.numberOfContours=e,this.xMin=A,this.yMin=r,this.xMax=n,this.yMax=i,this.compound=!1}return t.prototype.encode=function(){return this.raw.data},t}(),yo=function(){function t(t,e,A,r,n){var i,s;for(this.raw=t,this.xMin=e,this.yMin=A,this.xMax=r,this.yMax=n,this.compound=!0,this.glyphIDs=[],this.glyphOffsets=[],i=this.raw;s=i.readShort(),this.glyphOffsets.push(i.pos),this.glyphIDs.push(i.readUInt16()),32&s;)i.pos+=1&s?4:2,128&s?i.pos+=8:64&s?i.pos+=4:8&s&&(i.pos+=2)}return t.prototype.encode=function(){var t,e,A;for(e=new no(wo.call(this.raw.data)),t=0,A=this.glyphIDs.length;t<A;++t)e.pos=this.glyphOffsets[t];return e.data},t}(),Co=function(){function t(){return t.__super__.constructor.apply(this,arguments)}return ao(t,ro),t.prototype.tag="loca",t.prototype.parse=function(t){var e,A;return t.pos=this.offset,e=this.file.head.indexToLocFormat,this.offsets=0===e?function(){var e,r;for(r=[],A=0,e=this.length;A<e;A+=2)r.push(2*t.readUInt16());return r}.call(this):function(){var e,r;for(r=[],A=0,e=this.length;A<e;A+=4)r.push(t.readUInt32());return r}.call(this)},t.prototype.indexOf=function(t){return this.offsets[t]},t.prototype.lengthOf=function(t){return this.offsets[t+1]-this.offsets[t]},t.prototype.encode=function(t,e){for(var A=new Uint32Array(this.offsets.length),r=0,n=0,i=0;i<A.length;++i)if(A[i]=r,n<e.length&&e[n]==i){++n,A[i]=r;var s=this.offsets[i],a=this.offsets[i+1]-s;a>0&&(r+=a)}for(var o=new Array(4*A.length),l=0;l<A.length;++l)o[4*l+3]=255&A[l],o[4*l+2]=(65280&A[l])>>8,o[4*l+1]=(16711680&A[l])>>16,o[4*l]=(4278190080&A[l])>>24;return o},t}(),xo=function(){function t(t){this.font=t,this.subset={},this.unicodes={},this.next=33}return t.prototype.generateCmap=function(){var t,e,A,r,n;for(e in r=this.font.cmap.tables[0].codeMap,t={},n=this.subset)A=n[e],t[e]=r[A];return t},t.prototype.glyphsFor=function(t){var e,A,r,n,i,s,a;for(r={},i=0,s=t.length;i<s;i++)r[n=t[i]]=this.font.glyf.glyphFor(n);for(n in e=[],r)(null!=(A=r[n])?A.compound:void 0)&&e.push.apply(e,A.glyphIDs);if(e.length>0)for(n in a=this.glyphsFor(e))A=a[n],r[n]=A;return r},t.prototype.encode=function(t,e){var A,r,n,i,s,a,o,l,c,u,h,d,f,p,g;for(r in A=co.encode(this.generateCmap(),"unicode"),i=this.glyphsFor(t),h={0:0},g=A.charMap)h[(a=g[r]).old]=a.new;for(d in u=A.maxGlyphID,i)d in h||(h[d]=u++);return l=function(t){var e,A;for(e in A={},t)A[t[e]]=e;return A}(h),c=Object.keys(l).sort(function(t,e){return t-e}),f=function(){var t,e,A;for(A=[],t=0,e=c.length;t<e;t++)s=c[t],A.push(l[s]);return A}(),n=this.font.glyf.encode(i,f,h),o=this.font.loca.encode(n.offsets,f),p={cmap:this.font.cmap.raw(),glyf:n.table,loca:o,hmtx:this.font.hmtx.raw(),hhea:this.font.hhea.raw(),maxp:this.font.maxp.raw(),post:this.font.post.raw(),name:this.font.name.raw(),head:this.font.head.encode(e)},this.font.os2.exists&&(p["OS/2"]=this.font.os2.raw()),this.font.directory.encode(p)},t}();Ls.API.PDFObject=function(){var t;function e(){}return t=function(t,e){return(Array(e+1).join("0")+t).slice(-e)},e.convert=function(A){var r,n,i,s;if(Array.isArray(A))return"["+function(){var t,n,i;for(i=[],t=0,n=A.length;t<n;t++)r=A[t],i.push(e.convert(r));return i}().join(" ")+"]";if("string"==typeof A)return"/"+A;if(null!=A?A.isString:void 0)return"("+A+")";if(A instanceof Date)return"(D:"+t(A.getUTCFullYear(),4)+t(A.getUTCMonth(),2)+t(A.getUTCDate(),2)+t(A.getUTCHours(),2)+t(A.getUTCMinutes(),2)+t(A.getUTCSeconds(),2)+"Z)";if("[object Object]"==={}.toString.call(A)){for(n in i=["<<"],A)s=A[n],i.push("/"+n+" "+e.convert(s));return i.push(">>"),i.join("\n")}return""+A},e}();const Fo=t=>tt(void 0,void 0,void 0,function*(){return new Promise((e,A)=>tt(void 0,void 0,void 0,function*(){let r=null,n=null;try{r=document.createElement("div"),r.style.position="absolute",r.style.top="-9999px",r.style.left="-9999px",r.style.width="794px",r.style.backgroundColor="#ffffff",r.style.zIndex="-1000",document.body.appendChild(r),n=zt(r),n.render(X.jsx(Vt,{formTitle:t.formTitle,formDescription:t.formDescription,userName:t.userName,components:t.components})),yield new Promise(t=>setTimeout(t,1e3));const A=yield Yt(r,{scale:2,useCORS:!0,logging:!1,backgroundColor:"#ffffff",windowWidth:794}),i=A.toDataURL("image/jpeg",.95),s=new Ls({orientation:"portrait",unit:"mm",format:"a4"}),a=210,o=297,l=A.height*a/A.width;let c=l,u=0;for(s.addImage(i,"JPEG",0,u,a,l),c-=o;c>0;)u-=o,s.addPage(),s.addImage(i,"JPEG",0,u,a,l),c-=o;const h=s.output("blob");e(h)}catch(t){console.error("Error generating PDF:",t),A(t)}finally{n&&setTimeout(()=>{n.unmount(),r&&r.parentNode&&r.parentNode.removeChild(r)},100)}}))});var Qo;!function(t){t.Top="top",t.Left="left"}(Qo||(Qo={}));
308
308
  /*! @license DOMPurify 3.3.1 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.1/LICENSE */
309
309
  const{entries:Uo,setPrototypeOf:Eo,isFrozen:No,getPrototypeOf:So,getOwnPropertyDescriptor:Lo}=Object;let{freeze:Io,seal:_o,create:Oo}=Object,{apply:ko,construct:To}="undefined"!=typeof Reflect&&Reflect;Io||(Io=function(t){return t}),_o||(_o=function(t){return t}),ko||(ko=function(t,e){for(var A=arguments.length,r=new Array(A>2?A-2:0),n=2;n<A;n++)r[n-2]=arguments[n];return t.apply(e,r)}),To||(To=function(t){for(var e=arguments.length,A=new Array(e>1?e-1:0),r=1;r<e;r++)A[r-1]=arguments[r];return new t(...A)});const jo=$o(Array.prototype.forEach),Ho=$o(Array.prototype.lastIndexOf),Po=$o(Array.prototype.pop),Do=$o(Array.prototype.push),Mo=$o(Array.prototype.splice),Ro=$o(String.prototype.toLowerCase),Ko=$o(String.prototype.toString),Vo=$o(String.prototype.match),zo=$o(String.prototype.replace),Go=$o(String.prototype.indexOf),qo=$o(String.prototype.trim),Wo=$o(Object.prototype.hasOwnProperty),Xo=$o(RegExp.prototype.test),Yo=(Jo=TypeError,function(){for(var t=arguments.length,e=new Array(t),A=0;A<t;A++)e[A]=arguments[A];return To(Jo,e)});var Jo;function $o(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var A=arguments.length,r=new Array(A>1?A-1:0),n=1;n<A;n++)r[n-1]=arguments[n];return ko(t,e,r)}}function Zo(t,e){let A=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Ro;Eo&&Eo(t,null);let r=e.length;for(;r--;){let n=e[r];if("string"==typeof n){const t=A(n);t!==n&&(No(e)||(e[r]=t),n=t)}t[n]=!0}return t}function tl(t){for(let e=0;e<t.length;e++){Wo(t,e)||(t[e]=null)}return t}function el(t){const e=Oo(null);for(const[A,r]of Uo(t)){Wo(t,A)&&(Array.isArray(r)?e[A]=tl(r):r&&"object"==typeof r&&r.constructor===Object?e[A]=el(r):e[A]=r)}return e}function Al(t,e){for(;null!==t;){const A=Lo(t,e);if(A){if(A.get)return $o(A.get);if("function"==typeof A.value)return $o(A.value)}t=So(t)}return function(){return null}}const rl=Io(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),nl=Io(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),il=Io(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),sl=Io(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),al=Io(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),ol=Io(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ll=Io(["#text"]),cl=Io(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),ul=Io(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),hl=Io(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),dl=Io(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),fl=_o(/\{\{[\w\W]*|[\w\W]*\}\}/gm),pl=_o(/<%[\w\W]*|[\w\W]*%>/gm),gl=_o(/\$\{[\w\W]*/gm),ml=_o(/^data-[\-\w.\u00B7-\uFFFF]+$/),vl=_o(/^aria-[\-\w]+$/),wl=_o(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Bl=_o(/^(?:\w+script|data):/i),bl=_o(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),yl=_o(/^html$/i),Cl=_o(/^[a-z][.\w]*(-[.\w]+)+$/i);var xl=Object.freeze({__proto__:null,ARIA_ATTR:vl,ATTR_WHITESPACE:bl,CUSTOM_ELEMENT:Cl,DATA_ATTR:ml,DOCTYPE_NAME:yl,ERB_EXPR:pl,IS_ALLOWED_URI:wl,IS_SCRIPT_OR_DATA:Bl,MUSTACHE_EXPR:fl,TMPLIT_EXPR:gl});const Fl=1,Ql=3,Ul=7,El=8,Nl=9,Sl=function(){return"undefined"==typeof window?null:window};var Ll=function t(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Sl();const A=e=>t(e);if(A.version="3.3.1",A.removed=[],!e||!e.document||e.document.nodeType!==Nl||!e.Element)return A.isSupported=!1,A;let{document:r}=e;const n=r,i=n.currentScript,{DocumentFragment:s,HTMLTemplateElement:a,Node:o,Element:l,NodeFilter:c,NamedNodeMap:u=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:h,DOMParser:d,trustedTypes:f}=e,p=l.prototype,g=Al(p,"cloneNode"),m=Al(p,"remove"),v=Al(p,"nextSibling"),w=Al(p,"childNodes"),B=Al(p,"parentNode");if("function"==typeof a){const t=r.createElement("template");t.content&&t.content.ownerDocument&&(r=t.content.ownerDocument)}let b,y="";const{implementation:C,createNodeIterator:x,createDocumentFragment:F,getElementsByTagName:Q}=r,{importNode:U}=n;let E={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};A.isSupported="function"==typeof Uo&&"function"==typeof B&&C&&void 0!==C.createHTMLDocument;const{MUSTACHE_EXPR:N,ERB_EXPR:S,TMPLIT_EXPR:L,DATA_ATTR:I,ARIA_ATTR:_,IS_SCRIPT_OR_DATA:O,ATTR_WHITESPACE:k,CUSTOM_ELEMENT:T}=xl;let{IS_ALLOWED_URI:j}=xl,H=null;const P=Zo({},[...rl,...nl,...il,...al,...ll]);let D=null;const M=Zo({},[...cl,...ul,...hl,...dl]);let R=Object.seal(Oo(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),K=null,V=null;const z=Object.seal(Oo(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let G=!0,q=!0,W=!1,X=!0,Y=!1,J=!0,$=!1,Z=!1,tt=!1,et=!1,At=!1,rt=!1,nt=!0,it=!1,st=!0,at=!1,ot={},lt=null;const ct=Zo({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let ut=null;const ht=Zo({},["audio","video","img","source","image","track"]);let dt=null;const ft=Zo({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),pt="http://www.w3.org/1998/Math/MathML",gt="http://www.w3.org/2000/svg",mt="http://www.w3.org/1999/xhtml";let vt=mt,wt=!1,Bt=null;const bt=Zo({},[pt,gt,mt],Ko);let yt=Zo({},["mi","mo","mn","ms","mtext"]),Ct=Zo({},["annotation-xml"]);const xt=Zo({},["title","style","font","a","script"]);let Ft=null;const Qt=["application/xhtml+xml","text/html"];let Ut=null,Et=null;const Nt=r.createElement("form"),St=function(t){return t instanceof RegExp||t instanceof Function},Lt=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!Et||Et!==t){if(t&&"object"==typeof t||(t={}),t=el(t),Ft=-1===Qt.indexOf(t.PARSER_MEDIA_TYPE)?"text/html":t.PARSER_MEDIA_TYPE,Ut="application/xhtml+xml"===Ft?Ko:Ro,H=Wo(t,"ALLOWED_TAGS")?Zo({},t.ALLOWED_TAGS,Ut):P,D=Wo(t,"ALLOWED_ATTR")?Zo({},t.ALLOWED_ATTR,Ut):M,Bt=Wo(t,"ALLOWED_NAMESPACES")?Zo({},t.ALLOWED_NAMESPACES,Ko):bt,dt=Wo(t,"ADD_URI_SAFE_ATTR")?Zo(el(ft),t.ADD_URI_SAFE_ATTR,Ut):ft,ut=Wo(t,"ADD_DATA_URI_TAGS")?Zo(el(ht),t.ADD_DATA_URI_TAGS,Ut):ht,lt=Wo(t,"FORBID_CONTENTS")?Zo({},t.FORBID_CONTENTS,Ut):ct,K=Wo(t,"FORBID_TAGS")?Zo({},t.FORBID_TAGS,Ut):el({}),V=Wo(t,"FORBID_ATTR")?Zo({},t.FORBID_ATTR,Ut):el({}),ot=!!Wo(t,"USE_PROFILES")&&t.USE_PROFILES,G=!1!==t.ALLOW_ARIA_ATTR,q=!1!==t.ALLOW_DATA_ATTR,W=t.ALLOW_UNKNOWN_PROTOCOLS||!1,X=!1!==t.ALLOW_SELF_CLOSE_IN_ATTR,Y=t.SAFE_FOR_TEMPLATES||!1,J=!1!==t.SAFE_FOR_XML,$=t.WHOLE_DOCUMENT||!1,et=t.RETURN_DOM||!1,At=t.RETURN_DOM_FRAGMENT||!1,rt=t.RETURN_TRUSTED_TYPE||!1,tt=t.FORCE_BODY||!1,nt=!1!==t.SANITIZE_DOM,it=t.SANITIZE_NAMED_PROPS||!1,st=!1!==t.KEEP_CONTENT,at=t.IN_PLACE||!1,j=t.ALLOWED_URI_REGEXP||wl,vt=t.NAMESPACE||mt,yt=t.MATHML_TEXT_INTEGRATION_POINTS||yt,Ct=t.HTML_INTEGRATION_POINTS||Ct,R=t.CUSTOM_ELEMENT_HANDLING||{},t.CUSTOM_ELEMENT_HANDLING&&St(t.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(R.tagNameCheck=t.CUSTOM_ELEMENT_HANDLING.tagNameCheck),t.CUSTOM_ELEMENT_HANDLING&&St(t.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(R.attributeNameCheck=t.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),t.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof t.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(R.allowCustomizedBuiltInElements=t.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Y&&(q=!1),At&&(et=!0),ot&&(H=Zo({},ll),D=[],!0===ot.html&&(Zo(H,rl),Zo(D,cl)),!0===ot.svg&&(Zo(H,nl),Zo(D,ul),Zo(D,dl)),!0===ot.svgFilters&&(Zo(H,il),Zo(D,ul),Zo(D,dl)),!0===ot.mathMl&&(Zo(H,al),Zo(D,hl),Zo(D,dl))),t.ADD_TAGS&&("function"==typeof t.ADD_TAGS?z.tagCheck=t.ADD_TAGS:(H===P&&(H=el(H)),Zo(H,t.ADD_TAGS,Ut))),t.ADD_ATTR&&("function"==typeof t.ADD_ATTR?z.attributeCheck=t.ADD_ATTR:(D===M&&(D=el(D)),Zo(D,t.ADD_ATTR,Ut))),t.ADD_URI_SAFE_ATTR&&Zo(dt,t.ADD_URI_SAFE_ATTR,Ut),t.FORBID_CONTENTS&&(lt===ct&&(lt=el(lt)),Zo(lt,t.FORBID_CONTENTS,Ut)),t.ADD_FORBID_CONTENTS&&(lt===ct&&(lt=el(lt)),Zo(lt,t.ADD_FORBID_CONTENTS,Ut)),st&&(H["#text"]=!0),$&&Zo(H,["html","head","body"]),H.table&&(Zo(H,["tbody"]),delete K.tbody),t.TRUSTED_TYPES_POLICY){if("function"!=typeof t.TRUSTED_TYPES_POLICY.createHTML)throw Yo('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof t.TRUSTED_TYPES_POLICY.createScriptURL)throw Yo('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');b=t.TRUSTED_TYPES_POLICY,y=b.createHTML("")}else void 0===b&&(b=function(t,e){if("object"!=typeof t||"function"!=typeof t.createPolicy)return null;let A=null;const r="data-tt-policy-suffix";e&&e.hasAttribute(r)&&(A=e.getAttribute(r));const n="dompurify"+(A?"#"+A:"");try{return t.createPolicy(n,{createHTML:t=>t,createScriptURL:t=>t})}catch(t){return console.warn("TrustedTypes policy "+n+" could not be created."),null}}(f,i)),null!==b&&"string"==typeof y&&(y=b.createHTML(""));Io&&Io(t),Et=t}},It=Zo({},[...nl,...il,...sl]),_t=Zo({},[...al,...ol]),Ot=function(t){Do(A.removed,{element:t});try{B(t).removeChild(t)}catch(e){m(t)}},kt=function(t,e){try{Do(A.removed,{attribute:e.getAttributeNode(t),from:e})}catch(t){Do(A.removed,{attribute:null,from:e})}if(e.removeAttribute(t),"is"===t)if(et||At)try{Ot(e)}catch(t){}else try{e.setAttribute(t,"")}catch(t){}},Tt=function(t){let e=null,A=null;if(tt)t="<remove></remove>"+t;else{const e=Vo(t,/^[\r\n\t ]+/);A=e&&e[0]}"application/xhtml+xml"===Ft&&vt===mt&&(t='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+t+"</body></html>");const n=b?b.createHTML(t):t;if(vt===mt)try{e=(new d).parseFromString(n,Ft)}catch(t){}if(!e||!e.documentElement){e=C.createDocument(vt,"template",null);try{e.documentElement.innerHTML=wt?y:n}catch(t){}}const i=e.body||e.documentElement;return t&&A&&i.insertBefore(r.createTextNode(A),i.childNodes[0]||null),vt===mt?Q.call(e,$?"html":"body")[0]:$?e.documentElement:i},jt=function(t){return x.call(t.ownerDocument||t,t,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Ht=function(t){return t instanceof h&&("string"!=typeof t.nodeName||"string"!=typeof t.textContent||"function"!=typeof t.removeChild||!(t.attributes instanceof u)||"function"!=typeof t.removeAttribute||"function"!=typeof t.setAttribute||"string"!=typeof t.namespaceURI||"function"!=typeof t.insertBefore||"function"!=typeof t.hasChildNodes)},Pt=function(t){return"function"==typeof o&&t instanceof o};function Dt(t,e,r){jo(t,t=>{t.call(A,e,r,Et)})}const Mt=function(t){let e=null;if(Dt(E.beforeSanitizeElements,t,null),Ht(t))return Ot(t),!0;const r=Ut(t.nodeName);if(Dt(E.uponSanitizeElement,t,{tagName:r,allowedTags:H}),J&&t.hasChildNodes()&&!Pt(t.firstElementChild)&&Xo(/<[/\w!]/g,t.innerHTML)&&Xo(/<[/\w!]/g,t.textContent))return Ot(t),!0;if(t.nodeType===Ul)return Ot(t),!0;if(J&&t.nodeType===El&&Xo(/<[/\w]/g,t.data))return Ot(t),!0;if(!(z.tagCheck instanceof Function&&z.tagCheck(r))&&(!H[r]||K[r])){if(!K[r]&&Kt(r)){if(R.tagNameCheck instanceof RegExp&&Xo(R.tagNameCheck,r))return!1;if(R.tagNameCheck instanceof Function&&R.tagNameCheck(r))return!1}if(st&&!lt[r]){const e=B(t)||t.parentNode,A=w(t)||t.childNodes;if(A&&e){for(let r=A.length-1;r>=0;--r){const n=g(A[r],!0);n.__removalCount=(t.__removalCount||0)+1,e.insertBefore(n,v(t))}}}return Ot(t),!0}return t instanceof l&&!function(t){let e=B(t);e&&e.tagName||(e={namespaceURI:vt,tagName:"template"});const A=Ro(t.tagName),r=Ro(e.tagName);return!!Bt[t.namespaceURI]&&(t.namespaceURI===gt?e.namespaceURI===mt?"svg"===A:e.namespaceURI===pt?"svg"===A&&("annotation-xml"===r||yt[r]):Boolean(It[A]):t.namespaceURI===pt?e.namespaceURI===mt?"math"===A:e.namespaceURI===gt?"math"===A&&Ct[r]:Boolean(_t[A]):t.namespaceURI===mt?!(e.namespaceURI===gt&&!Ct[r])&&!(e.namespaceURI===pt&&!yt[r])&&!_t[A]&&(xt[A]||!It[A]):!("application/xhtml+xml"!==Ft||!Bt[t.namespaceURI]))}(t)?(Ot(t),!0):"noscript"!==r&&"noembed"!==r&&"noframes"!==r||!Xo(/<\/no(script|embed|frames)/i,t.innerHTML)?(Y&&t.nodeType===Ql&&(e=t.textContent,jo([N,S,L],t=>{e=zo(e,t," ")}),t.textContent!==e&&(Do(A.removed,{element:t.cloneNode()}),t.textContent=e)),Dt(E.afterSanitizeElements,t,null),!1):(Ot(t),!0)},Rt=function(t,e,A){if(nt&&("id"===e||"name"===e)&&(A in r||A in Nt))return!1;if(q&&!V[e]&&Xo(I,e));else if(G&&Xo(_,e));else if(z.attributeCheck instanceof Function&&z.attributeCheck(e,t));else if(!D[e]||V[e]){if(!(Kt(t)&&(R.tagNameCheck instanceof RegExp&&Xo(R.tagNameCheck,t)||R.tagNameCheck instanceof Function&&R.tagNameCheck(t))&&(R.attributeNameCheck instanceof RegExp&&Xo(R.attributeNameCheck,e)||R.attributeNameCheck instanceof Function&&R.attributeNameCheck(e,t))||"is"===e&&R.allowCustomizedBuiltInElements&&(R.tagNameCheck instanceof RegExp&&Xo(R.tagNameCheck,A)||R.tagNameCheck instanceof Function&&R.tagNameCheck(A))))return!1}else if(dt[e]);else if(Xo(j,zo(A,k,"")));else if("src"!==e&&"xlink:href"!==e&&"href"!==e||"script"===t||0!==Go(A,"data:")||!ut[t]){if(W&&!Xo(O,zo(A,k,"")));else if(A)return!1}else;return!0},Kt=function(t){return"annotation-xml"!==t&&Vo(t,T)},Vt=function(t){Dt(E.beforeSanitizeAttributes,t,null);const{attributes:e}=t;if(!e||Ht(t))return;const r={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:D,forceKeepAttr:void 0};let n=e.length;for(;n--;){const i=e[n],{name:s,namespaceURI:a,value:o}=i,l=Ut(s),c=o;let u="value"===s?c:qo(c);if(r.attrName=l,r.attrValue=u,r.keepAttr=!0,r.forceKeepAttr=void 0,Dt(E.uponSanitizeAttribute,t,r),u=r.attrValue,!it||"id"!==l&&"name"!==l||(kt(s,t),u="user-content-"+u),J&&Xo(/((--!?|])>)|<\/(style|title|textarea)/i,u)){kt(s,t);continue}if("attributename"===l&&Vo(u,"href")){kt(s,t);continue}if(r.forceKeepAttr)continue;if(!r.keepAttr){kt(s,t);continue}if(!X&&Xo(/\/>/i,u)){kt(s,t);continue}Y&&jo([N,S,L],t=>{u=zo(u,t," ")});const h=Ut(t.nodeName);if(Rt(h,l,u)){if(b&&"object"==typeof f&&"function"==typeof f.getAttributeType)if(a);else switch(f.getAttributeType(h,l)){case"TrustedHTML":u=b.createHTML(u);break;case"TrustedScriptURL":u=b.createScriptURL(u)}if(u!==c)try{a?t.setAttributeNS(a,s,u):t.setAttribute(s,u),Ht(t)?Ot(t):Po(A.removed)}catch(e){kt(s,t)}}else kt(s,t)}Dt(E.afterSanitizeAttributes,t,null)},zt=function t(e){let A=null;const r=jt(e);for(Dt(E.beforeSanitizeShadowDOM,e,null);A=r.nextNode();)Dt(E.uponSanitizeShadowNode,A,null),Mt(A),Vt(A),A.content instanceof s&&t(A.content);Dt(E.afterSanitizeShadowDOM,e,null)};return A.sanitize=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=null,i=null,a=null,l=null;if(wt=!t,wt&&(t="\x3c!--\x3e"),"string"!=typeof t&&!Pt(t)){if("function"!=typeof t.toString)throw Yo("toString is not a function");if("string"!=typeof(t=t.toString()))throw Yo("dirty is not a string, aborting")}if(!A.isSupported)return t;if(Z||Lt(e),A.removed=[],"string"==typeof t&&(at=!1),at){if(t.nodeName){const e=Ut(t.nodeName);if(!H[e]||K[e])throw Yo("root node is forbidden and cannot be sanitized in-place")}}else if(t instanceof o)r=Tt("\x3c!----\x3e"),i=r.ownerDocument.importNode(t,!0),i.nodeType===Fl&&"BODY"===i.nodeName||"HTML"===i.nodeName?r=i:r.appendChild(i);else{if(!et&&!Y&&!$&&-1===t.indexOf("<"))return b&&rt?b.createHTML(t):t;if(r=Tt(t),!r)return et?null:rt?y:""}r&&tt&&Ot(r.firstChild);const c=jt(at?t:r);for(;a=c.nextNode();)Mt(a),Vt(a),a.content instanceof s&&zt(a.content);if(at)return t;if(et){if(At)for(l=F.call(r.ownerDocument);r.firstChild;)l.appendChild(r.firstChild);else l=r;return(D.shadowroot||D.shadowrootmode)&&(l=U.call(n,l,!0)),l}let u=$?r.outerHTML:r.innerHTML;return $&&H["!doctype"]&&r.ownerDocument&&r.ownerDocument.doctype&&r.ownerDocument.doctype.name&&Xo(yl,r.ownerDocument.doctype.name)&&(u="<!DOCTYPE "+r.ownerDocument.doctype.name+">\n"+u),Y&&jo([N,S,L],t=>{u=zo(u,t," ")}),b&&rt?b.createHTML(u):u},A.setConfig=function(){Lt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),Z=!0},A.clearConfig=function(){Et=null,Z=!1},A.isValidAttribute=function(t,e,A){Et||Lt({});const r=Ut(t),n=Ut(e);return Rt(r,n,A)},A.addHook=function(t,e){"function"==typeof e&&Do(E[t],e)},A.removeHook=function(t,e){if(void 0!==e){const A=Ho(E[t],e);return-1===A?void 0:Mo(E[t],A,1)[0]}return Po(E[t])},A.removeHooks=function(t){E[t]=[]},A.removeAllHooks=function(){E={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},A}(),Il=Object.freeze({__proto__:null,default:Ll}),_l=function(t){return t&&t.Math===Math&&t},Ol=_l("object"==typeof globalThis&&globalThis)||_l("object"==typeof window&&window)||_l("object"==typeof self&&self)||_l("object"==typeof R&&R)||_l("object"==typeof R&&R)||function(){return this}()||Function("return this")(),kl={},Tl=function(t){try{return!!t()}catch(t){return!0}},jl=!Tl(function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]}),Hl=!Tl(function(){var t=function(){}.bind();return"function"!=typeof t||t.hasOwnProperty("prototype")}),Pl=Hl,Dl=Function.prototype.call,Ml=Pl?Dl.bind(Dl):function(){return Dl.apply(Dl,arguments)},Rl={},Kl={}.propertyIsEnumerable,Vl=Object.getOwnPropertyDescriptor,zl=Vl&&!Kl.call({1:2},1);Rl.f=zl?function(t){var e=Vl(this,t);return!!e&&e.enumerable}:Kl;var Gl,ql,Wl=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},Xl=Hl,Yl=Function.prototype,Jl=Yl.call,$l=Xl&&Yl.bind.bind(Jl,Jl),Zl=Xl?$l:function(t){return function(){return Jl.apply(t,arguments)}},tc=Zl,ec=tc({}.toString),Ac=tc("".slice),rc=function(t){return Ac(ec(t),8,-1)},nc=Tl,ic=rc,sc=Object,ac=Zl("".split),oc=nc(function(){return!sc("z").propertyIsEnumerable(0)})?function(t){return"String"===ic(t)?ac(t,""):sc(t)}:sc,lc=function(t){return null==t},cc=lc,uc=TypeError,hc=function(t){if(cc(t))throw new uc("Can't call method on "+t);return t},dc=oc,fc=hc,pc=function(t){return dc(fc(t))},gc="object"==typeof document&&document.all,mc=void 0===gc&&void 0!==gc?function(t){return"function"==typeof t||t===gc}:function(t){return"function"==typeof t},vc=mc,wc=function(t){return"object"==typeof t?null!==t:vc(t)},Bc=Ol,bc=mc,yc=function(t,e){return arguments.length<2?(A=Bc[t],bc(A)?A:void 0):Bc[t]&&Bc[t][e];var A},Cc=Zl({}.isPrototypeOf),xc=Ol.navigator,Fc=xc&&xc.userAgent,Qc=Fc?String(Fc):"",Uc=Ol,Ec=Qc,Nc=Uc.process,Sc=Uc.Deno,Lc=Nc&&Nc.versions||Sc&&Sc.version,Ic=Lc&&Lc.v8;Ic&&(ql=(Gl=Ic.split("."))[0]>0&&Gl[0]<4?1:+(Gl[0]+Gl[1])),!ql&&Ec&&(!(Gl=Ec.match(/Edge\/(\d+)/))||Gl[1]>=74)&&(Gl=Ec.match(/Chrome\/(\d+)/))&&(ql=+Gl[1]);var _c=ql,Oc=_c,kc=Tl,Tc=Ol.String,jc=!!Object.getOwnPropertySymbols&&!kc(function(){var t=Symbol("symbol detection");return!Tc(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&Oc&&Oc<41}),Hc=jc&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,Pc=yc,Dc=mc,Mc=Cc,Rc=Object,Kc=Hc?function(t){return"symbol"==typeof t}:function(t){var e=Pc("Symbol");return Dc(e)&&Mc(e.prototype,Rc(t))},Vc=String,zc=function(t){try{return Vc(t)}catch(t){return"Object"}},Gc=mc,qc=zc,Wc=TypeError,Xc=function(t){if(Gc(t))return t;throw new Wc(qc(t)+" is not a function")},Yc=Xc,Jc=lc,$c=function(t,e){var A=t[e];return Jc(A)?void 0:Yc(A)},Zc=Ml,tu=mc,eu=wc,Au=TypeError,ru={exports:{}},nu=Ol,iu=Object.defineProperty,su=function(t,e){try{iu(nu,t,{value:e,configurable:!0,writable:!0})}catch(A){nu[t]=e}return e},au=Ol,ou=su,lu="__core-js_shared__",cu=ru.exports=au[lu]||ou(lu,{});(cu.versions||(cu.versions=[])).push({version:"3.47.0",mode:"global",copyright:"© 2014-2025 Denis Pushkarev (zloirock.ru), 2025 CoreJS Company (core-js.io)",license:"https://github.com/zloirock/core-js/blob/v3.47.0/LICENSE",source:"https://github.com/zloirock/core-js"});var uu=ru.exports,hu=uu,du=function(t,e){return hu[t]||(hu[t]=e||{})},fu=hc,pu=Object,gu=function(t){return pu(fu(t))},mu=gu,vu=Zl({}.hasOwnProperty),wu=Object.hasOwn||function(t,e){return vu(mu(t),e)},Bu=Zl,bu=0,yu=Math.random(),Cu=Bu(1.1.toString),xu=function(t){return"Symbol("+(void 0===t?"":t)+")_"+Cu(++bu+yu,36)},Fu=du,Qu=wu,Uu=xu,Eu=jc,Nu=Hc,Su=Ol.Symbol,Lu=Fu("wks"),Iu=Nu?Su.for||Su:Su&&Su.withoutSetter||Uu,_u=function(t){return Qu(Lu,t)||(Lu[t]=Eu&&Qu(Su,t)?Su[t]:Iu("Symbol."+t)),Lu[t]},Ou=Ml,ku=wc,Tu=Kc,ju=$c,Hu=function(t,e){var A,r;if("string"===e&&tu(A=t.toString)&&!eu(r=Zc(A,t)))return r;if(tu(A=t.valueOf)&&!eu(r=Zc(A,t)))return r;if("string"!==e&&tu(A=t.toString)&&!eu(r=Zc(A,t)))return r;throw new Au("Can't convert object to primitive value")},Pu=TypeError,Du=_u("toPrimitive"),Mu=function(t,e){if(!ku(t)||Tu(t))return t;var A,r=ju(t,Du);if(r){if(void 0===e&&(e="default"),A=Ou(r,t,e),!ku(A)||Tu(A))return A;throw new Pu("Can't convert object to primitive value")}return void 0===e&&(e="number"),Hu(t,e)},Ru=Kc,Ku=function(t){var e=Mu(t,"string");return Ru(e)?e:e+""},Vu=wc,zu=Ol.document,Gu=Vu(zu)&&Vu(zu.createElement),qu=function(t){return Gu?zu.createElement(t):{}},Wu=qu,Xu=!jl&&!Tl(function(){return 7!==Object.defineProperty(Wu("div"),"a",{get:function(){return 7}}).a}),Yu=jl,Ju=Ml,$u=Rl,Zu=Wl,th=pc,eh=Ku,Ah=wu,rh=Xu,nh=Object.getOwnPropertyDescriptor;kl.f=Yu?nh:function(t,e){if(t=th(t),e=eh(e),rh)try{return nh(t,e)}catch(t){}if(Ah(t,e))return Zu(!Ju($u.f,t,e),t[e])};var ih={},sh=jl&&Tl(function(){return 42!==Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype}),ah=wc,oh=String,lh=TypeError,ch=function(t){if(ah(t))return t;throw new lh(oh(t)+" is not an object")},uh=jl,hh=Xu,dh=sh,fh=ch,ph=Ku,gh=TypeError,mh=Object.defineProperty,vh=Object.getOwnPropertyDescriptor,wh="enumerable",Bh="configurable",bh="writable";ih.f=uh?dh?function(t,e,A){if(fh(t),e=ph(e),fh(A),"function"==typeof t&&"prototype"===e&&"value"in A&&bh in A&&!A[bh]){var r=vh(t,e);r&&r[bh]&&(t[e]=A.value,A={configurable:Bh in A?A[Bh]:r[Bh],enumerable:wh in A?A[wh]:r[wh],writable:!1})}return mh(t,e,A)}:mh:function(t,e,A){if(fh(t),e=ph(e),fh(A),hh)try{return mh(t,e,A)}catch(t){}if("get"in A||"set"in A)throw new gh("Accessors not supported");return"value"in A&&(t[e]=A.value),t};var yh=ih,Ch=Wl,xh=jl?function(t,e,A){return yh.f(t,e,Ch(1,A))}:function(t,e,A){return t[e]=A,t},Fh={exports:{}},Qh=jl,Uh=wu,Eh=Function.prototype,Nh=Qh&&Object.getOwnPropertyDescriptor,Sh=Uh(Eh,"name"),Lh={EXISTS:Sh,PROPER:Sh&&"something"===function(){}.name,CONFIGURABLE:Sh&&(!Qh||Qh&&Nh(Eh,"name").configurable)},Ih=mc,_h=uu,Oh=Zl(Function.toString);Ih(_h.inspectSource)||(_h.inspectSource=function(t){return Oh(t)});var kh,Th,jh,Hh=_h.inspectSource,Ph=mc,Dh=Ol.WeakMap,Mh=Ph(Dh)&&/native code/.test(String(Dh)),Rh=xu,Kh=du("keys"),Vh=function(t){return Kh[t]||(Kh[t]=Rh(t))},zh={},Gh=Mh,qh=Ol,Wh=wc,Xh=xh,Yh=wu,Jh=uu,$h=Vh,Zh=zh,td="Object already initialized",ed=qh.TypeError,Ad=qh.WeakMap;if(Gh||Jh.state){var rd=Jh.state||(Jh.state=new Ad);rd.get=rd.get,rd.has=rd.has,rd.set=rd.set,kh=function(t,e){if(rd.has(t))throw new ed(td);return e.facade=t,rd.set(t,e),e},Th=function(t){return rd.get(t)||{}},jh=function(t){return rd.has(t)}}else{var nd=$h("state");Zh[nd]=!0,kh=function(t,e){if(Yh(t,nd))throw new ed(td);return e.facade=t,Xh(t,nd,e),e},Th=function(t){return Yh(t,nd)?t[nd]:{}},jh=function(t){return Yh(t,nd)}}var id={set:kh,get:Th,has:jh,enforce:function(t){return jh(t)?Th(t):kh(t,{})},getterFor:function(t){return function(e){var A;if(!Wh(e)||(A=Th(e)).type!==t)throw new ed("Incompatible receiver, "+t+" required");return A}}},sd=Zl,ad=Tl,od=mc,ld=wu,cd=jl,ud=Lh.CONFIGURABLE,hd=Hh,dd=id.enforce,fd=id.get,pd=String,gd=Object.defineProperty,md=sd("".slice),vd=sd("".replace),wd=sd([].join),Bd=cd&&!ad(function(){return 8!==gd(function(){},"length",{value:8}).length}),bd=String(String).split("String"),yd=Fh.exports=function(t,e,A){"Symbol("===md(pd(e),0,7)&&(e="["+vd(pd(e),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),A&&A.getter&&(e="get "+e),A&&A.setter&&(e="set "+e),(!ld(t,"name")||ud&&t.name!==e)&&(cd?gd(t,"name",{value:e,configurable:!0}):t.name=e),Bd&&A&&ld(A,"arity")&&t.length!==A.arity&&gd(t,"length",{value:A.arity});try{A&&ld(A,"constructor")&&A.constructor?cd&&gd(t,"prototype",{writable:!1}):t.prototype&&(t.prototype=void 0)}catch(t){}var r=dd(t);return ld(r,"source")||(r.source=wd(bd,"string"==typeof e?e:"")),t};Function.prototype.toString=yd(function(){return od(this)&&fd(this).source||hd(this)},"toString");var Cd=Fh.exports,xd=mc,Fd=ih,Qd=Cd,Ud=su,Ed=function(t,e,A,r){r||(r={});var n=r.enumerable,i=void 0!==r.name?r.name:e;if(xd(A)&&Qd(A,i,r),r.global)n?t[e]=A:Ud(e,A);else{try{r.unsafe?t[e]&&(n=!0):delete t[e]}catch(t){}n?t[e]=A:Fd.f(t,e,{value:A,enumerable:!1,configurable:!r.nonConfigurable,writable:!r.nonWritable})}return t},Nd={},Sd=Math.ceil,Ld=Math.floor,Id=Math.trunc||function(t){var e=+t;return(e>0?Ld:Sd)(e)},_d=Id,Od=function(t){var e=+t;return e!=e||0===e?0:_d(e)},kd=Od,Td=Math.max,jd=Math.min,Hd=Od,Pd=Math.min,Dd=function(t){var e=Hd(t);return e>0?Pd(e,9007199254740991):0},Md=Dd,Rd=function(t){return Md(t.length)},Kd=pc,Vd=function(t,e){var A=kd(t);return A<0?Td(A+e,0):jd(A,e)},zd=Rd,Gd=function(t){return function(e,A,r){var n=Kd(e),i=zd(n);if(0===i)return!t&&-1;var s,a=Vd(r,i);if(t&&A!=A){for(;i>a;)if((s=n[a++])!=s)return!0}else for(;i>a;a++)if((t||a in n)&&n[a]===A)return t||a||0;return!t&&-1}},qd={includes:Gd(!0),indexOf:Gd(!1)},Wd=wu,Xd=pc,Yd=qd.indexOf,Jd=zh,$d=Zl([].push),Zd=function(t,e){var A,r=Xd(t),n=0,i=[];for(A in r)!Wd(Jd,A)&&Wd(r,A)&&$d(i,A);for(;e.length>n;)Wd(r,A=e[n++])&&(~Yd(i,A)||$d(i,A));return i},tf=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],ef=Zd,Af=tf.concat("length","prototype");Nd.f=Object.getOwnPropertyNames||function(t){return ef(t,Af)};var rf={};rf.f=Object.getOwnPropertySymbols;var nf=yc,sf=Nd,af=rf,of=ch,lf=Zl([].concat),cf=nf("Reflect","ownKeys")||function(t){var e=sf.f(of(t)),A=af.f;return A?lf(e,A(t)):e},uf=wu,hf=cf,df=kl,ff=ih,pf=Tl,gf=mc,mf=/#|\.prototype\./,vf=function(t,e){var A=Bf[wf(t)];return A===yf||A!==bf&&(gf(e)?pf(e):!!e)},wf=vf.normalize=function(t){return String(t).replace(mf,".").toLowerCase()},Bf=vf.data={},bf=vf.NATIVE="N",yf=vf.POLYFILL="P",Cf=vf,xf=Ol,Ff=kl.f,Qf=xh,Uf=Ed,Ef=su,Nf=function(t,e,A){for(var r=hf(e),n=ff.f,i=df.f,s=0;s<r.length;s++){var a=r[s];uf(t,a)||A&&uf(A,a)||n(t,a,i(e,a))}},Sf=Cf,Lf=function(t,e){var A,r,n,i,s,a=t.target,o=t.global,l=t.stat;if(A=o?xf:l?xf[a]||Ef(a,{}):xf[a]&&xf[a].prototype)for(r in e){if(i=e[r],n=t.dontCallGetSet?(s=Ff(A,r))&&s.value:A[r],!Sf(o?r:a+(l?".":"#")+r,t.forced)&&void 0!==n){if(typeof i==typeof n)continue;Nf(i,n)}(t.sham||n&&n.sham)&&Qf(i,"sham",!0),Uf(A,r,i,t)}},If=Ol,_f=Qc,Of=rc,kf=function(t){return _f.slice(0,t.length)===t},Tf=kf("Bun/")?"BUN":kf("Cloudflare-Workers")?"CLOUDFLARE":kf("Deno/")?"DENO":kf("Node.js/")?"NODE":If.Bun&&"string"==typeof Bun.version?"BUN":If.Deno&&"object"==typeof Deno.version?"DENO":"process"===Of(If.process)?"NODE":If.window&&If.document?"BROWSER":"REST",jf="NODE"===Tf,Hf=Ol,Pf=Zl,Df=Xc,Mf=wc,Rf=function(t){return Mf(t)||null===t},Kf=String,Vf=TypeError,zf=function(t,e,A){try{return Pf(Df(Object.getOwnPropertyDescriptor(t,e)[A]))}catch(t){}},Gf=wc,qf=hc,Wf=function(t){if(Rf(t))return t;throw new Vf("Can't set "+Kf(t)+" as a prototype")},Xf=Object.setPrototypeOf||("__proto__"in{}?function(){var t,e=!1,A={};try{(t=zf(Object.prototype,"__proto__","set"))(A,[]),e=A instanceof Array}catch(t){}return function(A,r){return qf(A),Wf(r),Gf(A)?(e?t(A,r):A.__proto__=r,A):A}}():void 0),Yf=ih.f,Jf=wu,$f=_u("toStringTag"),Zf=function(t,e,A){t&&!A&&(t=t.prototype),t&&!Jf(t,$f)&&Yf(t,$f,{configurable:!0,value:e})},tp=Cd,ep=ih,Ap=yc,rp=function(t,e,A){return A.get&&tp(A.get,e,{getter:!0}),A.set&&tp(A.set,e,{setter:!0}),ep.f(t,e,A)},np=jl,ip=_u("species"),sp=Cc,ap=TypeError,op={};op[_u("toStringTag")]="z";var lp="[object z]"===String(op),cp=mc,up=rc,hp=_u("toStringTag"),dp=Object,fp="Arguments"===up(function(){return arguments}()),pp=lp?up:function(t){var e,A,r;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(A=function(t,e){try{return t[e]}catch(t){}}(e=dp(t),hp))?A:fp?up(e):"Object"===(r=up(e))&&cp(e.callee)?"Arguments":r},gp=Zl,mp=Tl,vp=mc,wp=pp,Bp=Hh,bp=function(){},yp=yc("Reflect","construct"),Cp=/^\s*(?:class|function)\b/,xp=gp(Cp.exec),Fp=!Cp.test(bp),Qp=function(t){if(!vp(t))return!1;try{return yp(bp,[],t),!0}catch(t){return!1}},Up=function(t){if(!vp(t))return!1;switch(wp(t)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Fp||!!xp(Cp,Bp(t))}catch(t){return!0}};Up.sham=!0;var Ep,Np,Sp,Lp,Ip=!yp||mp(function(){var t;return Qp(Qp.call)||!Qp(Object)||!Qp(function(){t=!0})||t})?Up:Qp,_p=Ip,Op=zc,kp=TypeError,Tp=ch,jp=function(t){if(_p(t))return t;throw new kp(Op(t)+" is not a constructor")},Hp=lc,Pp=_u("species"),Dp=function(t,e){var A,r=Tp(t).constructor;return void 0===r||Hp(A=Tp(r)[Pp])?e:jp(A)},Mp=Hl,Rp=Function.prototype,Kp=Rp.apply,Vp=Rp.call,zp="object"==typeof Reflect&&Reflect.apply||(Mp?Vp.bind(Kp):function(){return Vp.apply(Kp,arguments)}),Gp=rc,qp=Zl,Wp=function(t){if("Function"===Gp(t))return qp(t)},Xp=Xc,Yp=Hl,Jp=Wp(Wp.bind),$p=function(t,e){return Xp(t),void 0===e?t:Yp?Jp(t,e):function(){return t.apply(e,arguments)}},Zp=yc("document","documentElement"),tg=Zl([].slice),eg=TypeError,Ag=/(?:ipad|iphone|ipod).*applewebkit/i.test(Qc),rg=Ol,ng=zp,ig=$p,sg=mc,ag=wu,og=Tl,lg=Zp,cg=tg,ug=qu,hg=function(t,e){if(t<e)throw new eg("Not enough arguments");return t},dg=Ag,fg=jf,pg=rg.setImmediate,gg=rg.clearImmediate,mg=rg.process,vg=rg.Dispatch,wg=rg.Function,Bg=rg.MessageChannel,bg=rg.String,yg=0,Cg={},xg="onreadystatechange";og(function(){Ep=rg.location});var Fg=function(t){if(ag(Cg,t)){var e=Cg[t];delete Cg[t],e()}},Qg=function(t){return function(){Fg(t)}},Ug=function(t){Fg(t.data)},Eg=function(t){rg.postMessage(bg(t),Ep.protocol+"//"+Ep.host)};pg&&gg||(pg=function(t){hg(arguments.length,1);var e=sg(t)?t:wg(t),A=cg(arguments,1);return Cg[++yg]=function(){ng(e,void 0,A)},Np(yg),yg},gg=function(t){delete Cg[t]},fg?Np=function(t){mg.nextTick(Qg(t))}:vg&&vg.now?Np=function(t){vg.now(Qg(t))}:Bg&&!dg?(Lp=(Sp=new Bg).port2,Sp.port1.onmessage=Ug,Np=ig(Lp.postMessage,Lp)):rg.addEventListener&&sg(rg.postMessage)&&!rg.importScripts&&Ep&&"file:"!==Ep.protocol&&!og(Eg)?(Np=Eg,rg.addEventListener("message",Ug,!1)):Np=xg in ug("script")?function(t){lg.appendChild(ug("script"))[xg]=function(){lg.removeChild(this),Fg(t)}}:function(t){setTimeout(Qg(t),0)});var Ng={set:pg,clear:gg},Sg=Ol,Lg=jl,Ig=Object.getOwnPropertyDescriptor,_g=function(){this.head=null,this.tail=null};_g.prototype={add:function(t){var e={item:t,next:null},A=this.tail;A?A.next=e:this.head=e,this.tail=e},get:function(){var t=this.head;if(t)return null===(this.head=t.next)&&(this.tail=null),t.item}};var Og,kg,Tg,jg,Hg,Pg=_g,Dg=/ipad|iphone|ipod/i.test(Qc)&&"undefined"!=typeof Pebble,Mg=/web0s(?!.*chrome)/i.test(Qc),Rg=Ol,Kg=function(t){if(!Lg)return Sg[t];var e=Ig(Sg,t);return e&&e.value},Vg=$p,zg=Ng.set,Gg=Pg,qg=Ag,Wg=Dg,Xg=Mg,Yg=jf,Jg=Rg.MutationObserver||Rg.WebKitMutationObserver,$g=Rg.document,Zg=Rg.process,tm=Rg.Promise,em=Kg("queueMicrotask");if(!em){var Am=new Gg,rm=function(){var t,e;for(Yg&&(t=Zg.domain)&&t.exit();e=Am.get();)try{e()}catch(t){throw Am.head&&Og(),t}t&&t.enter()};qg||Yg||Xg||!Jg||!$g?!Wg&&tm&&tm.resolve?((jg=tm.resolve(void 0)).constructor=tm,Hg=Vg(jg.then,jg),Og=function(){Hg(rm)}):Yg?Og=function(){Zg.nextTick(rm)}:(zg=Vg(zg,Rg),Og=function(){zg(rm)}):(kg=!0,Tg=$g.createTextNode(""),new Jg(rm).observe(Tg,{characterData:!0}),Og=function(){Tg.data=kg=!kg}),em=function(t){Am.head||Og(),Am.add(t)}}var nm=em,im=function(t){try{return{error:!1,value:t()}}catch(t){return{error:!0,value:t}}},sm=Ol.Promise,am=Ol,om=sm,lm=mc,cm=Cf,um=Hh,hm=_u,dm=Tf,fm=_c;om&&om.prototype;var pm=hm("species"),gm=!1,mm=lm(am.PromiseRejectionEvent),vm=cm("Promise",function(){var t=um(om),e=t!==String(om);if(!e&&66===fm)return!0;if(!fm||fm<51||!/native code/.test(t)){var A=new om(function(t){t(1)}),r=function(t){t(function(){},function(){})};if((A.constructor={})[pm]=r,!(gm=A.then(function(){})instanceof r))return!0}return!(e||"BROWSER"!==dm&&"DENO"!==dm||mm)}),wm={CONSTRUCTOR:vm,REJECTION_EVENT:mm,SUBCLASSING:gm},Bm={},bm=Xc,ym=TypeError,Cm=function(t){var e,A;this.promise=new t(function(t,r){if(void 0!==e||void 0!==A)throw new ym("Bad Promise constructor");e=t,A=r}),this.resolve=bm(e),this.reject=bm(A)};Bm.f=function(t){return new Cm(t)};var xm,Fm,Qm,Um,Em=Lf,Nm=jf,Sm=Ol,Lm=Hf,Im=Ml,_m=Ed,Om=Xf,km=Zf,Tm=function(t){var e=Ap(t);np&&e&&!e[ip]&&rp(e,ip,{configurable:!0,get:function(){return this}})},jm=Xc,Hm=mc,Pm=wc,Dm=function(t,e){if(sp(e,t))return t;throw new ap("Incorrect invocation")},Mm=Dp,Rm=Ng.set,Km=nm,Vm=function(t,e){try{1===arguments.length?console.error(t):console.error(t,e)}catch(t){}},zm=im,Gm=Pg,qm=id,Wm=sm,Xm=Bm,Ym="Promise",Jm=wm.CONSTRUCTOR,$m=wm.REJECTION_EVENT,Zm=wm.SUBCLASSING,tv=qm.getterFor(Ym),ev=qm.set,Av=Wm&&Wm.prototype,rv=Wm,nv=Av,iv=Sm.TypeError,sv=Sm.document,av=Sm.process,ov=Xm.f,lv=ov,cv=!!(sv&&sv.createEvent&&Sm.dispatchEvent),uv="unhandledrejection",hv=function(t){var e;return!(!Pm(t)||!Hm(e=t.then))&&e},dv=function(t,e){var A,r,n,i=e.value,s=1===e.state,a=s?t.ok:t.fail,o=t.resolve,l=t.reject,c=t.domain;try{a?(s||(2===e.rejection&&vv(e),e.rejection=1),!0===a?A=i:(c&&c.enter(),A=a(i),c&&(c.exit(),n=!0)),A===t.promise?l(new iv("Promise-chain cycle")):(r=hv(A))?Im(r,A,o,l):o(A)):l(i)}catch(t){c&&!n&&c.exit(),l(t)}},fv=function(t,e){t.notified||(t.notified=!0,Km(function(){for(var A,r=t.reactions;A=r.get();)dv(A,t);t.notified=!1,e&&!t.rejection&&gv(t)}))},pv=function(t,e,A){var r,n;cv?((r=sv.createEvent("Event")).promise=e,r.reason=A,r.initEvent(t,!1,!0),Sm.dispatchEvent(r)):r={promise:e,reason:A},!$m&&(n=Sm["on"+t])?n(r):t===uv&&Vm("Unhandled promise rejection",A)},gv=function(t){Im(Rm,Sm,function(){var e,A=t.facade,r=t.value;if(mv(t)&&(e=zm(function(){Nm?av.emit("unhandledRejection",r,A):pv(uv,A,r)}),t.rejection=Nm||mv(t)?2:1,e.error))throw e.value})},mv=function(t){return 1!==t.rejection&&!t.parent},vv=function(t){Im(Rm,Sm,function(){var e=t.facade;Nm?av.emit("rejectionHandled",e):pv("rejectionhandled",e,t.value)})},wv=function(t,e,A){return function(r){t(e,r,A)}},Bv=function(t,e,A){t.done||(t.done=!0,A&&(t=A),t.value=e,t.state=2,fv(t,!0))},bv=function(t,e,A){if(!t.done){t.done=!0,A&&(t=A);try{if(t.facade===e)throw new iv("Promise can't be resolved itself");var r=hv(e);r?Km(function(){var A={done:!1};try{Im(r,e,wv(bv,A,t),wv(Bv,A,t))}catch(e){Bv(A,e,t)}}):(t.value=e,t.state=1,fv(t,!1))}catch(e){Bv({done:!1},e,t)}}};if(Jm&&(nv=(rv=function(t){Dm(this,nv),jm(t),Im(xm,this);var e=tv(this);try{t(wv(bv,e),wv(Bv,e))}catch(t){Bv(e,t)}}).prototype,(xm=function(t){ev(this,{type:Ym,done:!1,notified:!1,parent:!1,reactions:new Gm,rejection:!1,state:0,value:null})}).prototype=_m(nv,"then",function(t,e){var A=tv(this),r=ov(Mm(this,rv));return A.parent=!0,r.ok=!Hm(t)||t,r.fail=Hm(e)&&e,r.domain=Nm?av.domain:void 0,0===A.state?A.reactions.add(r):Km(function(){dv(r,A)}),r.promise}),Fm=function(){var t=new xm,e=tv(t);this.promise=t,this.resolve=wv(bv,e),this.reject=wv(Bv,e)},Xm.f=ov=function(t){return t===rv||t===Qm?new Fm(t):lv(t)},Hm(Wm)&&Av!==Object.prototype)){Um=Av.then,Zm||_m(Av,"then",function(t,e){var A=this;return new rv(function(t,e){Im(Um,A,t,e)}).then(t,e)},{unsafe:!0});try{delete Av.constructor}catch(t){}Om&&Om(Av,nv)}Em({global:!0,constructor:!0,wrap:!0,forced:Jm},{Promise:rv}),Qm=Lm.Promise,km(rv,Ym,!1),Tm(Ym);var yv={},Cv=yv,xv=_u("iterator"),Fv=Array.prototype,Qv=pp,Uv=$c,Ev=lc,Nv=yv,Sv=_u("iterator"),Lv=function(t){if(!Ev(t))return Uv(t,Sv)||Uv(t,"@@iterator")||Nv[Qv(t)]},Iv=Ml,_v=Xc,Ov=ch,kv=zc,Tv=Lv,jv=TypeError,Hv=Ml,Pv=ch,Dv=$c,Mv=$p,Rv=Ml,Kv=ch,Vv=zc,zv=function(t){return void 0!==t&&(Cv.Array===t||Fv[xv]===t)},Gv=Rd,qv=Cc,Wv=function(t,e){var A=arguments.length<2?Tv(t):e;if(_v(A))return Ov(Iv(A,t));throw new jv(kv(t)+" is not iterable")},Xv=Lv,Yv=function(t,e,A){var r,n;Pv(t);try{if(!(r=Dv(t,"return"))){if("throw"===e)throw A;return A}r=Hv(r,t)}catch(t){n=!0,r=t}if("throw"===e)throw A;if(n)throw r;return Pv(r),A},Jv=TypeError,$v=function(t,e){this.stopped=t,this.result=e},Zv=$v.prototype,tw=function(t,e,A){var r,n,i,s,a,o,l,c=A&&A.that,u=!(!A||!A.AS_ENTRIES),h=!(!A||!A.IS_RECORD),d=!(!A||!A.IS_ITERATOR),f=!(!A||!A.INTERRUPTED),p=Mv(e,c),g=function(t){return r&&Yv(r,"normal"),new $v(!0,t)},m=function(t){return u?(Kv(t),f?p(t[0],t[1],g):p(t[0],t[1])):f?p(t,g):p(t)};if(h)r=t.iterator;else if(d)r=t;else{if(!(n=Xv(t)))throw new Jv(Vv(t)+" is not iterable");if(zv(n)){for(i=0,s=Gv(t);s>i;i++)if((a=m(t[i]))&&qv(Zv,a))return a;return new $v(!1)}r=Wv(t,n)}for(o=h?t.next:r.next;!(l=Rv(o,r)).done;){try{a=m(l.value)}catch(t){Yv(r,"throw",t)}if("object"==typeof a&&a&&qv(Zv,a))return a}return new $v(!1)},ew=_u("iterator"),Aw=!1;try{var rw=0,nw={next:function(){return{done:!!rw++}},return:function(){Aw=!0}};nw[ew]=function(){return this},Array.from(nw,function(){throw 2})}catch(t){}var iw=sm,sw=function(t,e){try{if(!e&&!Aw)return!1}catch(t){return!1}var A=!1;try{var r={};r[ew]=function(){return{next:function(){return{done:A=!0}}}},t(r)}catch(t){}return A},aw=wm.CONSTRUCTOR||!sw(function(t){iw.all(t).then(void 0,function(){})}),ow=Ml,lw=Xc,cw=Bm,uw=im,hw=tw;Lf({target:"Promise",stat:!0,forced:aw},{all:function(t){var e=this,A=cw.f(e),r=A.resolve,n=A.reject,i=uw(function(){var A=lw(e.resolve),i=[],s=0,a=1;hw(t,function(t){var o=s++,l=!1;a++,ow(A,e,t).then(function(t){l||(l=!0,i[o]=t,--a||r(i))},n)}),--a||r(i)});return i.error&&n(i.value),A.promise}});var dw=Lf,fw=wm.CONSTRUCTOR,pw=sm,gw=yc,mw=mc,vw=Ed,ww=pw&&pw.prototype;if(dw({target:"Promise",proto:!0,forced:fw,real:!0},{catch:function(t){return this.then(void 0,t)}}),mw(pw)){var Bw=gw("Promise").prototype.catch;ww.catch!==Bw&&vw(ww,"catch",Bw,{unsafe:!0})}var bw=Ml,yw=Xc,Cw=Bm,xw=im,Fw=tw;Lf({target:"Promise",stat:!0,forced:aw},{race:function(t){var e=this,A=Cw.f(e),r=A.reject,n=xw(function(){var n=yw(e.resolve);Fw(t,function(t){bw(n,e,t).then(A.resolve,r)})});return n.error&&r(n.value),A.promise}});var Qw=Bm;Lf({target:"Promise",stat:!0,forced:wm.CONSTRUCTOR},{reject:function(t){var e=Qw.f(this);return(0,e.reject)(t),e.promise}});var Uw=ch,Ew=wc,Nw=Bm,Sw=Lf,Lw=wm.CONSTRUCTOR,Iw=function(t,e){if(Uw(t),Ew(e)&&e.constructor===t)return e;var A=Nw.f(t);return(0,A.resolve)(e),A.promise};function _w(t,e,A,r,n,i,s){try{var a=t[i](s),o=a.value}catch(t){return void A(t)}a.done?e(o):Promise.resolve(o).then(r,n)}function Ow(t){return function(){var e=this,A=arguments;return new Promise(function(r,n){var i=t.apply(e,A);function s(t){_w(i,r,n,s,a,"next",t)}function a(t){_w(i,r,n,s,a,"throw",t)}s(void 0)})}}yc("Promise"),Sw({target:"Promise",stat:!0,forced:Lw},{resolve:function(t){return Iw(this,t)}});var kw=pp,Tw=String,jw=function(t){if("Symbol"===kw(t))throw new TypeError("Cannot convert a Symbol value to a string");return Tw(t)},Hw=ch,Pw=function(){var t=Hw(this),e="";return t.hasIndices&&(e+="d"),t.global&&(e+="g"),t.ignoreCase&&(e+="i"),t.multiline&&(e+="m"),t.dotAll&&(e+="s"),t.unicode&&(e+="u"),t.unicodeSets&&(e+="v"),t.sticky&&(e+="y"),e},Dw=Tl,Mw=Ol.RegExp,Rw=Dw(function(){var t=Mw("a","y");return t.lastIndex=2,null!==t.exec("abcd")}),Kw=Rw||Dw(function(){return!Mw("a","y").sticky}),Vw=Rw||Dw(function(){var t=Mw("^r","gy");return t.lastIndex=2,null!==t.exec("str")}),zw={BROKEN_CARET:Vw,MISSED_STICKY:Kw,UNSUPPORTED_Y:Rw},Gw={},qw=Zd,Ww=tf,Xw=Object.keys||function(t){return qw(t,Ww)},Yw=jl,Jw=sh,$w=ih,Zw=ch,tB=pc,eB=Xw;Gw.f=Yw&&!Jw?Object.defineProperties:function(t,e){Zw(t);for(var A,r=tB(e),n=eB(e),i=n.length,s=0;i>s;)$w.f(t,A=n[s++],r[A]);return t};var AB,rB=ch,nB=Gw,iB=tf,sB=zh,aB=Zp,oB=qu,lB="prototype",cB="script",uB=Vh("IE_PROTO"),hB=function(){},dB=function(t){return"<"+cB+">"+t+"</"+cB+">"},fB=function(t){t.write(dB("")),t.close();var e=t.parentWindow.Object;return t=null,e},pB=function(){try{AB=new ActiveXObject("htmlfile")}catch(t){}var t,e,A;pB="undefined"!=typeof document?document.domain&&AB?fB(AB):(e=oB("iframe"),A="java"+cB+":",e.style.display="none",aB.appendChild(e),e.src=String(A),(t=e.contentWindow.document).open(),t.write(dB("document.F=Object")),t.close(),t.F):fB(AB);for(var r=iB.length;r--;)delete pB[lB][iB[r]];return pB()};sB[uB]=!0;var gB,mB,vB=Object.create||function(t,e){var A;return null!==t?(hB[lB]=rB(t),A=new hB,hB[lB]=null,A[uB]=t):A=pB(),void 0===e?A:nB.f(A,e)},wB=Tl,BB=Ol.RegExp,bB=wB(function(){var t=BB(".","s");return!(t.dotAll&&t.test("\n")&&"s"===t.flags)}),yB=Tl,CB=Ol.RegExp,xB=yB(function(){var t=CB("(?<a>b)","g");return"b"!==t.exec("b").groups.a||"bc"!=="b".replace(t,"$<a>c")}),FB=Ml,QB=Zl,UB=jw,EB=Pw,NB=zw,SB=vB,LB=id.get,IB=bB,_B=xB,OB=du("native-string-replace",String.prototype.replace),kB=RegExp.prototype.exec,TB=kB,jB=QB("".charAt),HB=QB("".indexOf),PB=QB("".replace),DB=QB("".slice),MB=(mB=/b*/g,FB(kB,gB=/a/,"a"),FB(kB,mB,"a"),0!==gB.lastIndex||0!==mB.lastIndex),RB=NB.BROKEN_CARET,KB=void 0!==/()??/.exec("")[1];(MB||KB||RB||IB||_B)&&(TB=function(t){var e,A,r,n,i,s,a,o=this,l=LB(o),c=UB(t),u=l.raw;if(u)return u.lastIndex=o.lastIndex,e=FB(TB,u,c),o.lastIndex=u.lastIndex,e;var h=l.groups,d=RB&&o.sticky,f=FB(EB,o),p=o.source,g=0,m=c;if(d&&(f=PB(f,"y",""),-1===HB(f,"g")&&(f+="g"),m=DB(c,o.lastIndex),o.lastIndex>0&&(!o.multiline||o.multiline&&"\n"!==jB(c,o.lastIndex-1))&&(p="(?: "+p+")",m=" "+m,g++),A=new RegExp("^(?:"+p+")",f)),KB&&(A=new RegExp("^"+p+"$(?!\\s)",f)),MB&&(r=o.lastIndex),n=FB(kB,d?A:o,m),d?n?(n.input=DB(n.input,g),n[0]=DB(n[0],g),n.index=o.lastIndex,o.lastIndex+=n[0].length):o.lastIndex=0:MB&&n&&(o.lastIndex=o.global?n.index+n[0].length:r),KB&&n&&n.length>1&&FB(OB,n[0],A,function(){for(i=1;i<arguments.length-2;i++)void 0===arguments[i]&&(n[i]=void 0)}),n&&h)for(n.groups=s=SB(null),i=0;i<h.length;i++)s[(a=h[i])[0]]=n[a[1]];return n});var VB=TB;Lf({target:"RegExp",proto:!0,forced:/./.exec!==VB},{exec:VB});var zB=Ml,GB=Ed,qB=VB,WB=Tl,XB=_u,YB=xh,JB=XB("species"),$B=RegExp.prototype,ZB=function(t,e,A,r){var n=XB(t),i=!WB(function(){var e={};return e[n]=function(){return 7},7!==""[t](e)}),s=i&&!WB(function(){var e=!1,A=/a/;if("split"===t){var r={};r[JB]=function(){return A},(A={constructor:r,flags:""})[n]=/./[n]}return A.exec=function(){return e=!0,null},A[n](""),!e});if(!i||!s||A){var a=/./[n],o=e(n,""[t],function(t,e,A,r,n){var s=e.exec;return s===qB||s===$B.exec?i&&!n?{done:!0,value:zB(a,e,A,r)}:{done:!0,value:zB(t,A,e,r)}:{done:!1}});GB(String.prototype,t,o[0]),GB($B,n,o[1])}r&&YB($B[n],"sham",!0)},tb=Zl,eb=Od,Ab=jw,rb=hc,nb=tb("".charAt),ib=tb("".charCodeAt),sb=tb("".slice),ab=function(t){return function(e,A){var r,n,i=Ab(rb(e)),s=eb(A),a=i.length;return s<0||s>=a?t?"":void 0:(r=ib(i,s))<55296||r>56319||s+1===a||(n=ib(i,s+1))<56320||n>57343?t?nb(i,s):r:t?sb(i,s,s+2):n-56320+(r-55296<<10)+65536}},ob={codeAt:ab(!1),charAt:ab(!0)}.charAt,lb=function(t,e,A){return e+(A?ob(t,e).length:1)},cb=Tl,ub=Ol.RegExp,hb=!cb(function(){var t=!0;try{ub(".","d")}catch(e){t=!1}var e={},A="",r=t?"dgimsy":"gimsy",n=function(t,r){Object.defineProperty(e,t,{get:function(){return A+=r,!0}})},i={dotAll:"s",global:"g",ignoreCase:"i",multiline:"m",sticky:"y"};for(var s in t&&(i.hasIndices="d"),i)n(s,i[s]);return Object.getOwnPropertyDescriptor(ub.prototype,"flags").get.call(e)!==r||A!==r}),db=Ml,fb=wu,pb=Cc,gb={correct:hb},mb=Pw,vb=RegExp.prototype,wb=gb.correct?function(t){return t.flags}:function(t){return gb.correct||!pb(vb,t)||fb(t,"flags")?t.flags:db(mb,t)},Bb=Ml,bb=ch,yb=mc,Cb=rc,xb=VB,Fb=TypeError,Qb=function(t,e){var A=t.exec;if(yb(A)){var r=Bb(A,t,e);return null!==r&&bb(r),r}if("RegExp"===Cb(t))return Bb(xb,t,e);throw new Fb("RegExp#exec called on incompatible receiver")},Ub=Ml,Eb=ZB,Nb=ch,Sb=wc,Lb=Dd,Ib=jw,_b=hc,Ob=$c,kb=lb,Tb=wb,jb=Qb,Hb=Zl("".indexOf);Eb("match",function(t,e,A){return[function(e){var A=_b(this),r=Sb(e)?Ob(e,t):void 0;return r?Ub(r,e,A):new RegExp(e)[t](Ib(A))},function(t){var r=Nb(this),n=Ib(t),i=A(e,r,n);if(i.done)return i.value;var s=Ib(Tb(r));if(-1===Hb(s,"g"))return jb(r,n);var a=-1!==Hb(s,"u");r.lastIndex=0;for(var o,l=[],c=0;null!==(o=jb(r,n));){var u=Ib(o[0]);l[c]=u,""===u&&(r.lastIndex=kb(n,Lb(r.lastIndex),a)),c++}return 0===c?null:l}]});var Pb=Zl,Db=gu,Mb=Math.floor,Rb=Pb("".charAt),Kb=Pb("".replace),Vb=Pb("".slice),zb=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,Gb=/\$([$&'`]|\d{1,2})/g,qb=zp,Wb=Ml,Xb=Zl,Yb=ZB,Jb=Tl,$b=ch,Zb=mc,ty=wc,ey=Od,Ay=Dd,ry=jw,ny=hc,iy=lb,sy=$c,ay=function(t,e,A,r,n,i){var s=A+t.length,a=r.length,o=Gb;return void 0!==n&&(n=Db(n),o=zb),Kb(i,o,function(i,o){var l;switch(Rb(o,0)){case"$":return"$";case"&":return t;case"`":return Vb(e,0,A);case"'":return Vb(e,s);case"<":l=n[Vb(o,1,-1)];break;default:var c=+o;if(0===c)return i;if(c>a){var u=Mb(c/10);return 0===u?i:u<=a?void 0===r[u-1]?Rb(o,1):r[u-1]+Rb(o,1):i}l=r[c-1]}return void 0===l?"":l})},oy=wb,ly=Qb,cy=_u("replace"),uy=Math.max,hy=Math.min,dy=Xb([].concat),fy=Xb([].push),py=Xb("".indexOf),gy=Xb("".slice),my=function(t){return void 0===t?t:String(t)},vy="$0"==="a".replace(/./,"$0"),wy=!!/./[cy]&&""===/./[cy]("a","$0"),By=!Jb(function(){var t=/./;return t.exec=function(){var t=[];return t.groups={a:"7"},t},"7"!=="".replace(t,"$<a>")});Yb("replace",function(t,e,A){var r=wy?"$":"$0";return[function(t,A){var r=ny(this),n=ty(t)?sy(t,cy):void 0;return n?Wb(n,t,r,A):Wb(e,ry(r),t,A)},function(t,n){var i=$b(this),s=ry(t);if("string"==typeof n&&-1===py(n,r)&&-1===py(n,"$<")){var a=A(e,i,s,n);if(a.done)return a.value}var o=Zb(n);o||(n=ry(n));var l,c=ry(oy(i)),u=-1!==py(c,"g");u&&(l=-1!==py(c,"u"),i.lastIndex=0);for(var h,d=[];null!==(h=ly(i,s))&&(fy(d,h),u);){""===ry(h[0])&&(i.lastIndex=iy(s,Ay(i.lastIndex),l))}for(var f="",p=0,g=0;g<d.length;g++){for(var m,v=ry((h=d[g])[0]),w=uy(hy(ey(h.index),s.length),0),B=[],b=1;b<h.length;b++)fy(B,my(h[b]));var y=h.groups;if(o){var C=dy([v],B,w,s);void 0!==y&&fy(C,y),m=ry(qb(n,void 0,C))}else m=ay(v,s,w,B,y,n);w>=p&&(f+=gy(s,p,w)+m,p=w+v.length)}return f+gy(s,p)}]},!By||!vy||wy);var by,yy=wc,Cy=rc,xy=_u("match"),Fy=function(t){var e;return yy(t)&&(void 0!==(e=t[xy])?!!e:"RegExp"===Cy(t))},Qy=TypeError,Uy=function(t){if(Fy(t))throw new Qy("The method doesn't accept regular expressions");return t},Ey=_u("match"),Ny=function(t){var e=/./;try{"/./"[t](e)}catch(A){try{return e[Ey]=!1,"/./"[t](e)}catch(t){}}return!1},Sy=Lf,Ly=Wp,Iy=kl.f,_y=Dd,Oy=jw,ky=Uy,Ty=hc,jy=Ny,Hy=Ly("".slice),Py=Math.min,Dy=jy("startsWith");Sy({target:"String",proto:!0,forced:!!(Dy||(by=Iy(String.prototype,"startsWith"),!by||by.writable))&&!Dy},{startsWith:function(t){var e=Oy(Ty(this));ky(t);var A=_y(Py(arguments.length>1?arguments[1]:void 0,e.length)),r=Oy(t);return Hy(e,A,A+r.length)===r}});var My=_u,Ry=vB,Ky=ih.f,Vy=My("unscopables"),zy=Array.prototype;void 0===zy[Vy]&&Ky(zy,Vy,{configurable:!0,value:Ry(null)});var Gy,qy,Wy,Xy=!Tl(function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype}),Yy=wu,Jy=mc,$y=gu,Zy=Xy,tC=Vh("IE_PROTO"),eC=Object,AC=eC.prototype,rC=Zy?eC.getPrototypeOf:function(t){var e=$y(t);if(Yy(e,tC))return e[tC];var A=e.constructor;return Jy(A)&&e instanceof A?A.prototype:e instanceof eC?AC:null},nC=Tl,iC=mc,sC=wc,aC=rC,oC=Ed,lC=_u("iterator"),cC=!1;[].keys&&("next"in(Wy=[].keys())?(qy=aC(aC(Wy)))!==Object.prototype&&(Gy=qy):cC=!0);var uC=!sC(Gy)||nC(function(){var t={};return Gy[lC].call(t)!==t});uC&&(Gy={}),iC(Gy[lC])||oC(Gy,lC,function(){return this});var hC={IteratorPrototype:Gy,BUGGY_SAFARI_ITERATORS:cC},dC=hC.IteratorPrototype,fC=vB,pC=Wl,gC=Zf,mC=yv,vC=function(){return this},wC=Lf,BC=Ml,bC=mc,yC=function(t,e,A,r){var n=e+" Iterator";return t.prototype=fC(dC,{next:pC(+!r,A)}),gC(t,n,!1),mC[n]=vC,t},CC=rC,xC=Xf,FC=Zf,QC=xh,UC=Ed,EC=yv,NC=Lh.PROPER,SC=Lh.CONFIGURABLE,LC=hC.IteratorPrototype,IC=hC.BUGGY_SAFARI_ITERATORS,_C=_u("iterator"),OC="keys",kC="values",TC="entries",jC=function(){return this},HC=pc,PC=function(t){zy[Vy][t]=!0},DC=yv,MC=id,RC=ih.f,KC=function(t,e,A,r,n,i,s){yC(A,e,r);var a,o,l,c=function(t){if(t===n&&p)return p;if(!IC&&t&&t in d)return d[t];switch(t){case OC:case kC:case TC:return function(){return new A(this,t)}}return function(){return new A(this)}},u=e+" Iterator",h=!1,d=t.prototype,f=d[_C]||d["@@iterator"]||n&&d[n],p=!IC&&f||c(n),g="Array"===e&&d.entries||f;if(g&&(a=CC(g.call(new t)))!==Object.prototype&&a.next&&(CC(a)!==LC&&(xC?xC(a,LC):bC(a[_C])||UC(a,_C,jC)),FC(a,u,!0)),NC&&n===kC&&f&&f.name!==kC&&(SC?QC(d,"name",kC):(h=!0,p=function(){return BC(f,this)})),n)if(o={values:c(kC),keys:i?p:c(OC),entries:c(TC)},s)for(l in o)(IC||h||!(l in d))&&UC(d,l,o[l]);else wC({target:e,proto:!0,forced:IC||h},o);return d[_C]!==p&&UC(d,_C,p,{name:n}),EC[e]=p,o},VC=function(t,e){return{value:t,done:e}},zC=jl,GC="Array Iterator",qC=MC.set,WC=MC.getterFor(GC),XC=KC(Array,"Array",function(t,e){qC(this,{type:GC,target:HC(t),index:0,kind:e})},function(){var t=WC(this),e=t.target,A=t.index++;if(!e||A>=e.length)return t.target=null,VC(void 0,!0);switch(t.kind){case"keys":return VC(A,!1);case"values":return VC(e[A],!1)}return VC([A,e[A]],!1)},"values"),YC=DC.Arguments=DC.Array;if(PC("keys"),PC("values"),PC("entries"),zC&&"values"!==YC.name)try{RC(YC,"name",{value:"values"})}catch(t){}var JC=qu("span").classList,$C=JC&&JC.constructor&&JC.constructor.prototype,ZC=$C===Object.prototype?void 0:$C,tx=Ol,ex={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},Ax=ZC,rx=XC,nx=xh,ix=Zf,sx=_u("iterator"),ax=rx.values,ox=function(t,e){if(t){if(t[sx]!==ax)try{nx(t,sx,ax)}catch(e){t[sx]=ax}if(ix(t,e,!0),ex[e])for(var A in rx)if(t[A]!==rx[A])try{nx(t,A,rx[A])}catch(e){t[A]=rx[A]}}};for(var lx in ex)ox(tx[lx]&&tx[lx].prototype,lx);function cx(t){var e=function(t,e){if("object"!=$t(t)||!t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var r=A.call(t,e||"default");if("object"!=$t(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==$t(e)?e:e+""}function ux(t,e,A){return(e=cx(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}ox(Ax,"DOMTokenList");var hx=Xc,dx=gu,fx=oc,px=Rd,gx=TypeError,mx="Reduce of empty array with no initial value",vx=function(t){return function(e,A,r,n){var i=dx(e),s=fx(i),a=px(i);if(hx(A),0===a&&r<2)throw new gx(mx);var o=t?a-1:0,l=t?-1:1;if(r<2)for(;;){if(o in s){n=s[o],o+=l;break}if(o+=l,t?o<0:a<=o)throw new gx(mx)}for(;t?o>=0:a>o;o+=l)o in s&&(n=A(n,s[o],o,i));return n}},wx={left:vx(!1),right:vx(!0)},Bx=Tl,bx=function(t,e){var A=[][t];return!!A&&Bx(function(){A.call(null,e||function(){return 1},1)})},yx=wx.left;Lf({target:"Array",proto:!0,forced:!jf&&_c>79&&_c<83||!bx("reduce")},{reduce:function(t){var e=arguments.length;return yx(this,t,e,e>1?arguments[1]:void 0)}});var Cx=Lf,xx=Wp,Fx=kl.f,Qx=Dd,Ux=jw,Ex=Uy,Nx=hc,Sx=Ny,Lx=xx("".slice),Ix=Math.min,_x=Sx("endsWith"),Ox=!_x&&!!function(){var t=Fx(String.prototype,"endsWith");return t&&!t.writable}();Cx({target:"String",proto:!0,forced:!Ox&&!_x},{endsWith:function(t){var e=Ux(Nx(this));Ex(t);var A=arguments.length>1?arguments[1]:void 0,r=e.length,n=void 0===A?r:Ix(Qx(A),r),i=Ux(t);return Lx(e,n-i.length,n)===i}});var kx=Ml,Tx=Zl,jx=ZB,Hx=ch,Px=wc,Dx=hc,Mx=Dp,Rx=lb,Kx=Dd,Vx=jw,zx=$c,Gx=Qb,qx=Tl,Wx=zw.UNSUPPORTED_Y,Xx=Math.min,Yx=Tx([].push),Jx=Tx("".slice),$x=!qx(function(){var t=/(?:)/,e=t.exec;t.exec=function(){return e.apply(this,arguments)};var A="ab".split(t);return 2!==A.length||"a"!==A[0]||"b"!==A[1]}),Zx="c"==="abbc".split(/(b)*/)[1]||4!=="test".split(/(?:)/,-1).length||2!=="ab".split(/(?:ab)*/).length||4!==".".split(/(.?)(.?)/).length||".".split(/()()/).length>1||"".split(/.?/).length;jx("split",function(t,e,A){var r="0".split(void 0,0).length?function(t,A){return void 0===t&&0===A?[]:kx(e,this,t,A)}:e;return[function(e,A){var n=Dx(this),i=Px(e)?zx(e,t):void 0;return i?kx(i,e,n,A):kx(r,Vx(n),e,A)},function(t,n){var i=Hx(this),s=Vx(t);if(!Zx){var a=A(r,i,s,n,r!==e);if(a.done)return a.value}var o=Mx(i,RegExp),l=i.unicode,c=(i.ignoreCase?"i":"")+(i.multiline?"m":"")+(i.unicode?"u":"")+(Wx?"g":"y"),u=new o(Wx?"^(?:"+i.source+")":i,c),h=void 0===n?4294967295:n>>>0;if(0===h)return[];if(0===s.length)return null===Gx(u,s)?[s]:[];for(var d=0,f=0,p=[];f<s.length;){u.lastIndex=Wx?0:f;var g,m=Gx(u,Wx?Jx(s,f):s);if(null===m||(g=Xx(Kx(u.lastIndex+(Wx?f:0)),s.length))===d)f=Rx(s,f,l);else{if(Yx(p,Jx(s,d,f)),p.length===h)return p;for(var v=1;v<=m.length-1;v++)if(Yx(p,m[v]),p.length===h)return p;f=d=g}}return Yx(p,Jx(s,d)),p}]},Zx||!$x,Wx);var tF={exports:{}},eF={exports:{}};(function(){var t,e,A,r,n,i;"undefined"!=typeof performance&&null!==performance&&performance.now?eF.exports=function(){return performance.now()}:"undefined"!=typeof process&&null!==process&&process.hrtime?(eF.exports=function(){return(t()-n)/1e6},e=process.hrtime,r=(t=function(){var t;return 1e9*(t=e())[0]+t[1]})(),i=1e9*process.uptime(),n=r-i):Date.now?(eF.exports=function(){return Date.now()-A},A=Date.now()):(eF.exports=function(){return(new Date).getTime()-A},A=(new Date).getTime())}).call(R);for(var AF=eF.exports,rF="undefined"==typeof window?R:window,nF=["moz","webkit"],iF="AnimationFrame",sF=rF["request"+iF],aF=rF["cancel"+iF]||rF["cancelRequest"+iF],oF=0;!sF&&oF<nF.length;oF++)sF=rF[nF[oF]+"Request"+iF],aF=rF[nF[oF]+"Cancel"+iF]||rF[nF[oF]+"CancelRequest"+iF];if(!sF||!aF){var lF=0,cF=0,uF=[],hF=1e3/60;sF=function(t){if(0===uF.length){var e=AF(),A=Math.max(0,hF-(e-lF));lF=A+e,setTimeout(function(){var t=uF.slice(0);uF.length=0;for(var e=0;e<t.length;e++)if(!t[e].cancelled)try{t[e].callback(lF)}catch(t){setTimeout(function(){throw t},0)}},Math.round(A))}return uF.push({handle:++cF,callback:t,cancelled:!1}),cF},aF=function(t){for(var e=0;e<uF.length;e++)uF[e].handle===t&&(uF[e].cancelled=!0)}}tF.exports=function(t){return sF.call(rF,t)},tF.exports.cancel=function(){aF.apply(rF,arguments)},tF.exports.polyfill=function(t){t||(t=rF),t.requestAnimationFrame=sF,t.cancelAnimationFrame=aF};var dF=K(tF.exports),fF="\t\n\v\f\r                 \u2028\u2029\ufeff",pF=hc,gF=jw,mF=fF,vF=Zl("".replace),wF=RegExp("^["+mF+"]+"),BF=RegExp("(^|[^"+mF+"])["+mF+"]+$"),bF=function(t){return function(e){var A=gF(pF(e));return 1&t&&(A=vF(A,wF,"")),2&t&&(A=vF(A,BF,"$1")),A}},yF={start:bF(1),end:bF(2),trim:bF(3)},CF=Lh.PROPER,xF=Tl,FF=fF,QF=yF.trim;Lf({target:"String",proto:!0,forced:function(t){return xF(function(){return!!FF[t]()||"​…᠎"!=="​…᠎"[t]()||CF&&FF[t].name!==t})}("trim")},{trim:function(){return QF(this)}});var UF=function(t){this.ok=!1,this.alpha=1,"#"==t.charAt(0)&&(t=t.substr(1,6)),t=(t=t.replace(/ /g,"")).toLowerCase();var e={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dodgerblue:"1e90ff",feldspar:"d19275",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgrey:"d3d3d3",lightgreen:"90ee90",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslateblue:"8470ff",lightslategray:"778899",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370d8",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"d87093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"ff0000",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",violetred:"d02090",wheat:"f5deb3",white:"ffffff",whitesmoke:"f5f5f5",yellow:"ffff00",yellowgreen:"9acd32"};t=e[t]||t;for(var A=[{re:/^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*((?:\d?\.)?\d)\)$/,example:["rgba(123, 234, 45, 0.8)","rgba(255,234,245,1.0)"],process:function(t){return[parseInt(t[1]),parseInt(t[2]),parseInt(t[3]),parseFloat(t[4])]}},{re:/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,example:["rgb(123, 234, 45)","rgb(255,234,245)"],process:function(t){return[parseInt(t[1]),parseInt(t[2]),parseInt(t[3])]}},{re:/^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,example:["#00ff00","336699"],process:function(t){return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]}},{re:/^([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,example:["#fb0","f0f"],process:function(t){return[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16)]}}],r=0;r<A.length;r++){var n=A[r].re,i=A[r].process,s=n.exec(t);if(s){var a=i(s);this.r=a[0],this.g=a[1],this.b=a[2],a.length>3&&(this.alpha=a[3]),this.ok=!0}}this.r=this.r<0||isNaN(this.r)?0:this.r>255?255:this.r,this.g=this.g<0||isNaN(this.g)?0:this.g>255?255:this.g,this.b=this.b<0||isNaN(this.b)?0:this.b>255?255:this.b,this.alpha=this.alpha<0?0:this.alpha>1||isNaN(this.alpha)?1:this.alpha,this.toRGB=function(){return"rgb("+this.r+", "+this.g+", "+this.b+")"},this.toRGBA=function(){return"rgba("+this.r+", "+this.g+", "+this.b+", "+this.alpha+")"},this.toHex=function(){var t=this.r.toString(16),e=this.g.toString(16),A=this.b.toString(16);return 1==t.length&&(t="0"+t),1==e.length&&(e="0"+e),1==A.length&&(A="0"+A),"#"+t+e+A},this.getHelpXML=function(){for(var t=new Array,r=0;r<A.length;r++)for(var n=A[r].example,i=0;i<n.length;i++)t[t.length]=n[i];for(var s in e)t[t.length]=s;var a=document.createElement("ul");a.setAttribute("id","rgbcolor-examples");for(r=0;r<t.length;r++)try{var o=document.createElement("li"),l=new RGBColor(t[r]),c=document.createElement("div");c.style.cssText="margin: 3px; border: 1px solid black; background:"+l.toHex()+"; color:"+l.toHex(),c.appendChild(document.createTextNode("test"));var u=document.createTextNode(" "+t[r]+" -> "+l.toRGB()+" -> "+l.toHex());o.appendChild(c),o.appendChild(u),a.appendChild(o)}catch(t){}return a}},EF=K(UF),NF=Lf,SF=qd.indexOf,LF=bx,IF=Wp([].indexOf),_F=!!IF&&1/IF([1],1,-0)<0;NF({target:"Array",proto:!0,forced:_F||!LF("indexOf")},{indexOf:function(t){var e=arguments.length>1?arguments[1]:void 0;return _F?IF(this,t,e)||0:SF(this,t,e)}});var OF=Lf,kF=Uy,TF=hc,jF=jw,HF=Ny,PF=Zl("".indexOf);OF({target:"String",proto:!0,forced:!HF("includes")},{includes:function(t){return!!~PF(jF(TF(this)),jF(kF(t)),arguments.length>1?arguments[1]:void 0)}});var DF=rc,MF=Lf,RF=Array.isArray||function(t){return"Array"===DF(t)},KF=Zl([].reverse),VF=[1,2];MF({target:"Array",proto:!0,forced:String(VF)===String(VF.reverse())},{reverse:function(){return RF(this)&&(this.length=this.length),KF(this)}});
310
310
  /*! *****************************************************************************