rndefine("#RNMainFormBuilderCore",["#RNMainCoreUI/ModelBase","lit","#RNMainCore/EventManager","#RNMainDialog/Dialog","#RNMainCore/WpAjaxPost","#RNMainCore/SingleEvent","#RNMainCore/StoreBase","#RNMainDialog/DialogBase","lit/decorators","#RNMainCore/LitElementBase","#RNMainLit/Lit","#RNMainCoreUI/ModelWithParent","#RNMainCore/Sanitizer","lit/directives/repeat.js","#RNMainCoreUI/LitModel"],(function(e,t,i,s,r,n,l,a,o,u,d,h,c,p,m){"use strict";var b,f,y,g,F,I,C,P,v,S,x,O,T,D,w,G,E,_,R,M,V;let $,z,B;!function(e){e.Equal="Equal",e.NotEqual="NotEqual",e.IsEmpty="IsEmpty",e.IsNotEmpty="IsNotEmpty",e.None="None",e.Contains="Contains",e.NotContains="NotContains",e.ChangedTo="ChangedTo",e.ChangedFrom="ChangedFrom",e.GreaterThan="GreaterThan",e.GreaterOrEqualThan="GreaterOrEqualThan",e.LessThan="LessThan",e.LessOrEqualThan="LessOrEqualThan",e.IsChecked="IsChecked",e.IsNotChecked="IsNotChecked",e.WasClicked="WasClicked",e.IsGuest="IsGuest",e.IsNotGuest="IsNotGuest",e.ViewingPage="ViewingPage",e.Is="Is",e.IsNot="IsNot",e.IsPartOfRole="IsPartOfRole",e.IsNotPartOfRole="IsNotPartOfRole"}($||($={})),function(e){e.Standard="Standard",e.Text="Text",e.MultipleValues="MultipleValues",e.Composed="Composed",e.Date="Date",e.Numeric="Numeric",e.Checkbox="Checkbox",e.Button="Button",e.Status="Status",e.Role="Role",e.Survey="Survey",e.List="List"}(z||(z={})),function(e){e.Variation="Variation",e.None="None",e.Entry="Entry",e.Field="Field",e.User="User"}(B||(B={}));class N{static GetValue(e,t){if(e.SubType==z.MultipleValues)return""!=t&&Array.isArray(t)?t:[]}}let L,A=(b=l.StoreDataType(Object),f=l.StoreDataType(Object),y=l.StoreAutoIncrement("ConditionLineOptions"),g=class extends l.StoreBase{constructor(...e){super(...e),babelHelpers.initializerDefineProperty(this,"Value",F,this),babelHelpers.initializerDefineProperty(this,"Formula",I,this),babelHelpers.initializerDefineProperty(this,"Id",C,this)}LoadDefaultValues(){this.Id=0,this.FieldId="",this.Comparison=$.None,this.Value="",this.Type=B.None,this.SubType=z.Standard,this.ValueSubType="",this.PathId="",this.Formula=null,this.HasMapping=!1}GetValueFromLoader(e,t){return"Value"===e?N.GetValue(this,t):null}},F=babelHelpers.applyDecoratedDescriptor(g.prototype,"Value",[b],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),I=babelHelpers.applyDecoratedDescriptor(g.prototype,"Formula",[f],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),C=babelHelpers.applyDecoratedDescriptor(g.prototype,"Id",[y],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),g),U=(P=l.StoreAutoIncrement("ConditionGroupOptions"),v=l.StoreDataType(A),S=class extends l.StoreBase{constructor(...e){super(...e),babelHelpers.initializerDefineProperty(this,"Id",x,this),babelHelpers.initializerDefineProperty(this,"ConditionLines",O,this)}LoadDefaultValues(){this.ConditionLines=[],this.Id=0}},x=babelHelpers.applyDecoratedDescriptor(S.prototype,"Id",[P],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),O=babelHelpers.applyDecoratedDescriptor(S.prototype,"ConditionLines",[v],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),S);!function(e){e.Field="Field"}(L||(L={}));class H extends l.StoreBase{LoadDefaultValues(){this.Type=L.Field,this.Id=""}}let k=(T=l.StoreAutoIncrement("ConditionOptionsBase"),D=l.StoreDataType(U),w=l.StoreDataType(H),G=l.StoreDataType(Object),E=class extends l.StoreBase{constructor(...e){super(...e),babelHelpers.initializerDefineProperty(this,"Id",_,this),babelHelpers.initializerDefineProperty(this,"ConditionGroups",R,this),babelHelpers.initializerDefineProperty(this,"ElementsUsed",M,this),babelHelpers.initializerDefineProperty(this,"Formula",V,this)}LoadDefaultValues(){this.Id=0,this.Type="ShowHide",this.ElementsUsed=[],this.ConditionGroups=[],this.Formula=null}},_=babelHelpers.applyDecoratedDescriptor(E.prototype,"Id",[T],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),R=babelHelpers.applyDecoratedDescriptor(E.prototype,"ConditionGroups",[D],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),M=babelHelpers.applyDecoratedDescriptor(E.prototype,"ElementsUsed",[w],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),V=babelHelpers.applyDecoratedDescriptor(E.prototype,"Formula",[G],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),E);class Q extends k{LoadDefaultValues(){super.LoadDefaultValues(),this.Type="ShowHide",this.ShowWhenTrue=!0}}class W extends k{LoadDefaultValues(){super.LoadDefaultValues(),this.Type="Validation",this.IsInvalidWhenTrue=!0,this.InvalidMessage="Invalid Field"}}var j,q,J;class Y{static GetFieldOptions(e){let t=i.EventManager.Publish("GetFieldOptions",e.Type);return null==t?null:(t.Merge(e),t)}}let Z=(j=l.StoreAutoIncrement("FBColumn"),q=class extends l.StoreBase{constructor(...e){super(...e),babelHelpers.initializerDefineProperty(this,"Id",J,this)}LoadDefaultValues(){this.Id=0,this.WidthPercentage=100,this.Field=null}GetValueFromLoader(e,t){return"Field"===e?Y.GetFieldOptions(t):null}},J=babelHelpers.applyDecoratedDescriptor(q.prototype,"Id",[j],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),q);var K,X,ee,te,ie;let se=(K=l.StoreAutoIncrement("FBRow"),X=l.StoreDataType(Z),ee=class extends l.StoreBase{constructor(...e){super(...e),babelHelpers.initializerDefineProperty(this,"Id",te,this),babelHelpers.initializerDefineProperty(this,"Columns",ie,this)}LoadDefaultValues(){this.Id=0,this.StepId=0,this.Columns=[]}},te=babelHelpers.applyDecoratedDescriptor(ee.prototype,"Id",[K],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),ie=babelHelpers.applyDecoratedDescriptor(ee.prototype,"Columns",[X],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),ee);var re,ne,le,ae,oe,ue,de,he,ce,pe,me,be,fe,ye,ge,Fe,Ie,Ce,Pe,ve,Se,xe,Oe,Te,De,we,Ge;let Ee;!function(e){e.Price="price",e.Any="any",e.Number="number",e.String="string",e.Raw="raw",e.Boolean="boolean"}(Ee||(Ee={}));let _e=(re=l.StoreDataType(Object),ne=class extends l.StoreBase{constructor(...e){super(...e),babelHelpers.initializerDefineProperty(this,"Ref",le,this)}LoadDefaultValues(){this.ImageType="none",this.Ref=null}},le=babelHelpers.applyDecoratedDescriptor(ne.prototype,"Ref",[re],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),ne),Re=(ae=l.StoreAutoIncrement("MultipleStepItem"),oe=l.StoreDataType(Number),ue=l.StoreDataType(k),de=class extends l.StoreBase{constructor(...e){super(...e),babelHelpers.initializerDefineProperty(this,"Id",he,this),babelHelpers.initializerDefineProperty(this,"FieldIds",ce,this),babelHelpers.initializerDefineProperty(this,"Conditions",pe,this)}LoadDefaultValues(){this.Id=0,this.Title="",this.FieldIds=[],this.Icon=(new _e).Merge(),this.Image=(new _e).Merge(),this.Conditions=[]}GetValueFromLoader(e,t){return"Conditions"===e?at.GetConditions(t):null}},he=babelHelpers.applyDecoratedDescriptor(de.prototype,"Id",[ae],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),ce=babelHelpers.applyDecoratedDescriptor(de.prototype,"FieldIds",[oe],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),pe=babelHelpers.applyDecoratedDescriptor(de.prototype,"Conditions",[ue],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),de),Me=(me=l.StoreDataType(Re),be=class extends l.StoreBase{constructor(...e){super(...e),babelHelpers.initializerDefineProperty(this,"Steps",fe,this)}LoadDefaultValues(){this.Style="Tabs",this.NextButtonText="Next",this.PreviousButtonText="Previous",this.SubmitButtonText="Submit",this.Steps=[],this.IncludeStepImage=!1,this.ImagePosition="top",this.ImageWidth="100%",this.ImageHeight="300px"}},fe=babelHelpers.applyDecoratedDescriptor(be.prototype,"Steps",[me],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),be),Ve=(ye=l.StoreDataType(Object),ge=l.StoreDataType(Object),Fe=l.StoreDataType(Me),Ie=l.StoreDataType(String),Ce=class extends l.StoreBase{constructor(...e){super(...e),babelHelpers.initializerDefineProperty(this,"Extensions",Pe,this),babelHelpers.initializerDefineProperty(this,"Icons",ve,this),babelHelpers.initializerDefineProperty(this,"MultipleSteps",Se,this),babelHelpers.initializerDefineProperty(this,"ExtensionsUsed",xe,this)}LoadDefaultValues(){this.Styles="",this.Javascript="",this.EnableDebug=!1,this.Icons=[],this.MapsApiKey="",this.MultipleSteps=null,this.Extensions=[],this.ExtensionsUsed=[],this.RequiredMessage="Required",this.Theme=""}},Pe=babelHelpers.applyDecoratedDescriptor(Ce.prototype,"Extensions",[ye],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),ve=babelHelpers.applyDecoratedDescriptor(Ce.prototype,"Icons",[ge],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),Se=babelHelpers.applyDecoratedDescriptor(Ce.prototype,"MultipleSteps",[Fe],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),xe=babelHelpers.applyDecoratedDescriptor(Ce.prototype,"ExtensionsUsed",[Ie],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),Ce),$e=(Oe=l.StoreDataType(se),Te=l.StoreDataType(String),De=class extends l.StoreBase{constructor(...e){super(...e),babelHelpers.initializerDefineProperty(this,"Rows",we,this),babelHelpers.initializerDefineProperty(this,"Dependencies",Ge,this)}LoadDefaultValues(){this.Rows=[],this.ClientOptions=(new Ve).Merge(),this.Dependencies=[]}},we=babelHelpers.applyDecoratedDescriptor(De.prototype,"Rows",[Oe],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),Ge=babelHelpers.applyDecoratedDescriptor(De.prototype,"Dependencies",[Te],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),De);var ze,Be,Ne,Le,Ae,Ue,He,ke,Qe,We,je,qe,Je,Ye,Ze,Ke,Xe,et,tt,it,st,rt;let nt,lt=(ze=l.StoreDataType(String),Be=l.StoreDataType(Number),Ne=l.StoreDataType(Object),Le=class extends l.StoreBase{constructor(...e){super(...e),babelHelpers.initializerDefineProperty(this,"Dependencies",Ae,this),babelHelpers.initializerDefineProperty(this,"Fields",Ue,this),babelHelpers.initializerDefineProperty(this,"Compiled",He,this)}LoadDefaultValues(){this.Code="",this.Name="",this.Compiled=null,this.PreferredReturnType=Ee.Any,this.Dependencies=[],this.Fields=[],this.SkipFieldListener=!1,this.SubId=""}},Ae=babelHelpers.applyDecoratedDescriptor(Le.prototype,"Dependencies",[ze],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),Ue=babelHelpers.applyDecoratedDescriptor(Le.prototype,"Fields",[Be],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),He=babelHelpers.applyDecoratedDescriptor(Le.prototype,"Compiled",[Ne],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),Le);class at{static GetConditions(e){let t=[];for(let s of e)switch(s.Type){case"ShowHide":t.push((new Q).Merge(s));break;case"Validation":t.push((new W).Merge(s));break;default:let e=i.EventManager.Publish("GetCondition",{Type:s.Type});if(null!=e&&t.push(e.Merge(s)),null==e)throw new Error("Condition not found "+s.Type)}return t}}!function(e){e.Text="text",e.Numeric="numeric",e.Total="total",e.TextArea="textarea",e.Radio="radio",e.Checkbox="checkbox",e.DropDown="dropdown",e.Hidden="hidden",e.Paragraph="paragraph",e.FileUpload="fileupload",e.ImagePicker="imagepicker",e.Divider="divider",e.Repeater="repeater",e.List="list",e.GroupPanel="grouppanel",e.FloatPanel="floatpanel",e.RepeaterItem="repeater_item",e.SubmitButton="submit_button",e.Datepicker="datepicker",e.DateRange="daterange",e.Masked="masked",e.ColorPicker="colorpicker",e.Slider="slider",e.ButtonSelection="buttonselection",e.Switch="switch",e.Signature="signature",e.ColorSwatcher="colorswatcher",e.TermOfService="termofservice",e.GoogleMaps="googlemaps",e.TextualImage="textualimage",e.Name="name",e.Email="email",e.Address="address",e.Recaptcha="recaptcha",e.None="none",e.Image="image",e.ActionButton="actionbutton",e.Survey="survey",e.HTML="html",e.SimpleText="simpletext"}(nt||(nt={}));let ot,ut=(ke=l.StoreAutoIncrement("FieldId"),Qe=l.StoreDataType(Object),We=l.StoreDataType(Object),je=l.StoreDataType(lt),qe=l.StoreDataType(k),Je=l.StoreDataType(Object),Ye=l.StoreDataType(Object),Ze=class extends l.StoreBase{constructor(...e){super(...e),babelHelpers.initializerDefineProperty(this,"Id",Ke,this),babelHelpers.initializerDefineProperty(this,"Description",Xe,this),babelHelpers.initializerDefineProperty(this,"Tooltip",et,this),babelHelpers.initializerDefineProperty(this,"Formulas",tt,this),babelHelpers.initializerDefineProperty(this,"Conditions",it,this),babelHelpers.initializerDefineProperty(this,"Behaviors",st,this),babelHelpers.initializerDefineProperty(this,"AS",rt,this)}LoadDefaultValues(){this.Id=0,this.HideLabel=!1,this.Label="",this.Description=null,this.Required=!1,this.Tooltip=null,this.IsFieldContainer=!1,this.Formulas=[],this.Conditions=[],this.Behaviors=[],this.ClassName="",this.AS=null}GetValueFromLoader(e,t){return"Conditions"===e?at.GetConditions(t):null}},Ke=babelHelpers.applyDecoratedDescriptor(Ze.prototype,"Id",[ke],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),Xe=babelHelpers.applyDecoratedDescriptor(Ze.prototype,"Description",[Qe],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),et=babelHelpers.applyDecoratedDescriptor(Ze.prototype,"Tooltip",[We],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),tt=babelHelpers.applyDecoratedDescriptor(Ze.prototype,"Formulas",[je],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),it=babelHelpers.applyDecoratedDescriptor(Ze.prototype,"Conditions",[qe],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),st=babelHelpers.applyDecoratedDescriptor(Ze.prototype,"Behaviors",[Je],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),rt=babelHelpers.applyDecoratedDescriptor(Ze.prototype,"AS",[Ye],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),Ze);!function(e){e.price_per_distance="price_per_distance",e.fixed_amount="fixed_amount",e.quantity="quantity",e.current_value="current_value",e.percent_of_original_price="percent_of_original_price",e.percent_or_original_price_plus_options="percent_or_original_price_plus_options",e.price_per_word="price_per_word",e.price_per_char="price_per_char",e.none="none",e.options="options",e.survey_options="survey_options",e.price_per_item="price_per_item",e.sum_of_fields_in_group="sum_of_fields_in_group",e.price_per_day="price_per_day",e.formula="formula",e.quantity_per_day="quantity_per_day"}(ot||(ot={}));class dt extends ut{constructor(...e){super(...e),this.QuantityMinimumValue=0,this.QuantityMaximumValue=0,this.QuantityDefaultValue="",this.QuantityPlaceholder="",this.QuantityLabel=""}LoadDefaultValues(){super.LoadDefaultValues(),this.PriceType=ot.none,this.Price="",this.SalePrice="",this.HidePrice=!1,this.ShowQuantitySelector=!1,this.QuantityPosition="top",this.QuantityMinimumValue=0,this.QuantityMaximumValue=0,this.QuantityDefaultValue="",this.QuantityPlaceholder="",this.QuantityLabel=""}}class ht{constructor(e){this.FormBuilder=e,this.UnitPrice=0,this.Quantity=0,this.OptionsTotal=0,this.DiscountTotal=0,this.TotalUpdated=new n.SingleEvent,this.GrandTotal=0,this.OptionsTotal=0,this.UnitPrice=0,this.FieldPriceUpdated=new n.SingleEvent,this.RecalculateTotal=this.RecalculateTotal.bind(this)}AddField(e){null!=e.Calculator&&(e.Calculator.PriceUpdated.Subscribe(this,this.RecalculateTotal),this.FieldPriceUpdated.Publish(e),this.RecalculateTotal(e))}RemoveField(e){null!=e.Calculator&&(e.Calculator.PriceUpdated.Unsubscribe(this),this.RecalculateTotal(e))}RecalculateTotal(e){null!=e&&this.FieldPriceUpdated.Publish(e);let t=this.GrandTotal,i=this.Quantity,s=this.DiscountTotal;this.UnitPrice=this.CalculateUnitPrice();let r=this.GetFields().find((e=>{var t;return e.Options.PriceType==ot.quantity||e.Options.PriceType==ot.quantity_per_day||(null===(t=e.Calculator)||void 0===t?void 0:t.CanCalculateQuantity())}));this.Quantity=null==r?1:r.Calculator.GetQuantity(),this.DiscountTotal=this.CalculateDiscount(),this.BeforeCalculatingGrandTotal(),this.GrandTotal=(this.UnitPrice-this.DiscountTotal)*this.Quantity,t==this.GrandTotal&&this.Quantity==i&&this.DiscountTotal==s||(this.TotalUpdated.Publish(this.GrandTotal),null!=this.FormBuilder.Calculator&&this.FormBuilder.Calculator.PriceUpdated.Publish(this))}BeforeCalculatingGrandTotal(){}CalculateDiscount(){return this.GetFields("D").reduce(((e,t)=>{var i;return e+(null===(i=t.Calculator)||void 0===i?void 0:i.GetPrice())}),0)}CalculateUnitPrice(){return this.GetFields().reduce(((e,t)=>{var i;return e+(null===(i=t.Calculator)||void 0===i?void 0:i.GetPrice())}),0)}GetFields(e="P"){return this.FormBuilder.GetFields(!1,!1,!1).filter((t=>"P"==e?t.IsFieldWithPrice&&(null==t.Calculator||0==t.Calculator.IsDiscount):null!=t.Calculator&&1==t.Calculator.IsDiscount))}GetPriceIgnoringFields(e){let t=0;for(let i of this.GetFields())i.Calculator.IsDynamic()||e.find((e=>e.Options.Id==i.Options.Id))||(t+=i.Calculator.GetPrice());return t}GetPrice(e){let t=this.GetFields().find((t=>t==e));return null==t?0:t.Calculator.GetPrice()}GetQuantity(){return this.Quantity}GetUnitPrice(){return this.UnitPrice}GetOptionsTotal(){return this.OptionsTotal}GetGrandTotal(){return this.GrandTotal}GetDiscountTotal(){return this.DiscountTotal}}var ct,pt,mt;const bt=globalThis,ft=e=>{bt.emitLitDebugLogEvents&&bt.dispatchEvent(new CustomEvent("lit-debug",{detail:e}))};let yt;var gt;null!==(gt=bt.litIssuedWarnings)&&void 0!==gt||(bt.litIssuedWarnings=new Set),yt=(e,t)=>{t+=e?` See https://lit.dev/msg/${e} for more information.`:"",bt.litIssuedWarnings.has(t)||(console.warn(t),bt.litIssuedWarnings.add(t))};const Ft=(null===(ct=bt.ShadyDOM)||void 0===ct?void 0:ct.inUse)&&!0===(null===(pt=bt.ShadyDOM)||void 0===pt?void 0:pt.noPatch)?bt.ShadyDOM.wrap:e=>e,It=bt.trustedTypes,Ct=It?It.createPolicy("lit-html",{createHTML:e=>e}):void 0,Pt=e=>e,vt=(e,t,i)=>Pt,St=(e,t,i)=>Qt(),xt="$lit$",Ot=`lit$${String(Math.random()).slice(9)}$`,Tt="?"+Ot,Dt=`<${Tt}>`,wt=document,Gt=()=>wt.createComment(""),Et=e=>null===e||"object"!=typeof e&&"function"!=typeof e,_t=Array.isArray,Rt="[ \t\n\f\r]",Mt=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Vt=/-->/g,$t=/>/g,zt=new RegExp(`>|${Rt}(?:([^\\s"'>=/]+)(${Rt}*=${Rt}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),Bt=/'/g,Nt=/"/g,Lt=/^(?:script|style|textarea|title)$/i,At=Symbol.for("lit-noChange"),Ut=Symbol.for("lit-nothing"),Ht=new WeakMap,kt=wt.createTreeWalker(wt,129);let Qt=vt;function Wt(e,t){if(!Array.isArray(e)||!e.hasOwnProperty("raw")){let e="invalid template strings array";throw e=" Internal Error: expected template strings to be an array with a 'raw' field. Faking a template strings array by calling html or svg like an ordinary function is effectively the same as calling unsafeHtml and can lead to major security issues, e.g. opening your code up to XSS attacks. If you're using the html or svg tagged template functions normally and still seeing this error, please file a bug at https://github.com/lit/lit/issues/new?template=bug_report.md and include information about your build tooling, if any. ".trim().replace(/\n */g,"\n"),new Error(e)}return void 0!==Ct?Ct.createHTML(t):t}class jt{constructor({strings:e,_$litType$:t},i){let s;this.parts=[];let r=0,n=0;const l=e.length-1,a=this.parts,[o,u]=((e,t)=>{const i=e.length-1,s=[];let r,n=2===t?"<svg>":"",l=Mt;for(let t=0;t<i;t++){const i=e[t];let o,u,d=-1,h=0;for(;h<i.length&&(l.lastIndex=h,u=l.exec(i),null!==u);)if(h=l.lastIndex,l===Mt){if("!--"===u[1])l=Vt;else if(void 0!==u[1])l=$t;else if(void 0!==u[2])Lt.test(u[2])&&(r=new RegExp(`</${u[2]}`,"g")),l=zt;else if(void 0!==u[3])throw new Error("Bindings in tag names are not supported. Please use static templates instead. See https://lit.dev/docs/templates/expressions/#static-expressions")}else if(l===zt){var a;">"===u[0]?(l=null!==(a=r)&&void 0!==a?a:Mt,d=-1):void 0===u[1]?d=-2:(d=l.lastIndex-u[2].length,o=u[1],l=void 0===u[3]?zt:'"'===u[3]?Nt:Bt)}else l===Nt||l===Bt?l=zt:l===Vt||l===$t?l=Mt:(l=zt,r=void 0);console.assert(-1===d||l===zt||l===Bt||l===Nt,"unexpected parse state B");const c=l===zt&&e[t+1].startsWith("/>")?" ":"";n+=l===Mt?i+Dt:d>=0?(s.push(o),i.slice(0,d)+xt+i.slice(d)+Ot+c):i+Ot+(-2===d?t:c)}return[Wt(e,n+(e[i]||"<?>")+(2===t?"</svg>":"")),s]})(e,t);if(this.el=jt.createElement(o,i),kt.currentNode=this.el.content,2===t){const e=this.el.content.firstChild;e.replaceWith(...e.childNodes)}for(;null!==(s=kt.nextNode())&&a.length<l;){if(1===s.nodeType){{const e=s.localName;if(/^(?:textarea|template)$/i.test(e)&&s.innerHTML.includes(Ot)){const t=`Expressions are not supported inside \`${e}\` elements. See https://lit.dev/msg/expression-in-${e} for more information.`;if("template"===e)throw new Error(t);yt("",t)}}if(s.hasAttributes())for(const e of s.getAttributeNames())if(e.endsWith(xt)){const t=u[n++],i=s.getAttribute(e).split(Ot),l=/([.?@])?(.*)/.exec(t);a.push({type:1,index:r,name:l[2],strings:i,ctor:"."===l[1]?Kt:"?"===l[1]?Xt:"@"===l[1]?ei:Zt}),s.removeAttribute(e)}else e.startsWith(Ot)&&(a.push({type:6,index:r}),s.removeAttribute(e));if(Lt.test(s.tagName)){const e=s.textContent.split(Ot),t=e.length-1;if(t>0){s.textContent=It?It.emptyScript:"";for(let i=0;i<t;i++)s.append(e[i],Gt()),kt.nextNode(),a.push({type:2,index:++r});s.append(e[t],Gt())}}}else if(8===s.nodeType){if(s.data===Tt)a.push({type:2,index:r});else{let e=-1;for(;-1!==(e=s.data.indexOf(Ot,e+1));)a.push({type:7,index:r}),e+=Ot.length-1}}r++}if(u.length!==n)throw new Error('Detected duplicate attribute bindings. This occurs if your template has duplicate attributes on an element tag. For example "<input ?disabled=${true} ?disabled=${false}>" contains a duplicate "disabled" attribute. The error was detected in the following template: \n`'+e.join("${...}")+"`");ft&&ft({kind:"template prep",template:this,clonableTemplate:this.el,parts:this.parts,strings:e})}static createElement(e,t){const i=wt.createElement("template");return i.innerHTML=e,i}}function qt(e,t,i=e,s){var r,n;if(t===At)return t;let l=void 0!==s?null===(r=i.__directives)||void 0===r?void 0:r[s]:i.__directive;const a=Et(t)?void 0:t._$litDirective$;var o,u,d;(null===(n=l)||void 0===n?void 0:n.constructor)!==a&&(null===(o=l)||void 0===o||null===(u=o._$notifyDirectiveConnectionChanged)||void 0===u||u.call(o,!1),void 0===a?l=void 0:(l=new a(e),l._$initialize(e,i,s)),void 0!==s?(null!==(d=i.__directives)&&void 0!==d?d:i.__directives=[])[s]=l:i.__directive=l);return void 0!==l&&(t=qt(e,l._$resolve(e,t.values),l,s)),t}class Jt{constructor(e,t){this._$parts=[],this._$disconnectableChildren=void 0,this._$template=e,this._$parent=t}get parentNode(){return this._$parent.parentNode}get _$isConnected(){return this._$parent._$isConnected}_clone(e){var t;const{el:{content:i},parts:s}=this._$template,r=(null!==(t=null==e?void 0:e.creationScope)&&void 0!==t?t:wt).importNode(i,!0);kt.currentNode=r;let n=kt.nextNode(),l=0,a=0,o=s[0];for(;void 0!==o;){var u;if(l===o.index){let t;2===o.type?t=new Yt(n,n.nextSibling,this,e):1===o.type?t=new o.ctor(n,o.name,o.strings,this,e):6===o.type&&(t=new ti(n,this,e)),this._$parts.push(t),o=s[++a]}l!==(null===(u=o)||void 0===u?void 0:u.index)&&(n=kt.nextNode(),l++)}return kt.currentNode=wt,r}_update(e){let t=0;for(const i of this._$parts)void 0!==i&&(ft&&ft({kind:"set part",part:i,value:e[t],valueIndex:t,values:e,templateInstance:this}),void 0!==i.strings?(i._$setValue(e,i,t),t+=i.strings.length-2):i._$setValue(e[t])),t++}}class Yt{get _$isConnected(){var e,t;return null!==(e=null===(t=this._$parent)||void 0===t?void 0:t._$isConnected)&&void 0!==e?e:this.__isConnected}constructor(e,t,i,s){var r;this.type=2,this._$committedValue=Ut,this._$disconnectableChildren=void 0,this._$startNode=e,this._$endNode=t,this._$parent=i,this.options=s,this.__isConnected=null===(r=null==s?void 0:s.isConnected)||void 0===r||r,this._textSanitizer=void 0}get parentNode(){var e;let t=Ft(this._$startNode).parentNode;const i=this._$parent;return void 0!==i&&11===(null===(e=t)||void 0===e?void 0:e.nodeType)&&(t=i.parentNode),t}get startNode(){return this._$startNode}get endNode(){return this._$endNode}_$setValue(e,t=this){if(null===this.parentNode)throw new Error("This `ChildPart` has no `parentNode` and therefore cannot accept a value. This likely means the element containing the part was manipulated in an unsupported way outside of Lit's control such that the part's marker nodes were ejected from DOM. For example, setting the element's `innerHTML` or `textContent` can do this.");if(e=qt(this,e,t),Et(e))e===Ut||null==e||""===e?(this._$committedValue!==Ut&&(ft&&ft({kind:"commit nothing to child",start:this._$startNode,end:this._$endNode,parent:this._$parent,options:this.options}),this._$clear()),this._$committedValue=Ut):e!==this._$committedValue&&e!==At&&this._commitText(e);else if(void 0!==e._$litType$)this._commitTemplateResult(e);else if(void 0!==e.nodeType){var i;if((null===(i=this.options)||void 0===i?void 0:i.host)===e)return this._commitText("[probable mistake: rendered a template's host in itself (commonly caused by writing ${this} in a template]"),void console.warn("Attempted to render the template host",e,"inside itself. This is almost always a mistake, and in dev mode ","we render some warning text. In production however, we'll ","render it, which will usually result in an error, and sometimes ","in the element disappearing from the DOM.");this._commitNode(e)}else(e=>_t(e)||"function"==typeof(null==e?void 0:e[Symbol.iterator]))(e)?this._commitIterable(e):this._commitText(e)}_insert(e){return Ft(Ft(this._$startNode).parentNode).insertBefore(e,this._$endNode)}_commitNode(e){if(this._$committedValue!==e){if(this._$clear(),Qt!==vt){var t;const e=null===(t=this._$startNode.parentNode)||void 0===t?void 0:t.nodeName;if("STYLE"===e||"SCRIPT"===e){let t="Forbidden";throw t="STYLE"===e?"Lit does not support binding inside style nodes. This is a security risk, as style injection attacks can exfiltrate data and spoof UIs. Consider instead using css`...` literals to compose styles, and make do dynamic styling with css custom properties, ::parts, <slot>s, and by mutating the DOM rather than stylesheets.":"Lit does not support binding inside script nodes. This is a security risk, as it could allow arbitrary code execution.",new Error(t)}}ft&&ft({kind:"commit node",start:this._$startNode,parent:this._$parent,value:e,options:this.options}),this._$committedValue=this._insert(e)}}_commitText(e){if(this._$committedValue!==Ut&&Et(this._$committedValue)){const t=Ft(this._$startNode).nextSibling;void 0===this._textSanitizer&&(this._textSanitizer=St()),e=this._textSanitizer(e),ft&&ft({kind:"commit text",node:t,value:e,options:this.options}),t.data=e}else{const t=wt.createTextNode("");this._commitNode(t),void 0===this._textSanitizer&&(this._textSanitizer=St()),e=this._textSanitizer(e),ft&&ft({kind:"commit text",node:t,value:e,options:this.options}),t.data=e}this._$committedValue=e}_commitTemplateResult(e){var t;const{values:i,_$litType$:s}=e,r="number"==typeof s?this._$getTemplate(e):(void 0===s.el&&(s.el=jt.createElement(Wt(s.h,s.h[0]),this.options)),s);if((null===(t=this._$committedValue)||void 0===t?void 0:t._$template)===r)ft&&ft({kind:"template updating",template:r,instance:this._$committedValue,parts:this._$committedValue._$parts,options:this.options,values:i}),this._$committedValue._update(i);else{const e=new Jt(r,this),t=e._clone(this.options);ft&&ft({kind:"template instantiated",template:r,instance:e,parts:e._$parts,options:this.options,fragment:t,values:i}),e._update(i),ft&&ft({kind:"template instantiated and updated",template:r,instance:e,parts:e._$parts,options:this.options,fragment:t,values:i}),this._commitNode(t),this._$committedValue=e}}_$getTemplate(e){let t=Ht.get(e.strings);return void 0===t&&Ht.set(e.strings,t=new jt(e)),t}_commitIterable(e){_t(this._$committedValue)||(this._$committedValue=[],this._$clear());const t=this._$committedValue;let i,s=0;for(const r of e)s===t.length?t.push(i=new Yt(this._insert(Gt()),this._insert(Gt()),this,this.options)):i=t[s],i._$setValue(r),s++;s<t.length&&(this._$clear(i&&Ft(i._$endNode).nextSibling,s),t.length=s)}_$clear(e=Ft(this._$startNode).nextSibling,t){var i;for(null===(i=this._$notifyConnectionChanged)||void 0===i||i.call(this,!1,!0,t);e&&e!==this._$endNode;){const t=Ft(e).nextSibling;Ft(e).remove(),e=t}}setConnected(e){if(void 0!==this._$parent)throw new Error("part.setConnected() may only be called on a RootPart returned from render().");var t;this.__isConnected=e,null===(t=this._$notifyConnectionChanged)||void 0===t||t.call(this,e)}}class Zt{get tagName(){return this.element.tagName}get _$isConnected(){return this._$parent._$isConnected}constructor(e,t,i,s,r){this.type=1,this._$committedValue=Ut,this._$disconnectableChildren=void 0,this.element=e,this.name=t,this._$parent=s,this.options=r,i.length>2||""!==i[0]||""!==i[1]?(this._$committedValue=new Array(i.length-1).fill(new String),this.strings=i):this._$committedValue=Ut,this._sanitizer=void 0}_$setValue(e,t=this,i,s){const r=this.strings;let n=!1;if(void 0===r)e=qt(this,e,t,0),n=!Et(e)||e!==this._$committedValue&&e!==At,n&&(this._$committedValue=e);else{const s=e;let a,o;for(e=r[0],a=0;a<r.length-1;a++){if(o=qt(this,s[i+a],t,a),o===At&&(o=this._$committedValue[a]),n||(n=!Et(o)||o!==this._$committedValue[a]),o===Ut)e=Ut;else if(e!==Ut){var l;e+=(null!==(l=o)&&void 0!==l?l:"")+r[a+1]}this._$committedValue[a]=o}}n&&!s&&this._commitValue(e)}_commitValue(e){var t,i;e===Ut?Ft(this.element).removeAttribute(this.name):(void 0===this._sanitizer&&(this._sanitizer=Qt(this.element,this.name)),e=this._sanitizer(null!==(i=e)&&void 0!==i?i:""),ft&&ft({kind:"commit attribute",element:this.element,name:this.name,value:e,options:this.options}),Ft(this.element).setAttribute(this.name,null!==(t=e)&&void 0!==t?t:""))}}class Kt extends Zt{constructor(){super(...arguments),this.type=3}_commitValue(e){void 0===this._sanitizer&&(this._sanitizer=Qt(this.element,this.name)),e=this._sanitizer(e),ft&&ft({kind:"commit property",element:this.element,name:this.name,value:e,options:this.options}),this.element[this.name]=e===Ut?void 0:e}}class Xt extends Zt{constructor(){super(...arguments),this.type=4}_commitValue(e){ft&&ft({kind:"commit boolean attribute",element:this.element,name:this.name,value:!(!e||e===Ut),options:this.options}),Ft(this.element).toggleAttribute(this.name,!!e&&e!==Ut)}}class ei extends Zt{constructor(e,t,i,s,r){if(super(e,t,i,s,r),this.type=5,void 0!==this.strings)throw new Error(`A \`<${e.localName}>\` has a \`@${t}=...\` listener with invalid content. Event listeners in templates must have exactly one expression and no surrounding text.`)}_$setValue(e,t=this){var i;if((e=null!==(i=qt(this,e,t,0))&&void 0!==i?i:Ut)===At)return;const s=this._$committedValue,r=e===Ut&&s!==Ut||e.capture!==s.capture||e.once!==s.once||e.passive!==s.passive,n=e!==Ut&&(s===Ut||r);ft&&ft({kind:"commit event listener",element:this.element,name:this.name,value:e,options:this.options,removeListener:r,addListener:n,oldListener:s}),r&&this.element.removeEventListener(this.name,this,s),n&&this.element.addEventListener(this.name,this,e),this._$committedValue=e}handleEvent(e){var t,i;"function"==typeof this._$committedValue?this._$committedValue.call(null!==(t=null===(i=this.options)||void 0===i?void 0:i.host)&&void 0!==t?t:this.element,e):this._$committedValue.handleEvent(e)}}class ti{constructor(e,t,i){this.element=e,this.type=6,this._$disconnectableChildren=void 0,this._$parent=t,this.options=i}get _$isConnected(){return this._$parent._$isConnected}_$setValue(e){ft&&ft({kind:"commit to element binding",element:this.element,value:e,options:this.options}),qt(this,e)}}const ii=bt.litHtmlPolyfillSupportDevMode;null==ii||ii(jt,Yt),(null!==(mt=bt.litHtmlVersions)&&void 0!==mt?mt:bt.litHtmlVersions=[]).push("3.1.2"),bt.litHtmlVersions.length>1&&yt("multiple-versions","Multiple versions of Lit loaded. Loading multiple versions is not recommended.");const si=2,ri=e=>(...t)=>({_$litDirective$:e,values:t});class ni{constructor(e){}get _$isConnected(){return this._$parent._$isConnected}_$initialize(e,t,i){this.__part=e,this._$parent=t,this.__attributeIndex=i}_$resolve(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}}class li extends ni{constructor(e){if(super(e),this._value=Ut,e.type!==si)throw new Error(`${this.constructor.directiveName}() can only be used in child bindings`)}render(e){if(e===Ut||null==e)return this._templateResult=void 0,this._value=e;if(e===At)return e;if("string"!=typeof e)throw new Error(`${this.constructor.directiveName}() called with a non-string value`);if(e===this._value)return this._templateResult;this._value=e;const t=[e];return t.raw=t,this._templateResult={_$litType$:this.constructor.resultType,strings:t,values:[]}}}li.directiveName="unsafeHTML",li.resultType=1;const ai=ri(li);var oi,ui,di,hi={};!function(e){Object.defineProperty(e,"__esModule",{value:!0});var t="check",i=[],s="f00c",r="M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z";e.definition={prefix:"fas",iconName:t,icon:[512,512,i,s,r]},e.faCheck=e.definition,e.prefix="fas",e.iconName=t,e.width=512,e.height=512,e.ligatures=i,e.unicode=s,e.svgPathData=r}(hi),o.customElement("rn-result-dialog-content")(class extends u.LitElementBase{constructor(...e){super(...e),this.iconType="Success",this.buttonText="Done"}static get properties(){return{content:{type:Object},title:{type:String}}}render(){let e="success";return"Error"==this.iconType&&(e="danger"),"Warning"==this.iconType&&(e="warning"),t.html` <div> <div style="text-align: center;overflow: hidden;" class="ResultDialogIcon"> ${d.rnIf("Success"==this.iconType&&t.html` <div class="svg-box"> <svg class="circular green-stroke"> <circle class="path" cx="75" cy="75" r="50" fill="none" stroke-width="5px" stroke-miterlimit="10" /> </svg> <svg class="checkmark green-stroke"> <g transform="matrix(0.79961,8.65821e-32,8.39584e-32,0.79961,-489.57,-205.679)"> <path class="checkmark__check" fill="none" d="M616.306,283.025L634.087,300.805L673.361,261.53" /> </g> </svg> </div>`)} ${d.rnIf("Error"==this.iconType&&t.html` <div class="svg-box"> <svg class="circular red-stroke"> <circle class="path" cx="75" cy="75" r="50" fill="none" stroke-width="5px" stroke-miterlimit="10" /> </svg> <svg class="cross red-stroke"> <g transform="matrix(0.79961,8.65821e-32,8.39584e-32,0.79961,-502.652,-204.518)"> <path class="first-line" d="M634.087,300.805L673.361,261.53" fill="none" /> </g> <g transform="matrix(-1.28587e-16,-0.79961,0.79961,-1.28587e-16,-204.752,543.031)"> <path class="second-line" d="M634.087,300.805L673.361,261.53" /> </g> </svg> </div>`)} ${d.rnIf("Warning"==this.iconType&&t.html` <div class="svg-box"> <svg class="circular yellow-stroke"> <circle class="path" cx="75" cy="75" r="50" fill="none" stroke-width="5px" stroke-miterlimit="10" /> </svg> <svg class="alert-sign yellow-stroke"> <g transform="matrix(1,0,0,1,-615.516,-257.346)"> <g transform="matrix(0.56541,-0.56541,0.56541,0.56541,93.7153,495.69)"> <path class="line" d="M634.087,300.805L673.361,261.53" fill="none" /> </g> <g transform="matrix(2.27612,-2.46519e-32,0,2.27612,-792.339,-404.147)"> <circle class="dot" cx="621.52" cy="316.126" r="1.318" /> </g> </g> </svg> </div>`)} </div> ${null!=this.title&&t.html` <p class=${"ResultDialogTitle"} style="white-space: pre-wrap">${this.title}</p> `} ${d.rnIf(null!=this.content&&"string"==typeof this.content&&t.html` <div style="text-align: left;margin-top: 15px;max-height: 300px;overflow: auto" class="ResultDialogContent">${ai(this.content)}</div> `)} ${d.rnIf(null!=this.content&&"string"!=typeof this.content&&t.html` <div style="margin-top: 15px;max-height: 300px;overflow: auto" class="ResultDialogContent">${this.content}</div> `)} <div style="text-align: center;margin-top: 15px"> <button @click=${e=>{e.preventDefault(),this.FireEvent("accepted",null)}} class="rnbtn rnbtn-${e}" style="padding: 10px 34px; display: inline-flex;align-items: center;" > <rn-fontawesome .icon=${hi.faCheck} style="display: inline-flex"></rn-fontawesome> <span style="margin-left: 5px">${this.buttonText}</span> </button> </div> </div> `}}),o.customElement("rn-result-dialog")(class extends a.DialogBase{constructor(...e){super(...e),this.iconType="Success",this.buttonText="Done"}InternalGetOptions(){}SubRender(){return t.html`<rn-result-dialog-content @accepted="${e=>this.SendResult(null)}" .iconType="${this.iconType}" .title="${this.title}" .content="${this.content}" .buttonText=${this.buttonText} ></rn-result-dialog-content>`}});let ci=(oi=e.ModelSerialize("Field"),ui=class extends h.ModelWithParent{constructor(e,t){super(e,t),babelHelpers.initializerDefineProperty(this,"_field",di,this),null!=this.FormBuilder&&null!=this.Options.Field&&(this.Field=this.FormBuilder.CreateFieldModel(this.Options.Field),this.Field.Parent=this)}render(){return t.html`<rn-fbcolumn .model="${this}"></rn-fbcolumn>`}get RootFormBuilder(){return this.Parent.RootFormBuilder}get FormBuilder(){return this.Parent.FormBuilder}get Field(){return this._field}set Field(e){this._field=e,null!=e&&(e.Parent=this)}},di=babelHelpers.applyDecoratedDescriptor(ui.prototype,"_field",[oi],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),ui);var pi,mi,bi;let fi,yi=(pi=e.ModelSerialize(),mi=class extends h.ModelWithParent{constructor(e,t){super(e,t),babelHelpers.initializerDefineProperty(this,"Columns",bi,this);for(let e of this.Options.Columns)this.Columns.push(this.CreateColumnModel(e,this))}CreateColumnModel(e,t){return new ci(e,this)}render(){return t.html`<rn-fbrow .model=${this}></rn-fbrow>`}get RootFormBuilder(){return this.Parent.RootFormBuilder}get FormBuilder(){return this.Parent}AddColumn(e,t=0){e.Parent=this,this.Columns.splice(t,0,e)}InsertColumn(e,t=0){e.Parent=this,this.Columns.splice(t,0,e)}CreateColumn(e,t=null){let i=this.CreateColumnModel((new Z).Merge(e),this);return i.Parent=this,null!==t&&this.InsertColumn(i,t),i}},bi=babelHelpers.applyDecoratedDescriptor(mi.prototype,"Columns",[pi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),mi);class gi{constructor(e,t){this.Id=e,this.Message=t}}class Fi{constructor(e){this.OriginalField=e,this.ChainMeta=[],this.Id=++Fi.Id,this.ChainEnded=new n.SingleEvent}AddMeta(e,t,i=null){let s=this.ChainMeta.find((t=>t.key==e&&t.reference==i));null==s&&(s={key:e,reference:i,value:null},this.ChainMeta.push(s)),s.value=t}}Fi.Id=0;class Ii{constructor(e){this.FieldModel=e,this.AlreadyProcessedChains=[]}GetFormula(e,t=""){return this.FieldModel.Options.Formulas.find((i=>i.Name==e&&i.SubId==t))}ExecuteFormulaIfExist(e,t=null,i=""){let s=this.GetFormula(e,i);null!=s&&this.ExecuteCalculation(s,t)}UpdateOrCreateFormula(e,t,i,s,r,n,l=!1,a=""){if(""==t)return void this.RemoveFormula(e,a);let o=this.GetFormula(e,a);null==o?this.FieldModel.Options.Formulas.push((new lt).Merge({SubId:a,Name:e,Code:t,Compiled:i,PreferredReturnType:s,Fields:r,Dependencies:n,SkipFieldListener:l})):(o.SubId=a,o.Code=t,o.Compiled=i,o.PreferredReturnType=s,o.Fields=r,o.Dependencies=n,o.SkipFieldListener=l)}HasFormula(e,t=""){return null!=this.GetFormula(e,t)}RemoveFormula(e,t=""){let i=this.FieldModel.Options.Formulas.find((i=>i.Name==e&&i.SubId==t));null!=i&&this.FieldModel.Options.Formulas.splice(this.FieldModel.Options.Formulas.indexOf(i),1)}StartListener(){if(!this.FieldModel.RootFormBuilder.IsEdition())for(let e of this.FieldModel.Options.Formulas.filter((e=>!e.SkipFieldListener))){for(let t of e.Fields){let i=this.FieldModel.FormBuilder.GetFieldById(t,!1,!0);if(null==i)return void alert(`Invalid formula for field ${this.FieldModel.Options.Label+" (Id:"+this.FieldModel.Options.Id}), field with id ${t} does not exist`);i.ValueChanged.Subscribe([this,e.Name],(t=>{this.ExecuteCalculation(e,t)}))}this.ExecuteCalculation(e,new Fi(this.FieldModel))}}ExecuteCalculation(e,t=null){if(null!=t&&this.AlreadyProcessedChains.some((i=>i==e.Name+"_"+t.Id)))return;let s=i.EventManager.Publish("CalculateFormula",{FieldList:this.FieldModel.FormBuilder.GetFields(!1,!0,!0),Formula:e,Owner:this.FieldModel.FormBuilder,Chain:t,Field:this.FieldModel}),r=()=>{null!=t&&this.AlreadyProcessedChains.push(e.Name+"_"+t.Id),void 0!==this.FieldModel["Set"+e.Name]&&this.FieldModel["Set"+e.Name](s,t,e.SubId)};s instanceof Promise?(this.FieldModel.SetIsBusy(!0),s.then((e=>{this.FieldModel.SetIsBusy(!1),s=e,r()})).catch((e=>{}))):r()}GetFriendlyFormula(e,t=""){var s;return i.EventManager.Publish("GetFriendlyFormula",{Form:this.FieldModel.FormBuilder,Code:null===(s=this.GetFormula(e,t))||void 0===s?void 0:s.Code})}}class Ci{static ScrollTo(e,t){var i=e.scrollTop,s=t-i,r=0;var n=function(){var t=function(e,t,i,s){return(e/=s/2)<1?i/2*e*e+t:-i/2*(--e*(e-2)-1)+t}(r+=20,i,s,200);e.scrollTop=t,r<200&&setTimeout(n,20)};window.requestAnimationFrame(n)}}class Pi{constructor(e){this.fieldContainer=e}Compare(e,t){return!!t.GetIsVisible()&&this.InternalCompare(e,t)}GetStringValue(e,t){return""==e.PathId?t.GetText():this.GetValueByPath(e.PathId,t)}GetValue(e,t){return""==e.PathId?t.GetValue():this.GetValueByPath(e.PathId,t)}GetValueByPath(e,t){let i=t.GetValue();return null==i||null==i[e]?null:i[e]}}class vi extends Pi{InternalCompare(e,t){let i=c.Sanitizer.SanitizeString(e.Value),s=c.Sanitizer.SanitizeString(this.GetStringValue(e,t),"");switch(e.Comparison){case $.Equal:return i==s;case $.NotEqual:return i!=s;case $.IsEmpty:return""==s;case $.IsNotEmpty:return""!=s;case $.Contains:return s.toLocaleLowerCase().indexOf(i.toLocaleLowerCase())>=0;case $.NotContains:return s.toLocaleLowerCase().indexOf(i.toLocaleLowerCase())<0}}}class Si extends Pi{InternalCompare(e,t){let i=c.Sanitizer.SanitizeNumber(e.Value,null),s=c.Sanitizer.SanitizeNumber(this.GetStringValue(e,t),0);switch(e.Comparison){case $.Equal:return i==s;case $.NotEqual:return i!=s;case $.IsEmpty:return""==this.GetStringValue(e,t);case $.IsNotEmpty:return""!=this.GetStringValue(e,t);case $.GreaterThan:return s>i;case $.GreaterOrEqualThan:return s>=i;case $.LessThan:return s<i;case $.LessOrEqualThan:return s<=i}}}class xi extends Pi{InternalCompare(e,t){let i=c.Sanitizer.SanitizeStringArray(e.Value),s=c.Sanitizer.SanitizeStringArray(this.GetValue(e,t));switch(e.Comparison){case $.Contains:return s.some((e=>i.indexOf(e)>=0));case $.NotContains:return!s.some((e=>i.indexOf(e)>=0));case $.IsEmpty:return 0==s.length;case $.IsNotEmpty:return s.length>0}}}!function(e){e[e.None=0]="None",e[e.FalseFirst=1]="FalseFirst",e[e.TrueFirst=2]="TrueFirst"}(fi||(fi={}));class Oi{constructor(e){this.Id=e,this.SubscribedCallBacks=[]}}class Ti{constructor(){this.LastResult=null}GetExecuteOnFieldChange(){return!0}GetExecuteOnInitialize(){return!0}GetExecutionOrder(){return fi.None}async Initialize(e,t,i=null){if(this.FieldContainer=e,this.Condition=t,this.LastResult=null,this.GetExecuteOnFieldChange())for(let e of t.ElementsUsed)if(e.Type==L.Field){let t=this.FieldContainer.GetFieldById(e.Id,!0,!0);null!=t&&t.ValueChanged.Subscribe(this,(e=>{this.ExecuteCondition(!1,e),e.ChainEnded.Subscribe(this,(()=>this.ConditionProcessingEnded()))}))}if(this.GetExecuteOnInitialize()){let e=!1;null==i&&(e=!0,i=new Fi(null)),await this.ExecuteCondition(!0,i),e&&i.ChainEnded.Publish()}return this}GetUniqueId(){return""}async ExecuteCondition(e=!1,t=null){let i=null;return new Promise((async s=>{if(this.GetExecutionOrder()==fi.None){if(i=await this.ProcessCondition(),this.LastResult===i)return s(i);this.LastResult=i,null!=t&&t.AddMeta(this.GetUniqueId()+"_"+(i?"TrueExecuted":"FalseExecuted"),!0),i?this.ExecuteTruAction(e):this.ExecuteFalseAction(e),s(i)}else{let r=this.Condition.Type,n=Ti.ExecutionDictionary.find((e=>e.Id==r));null==n&&(n=new Oi(r),Ti.ExecutionDictionary.push(n),t.ChainEnded.Subscribe(r+"_"+this.Condition.Id,(()=>{let e=()=>{let e=e=>{null!=t&&t.AddMeta(this.GetUniqueId()+"_"+(i?"TrueExecuted":"FalseExecuted"),!0),e.Callback(),e.ConditionProcessor.LastResult=e.ResultType};this.GetExecutionOrder()==fi.FalseFirst?(n.SubscribedCallBacks.filter((e=>0==e.ResultType)).forEach(e),n.SubscribedCallBacks.filter((e=>1==e.ResultType)).forEach(e)):(n.SubscribedCallBacks.filter((e=>1==e.ResultType)).forEach(e),n.SubscribedCallBacks.filter((e=>0==e.ResultType)).forEach(e)),Ti.ExecutionDictionary.indexOf(n)>=0&&Ti.ExecutionDictionary.splice(Ti.ExecutionDictionary.indexOf(n),1)};i instanceof Promise?i.then((t=>e())):e()}))),i=this.ProcessCondition(),i.then((t=>{i=t,i?n.SubscribedCallBacks.push({ResultType:!0,Callback:()=>this.ExecuteTruAction(e),ConditionProcessor:this}):n.SubscribedCallBacks.push({ResultType:!1,Callback:()=>this.ExecuteFalseAction(e),ConditionProcessor:this}),s(i)}))}}))}ExecuteTruAction(e){}ExecuteFalseAction(e){}async ProcessCondition(){if(null!=this.Condition.Formula){let e=i.EventManager.Publish("CalculateFormula",{FieldList:this.FieldContainer.GetFields(!1,!0,!0),Formula:this.Condition.Formula,Owner:this.FieldContainer,Chain:new Fi(null)});return e instanceof Promise&&(e=await e),1==e}for(let e of this.Condition.ConditionGroups){let t=!0;for(let s of e.ConditionLines){if(null!=s.Formula&&(s.Value=i.EventManager.Publish("CalculateFormula",{FieldList:this.FieldContainer.GetFields(!1,!0,!0),Formula:s.Formula,Owner:this.FieldContainer,Chain:new Fi(null)})),!t)break;let e=null;switch(s.Type){case B.Field:e=this.FieldContainer.GetFieldById(s.FieldId,!0,!0);break;case B.Entry:case B.User:e=!0}if(null==e)return!1;switch(s.SubType){case z.Text:case"Standard":t=new vi(this.FieldContainer).Compare(s,e);break;case z.Numeric:t=new Si(this.FieldContainer).Compare(s,e);break;case z.MultipleValues:t=new xi(this.FieldContainer).Compare(s,e);break;default:let r=i.EventManager.Publish("GetRunnableComparator",{SubType:s.SubType,Container:this.FieldContainer});if(null==r)throw new Error("Invalid comparison "+s.SubType);t=r.Compare(s,e)}}if(t)return!0}return!1}ConditionProcessingEnded(){}}Ti.ExecutionDictionary=[];class Di extends Ti{async Initialize(e,t,i=null){throw Error("Invalid initialization, please use initialize with fields instead")}async InitializeWidthFields(e,t,i=null){return this.Field=e,super.Initialize(e.FormBuilder,t,i)}}class wi extends Di{ExecuteFalseAction(e){this.Condition.ShowWhenTrue?this.Field.Hide(e):this.Field.Show(e)}ExecuteTruAction(e){this.Condition.ShowWhenTrue?this.Field.Show(e):this.Field.Hide(e)}}class Gi extends Di{GetExecuteOnFieldChange(){return!1}GetExecuteOnInitialize(){return!1}ExecuteFalseAction(e){this.Condition.IsInvalidWhenTrue?this.Field.RemoveError("Validation_"+this.Condition.Id):this.Field.AddError("Validation_"+this.Condition.Id,this.Condition.InvalidMessage)}ExecuteTruAction(e){this.Condition.IsInvalidWhenTrue?this.Field.AddError("Validation_"+this.Condition.Id,this.Condition.InvalidMessage):this.Field.RemoveError("Validation_"+this.Condition.Id)}}function Ei(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,s)}return i}class _i extends h.ModelWithParent{constructor(e,t){super(e,t),this.IsVisible=!0,this.IsFieldContainer=!1,this.IsFieldWithPrice=!1,this.IsPriceField=!1,this.IsField=!0,this.FieldIsBusy=!1,this.DisableFireValueChanged=!1,this.Meta={},this.Errors=[],this.ImmediateAnimation=!0,this.IsFocused=!1,this.ValueChanged=new n.SingleEvent,this.FormulaManager=new Ii(this),this.Conditions=[]}SetIsBusy(e){this.FieldIsBusy=e,this.Refresh()}GetIsBusy(){return this.FieldIsBusy}get Instance(){return this._instance}set Instance(e){this._instance=e}get IsHiddenTypeOfField(){return!1}get RootFormBuilder(){return this.Parent.RootFormBuilder}get FormBuilder(){var e;return null===(e=this.Parent)||void 0===e?void 0:e.FormBuilder}GetAS(e,t=null){return c.Sanitizer.GetValueFromPath(this.Options,["AS",...e.split(".")],t)}async Initialize(e=null){let t=this.GetAS("Meta");null!=t&&(this.Meta=JSON.parse(JSON.stringify(t)));let i=this.GetPreviousDataProperty("Meta",null);return null!=i&&(this.Meta=function(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?Ei(Object(i),!0).forEach((function(t){babelHelpers.defineProperty(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):Ei(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}({},this.Meta,{},i.Meta)),this.InitializeStartingValues(e),this}GetStoresInformation(){return!0}get IsDesign(){var e;return null==this.Parent||(null===(e=this.RootFormBuilder)||void 0===e?void 0:e.IsDesign)}InitializeFormulas(){null==this.Parent||this.IsDesign||this.FormulaManager.StartListener()}SetMeta(e,t,i){this.Meta[i]!=e&&(this.Meta[i]=e,this.FireValueChanged())}GetMeta(e,t=""){var i;return this.GetIsUsed()&&null!==(i=this.Meta[e])&&void 0!==i?i:t}GetHtml(){let e=this.GetText().split("\n"),i=[];for(let s of e)i.push(s),i.push(t.html`<br />`);return i}async InitializeConditions(){let e=new Fi(this);this.InitializeFormulas();for(let t of this.Options.Conditions)switch(t.Type){case"ShowHide":this.Conditions.push(await(new wi).InitializeWidthFields(this,t,e));break;case"Validation":this.Conditions.push(await(new Gi).InitializeWidthFields(this,t,e));break;default:let s=i.EventManager.Publish("GetConditionProcessor",{Type:t.Type});if(null==s)throw new Error(`Condition processor ${t.Type} not found`);this.Conditions.push(await s.InitializeWidthFields(this,t,e))}e.ChainEnded.Publish(),this.Options.Behaviors.forEach((e=>i.EventManager.Publish("InitializeBehavior",{Field:this,Options:e})))}get IsReadonly(){var e,t;return null==this.FormBuilder||!1===(null===(e=this.RootFormBuilder.AdditionalOptions)||void 0===e||null===(t=e.EditOptions)||void 0===t?void 0:t.AllowEdition)}GetIsValid(e=!1){return!this.GetIsVisible()||0==(e?this.Errors.filter((e=>"required"!=e.Id)):this.Errors).length}RemoveError(e){let t=this.Errors.find((t=>t.Id==e));null!=t&&(this.Errors.splice(this.Errors.indexOf(t),1),this.FireValueChanged())}GetIsUsed(){return this.GetIsVisible()&&this.GetIsValid(!0)}GetIsVisible(){return(null==this.RootFormBuilder||null==this.Row||null==this.RootFormBuilder.MultipleStepsModel||!this.RootFormBuilder.MultipleStepsModel.IsStepHidden(this.Row.Options.StepId))&&this.IsVisible}get Row(){return this.Parent.Parent}get Column(){return this.Parent}Focus(){this.IsFocused=!0,this.Refresh()}UnFocus(){this.IsFocused=!1,this.Refresh()}Show(e=!1){var t;0==this.IsVisible&&(this.ImmediateAnimation=e,this.IsVisible=!0,this.FireValueChanged(),null===(t=this.Parent)||void 0===t||t.Refresh())}Hide(e=!1){var t;1==this.IsVisible&&(this.ImmediateAnimation=e,this.IsVisible=!1,this.FireValueChanged(),null===(t=this.Parent)||void 0===t||t.Refresh())}GetAdditionalClasses(){return[]}FireValueChanged(e=null){var t;if(this.DisableFireValueChanged)return;let i=e;null==e&&(e=new Fi(this)),this.GetIsUsed()&&this.RemoveError("required"),null===(t=this.FormBuilder)||void 0===t||t.FieldValueChanged.Publish(this),null!=this.FormBuilder&&null!=this.FormBuilder.FireValueChanged&&this.FormBuilder.FireValueChanged(e),this.ValueChanged.Publish(e),null==i&&e.ChainEnded.Publish(e),this.Refresh()}GetPrice(){return 0}GetText(){return""}GetNumber(){let e=this.GetText();if(""==e)return 0;let t=Number(e);return isNaN(t)?0:t}GetPriceWithoutFormula(){return 0}AddError(e,t){this.Errors.some((t=>t.Id==e))||(this.Errors.push(new gi(e,t)),this.FireValueChanged(),this.Refresh())}async Validate(){this.RemoveError("required"),this.Options.Required&&!this.GetIsUsed()&&this.AddError("required",this.RootFormBuilder.Options.ClientOptions.RequiredMessage);for(let e of this.Conditions.filter((e=>"Validation"==e.Condition.Type)))await e.ExecuteCondition();return this.GetIsValid()}ScrollToField(){if(null==this.Instance)return;let e=this.Instance.getBoundingClientRect();(e.top<0||e.top>document.documentElement.clientHeight)&&Ci.ScrollTo(document.documentElement,document.documentElement.scrollTop+e.top-100)}SerializeEntry(){let e={Label:this.Options.Label,Id:this.Options.Id,Type:this.Options.Type};return Object.getOwnPropertyNames(this.Meta).length>0&&(e.Meta=this.Meta),this.InternalSerialize(e),e}GetValue(){return null}GetPreviousData(){if(null==this.FormBuilder)return null;let e=this.FormBuilder.PreviousData;return null==e||null==e.Fields?null:e.Fields.find((e=>e.Id==this.Options.Id))}GetPreviousDataProperty(e,t){let i=this.GetPreviousData();if(null==i)return t;if(""==e)return i;let s=e.split(","),r=i;for(let e of s){if(void 0===r[e])return t;r=r[e]}return r}ParseFixedField(e,t,i){return null!=this.FormBuilder?this.FormBuilder.ParseFixedField(e,t,i):""}GetFixedValue(e){return""}}class Ri{constructor(e){this.FormBuilder=e,this.UnitPrice=0,this.Quantity=0,this.OptionsTotal=0,this.DiscountTotal=0,this.TotalUpdated=new n.SingleEvent,this.GrandTotal=0,this.OptionsTotal=0,this.UnitPrice=0,this.FieldPriceUpdated=new n.SingleEvent,this.RecalculateTotal=this.RecalculateTotal.bind(this)}AddField(e){null!=e.Calculator&&(e.Calculator.PriceUpdated.Subscribe(this,this.RecalculateTotal),this.FieldPriceUpdated.Publish(e),this.RecalculateTotal(e))}RemoveField(e){null!=e.Calculator&&(e.Calculator.PriceUpdated.Unsubscribe(this),this.RecalculateTotal(e))}RecalculateTotal(e){null!=e&&this.FieldPriceUpdated.Publish(e);let t=this.GrandTotal,i=this.Quantity,s=this.DiscountTotal;this.UnitPrice=this.CalculateUnitPrice();let r=this.GetFields().find((e=>{var t;return e.Options.PriceType==ot.quantity||e.Options.PriceType==ot.quantity_per_day||(null===(t=e.Calculator)||void 0===t?void 0:t.CanCalculateQuantity())}));this.Quantity=null==r?1:r.Calculator.GetQuantity(),this.DiscountTotal=this.CalculateDiscount(),this.BeforeCalculatingGrandTotal(),this.GrandTotal=(this.UnitPrice-this.DiscountTotal)*this.Quantity,t==this.GrandTotal&&this.Quantity==i&&this.DiscountTotal==s||(this.TotalUpdated.Publish(this.GrandTotal),null!=this.FormBuilder.Calculator&&this.FormBuilder.Calculator.PriceUpdated.Publish(this))}BeforeCalculatingGrandTotal(){}CalculateDiscount(){return this.GetFields("D").reduce(((e,t)=>{var i;return e+(null===(i=t.Calculator)||void 0===i?void 0:i.GetPrice())}),0)}CalculateUnitPrice(){return this.GetFields().reduce(((e,t)=>{var i;return e+(null===(i=t.Calculator)||void 0===i?void 0:i.GetPrice())}),0)}GetFields(e="P"){return this.FormBuilder.GetFields(!1,!1,!1).filter((t=>"P"==e?t.IsFieldWithPrice&&(null==t.Calculator||0==t.Calculator.IsDiscount):null!=t.Calculator&&1==t.Calculator.IsDiscount))}GetPriceIgnoringFields(e){let t=0;for(let i of this.GetFields())i.Calculator.IsDynamic()||e.find((e=>e.Options.Id==i.Options.Id))||(t+=i.Calculator.GetPrice());return t}GetPrice(e){let t=this.GetFields().find((t=>t==e));return null==t?0:t.Calculator.GetPrice()}GetQuantity(){return this.Quantity}GetUnitPrice(){return this.UnitPrice}GetOptionsTotal(){return this.OptionsTotal}GetGrandTotal(){return this.GrandTotal}GetDiscountTotal(){return this.DiscountTotal}}var Mi;let Vi=o.customElement("rn-form-builder")(Mi=class extends m.LitModel{get properties(){return{model:{type:Object}}}GetParentStyles(){return{display:"inline-block"}}async firstUpdated(e){super.firstUpdated(e),await this.updateComplete,this.model.IsLoaded=!0,this.model.Instance=this.renderRoot,this.model.OnLoad.Publish()}render(){return t.html` ${p.repeat([1],(e=>this.model.InternalId),(e=>t.html` <div class="form_${this.model.FormId} rednaoForm rednao ${this.model.Options.ClientOptions.Theme}" style="position: relative"> <style type="text/css"> ${this.model.Options.ClientOptions.Styles} </style> ${null!=this.model.MultipleStepsModel?this.model.MultipleStepsModel.RenderFormContainer():this.model.RenderRows()} </div> `))} `}})||Mi;function $i(t){var s,r,l;return s=e.ModelSerialize(),r=class extends t{constructor(...e){super(...e),babelHelpers.initializerDefineProperty(this,"Rows",l,this),this.IsFieldContainer=!0,this.Rows=[],this.FieldValueChanged=new n.SingleEvent,this.PriceManager=this.CreatePriceManager()}CreatePriceManager(){return new Ri(this)}GetId(){return this.Options.Id}get RootFormBuilder(){return null==this.Parent?this:this.Parent.RootFormBuilder}get FormBuilder(){return null==this.Parent||null==this.Parent.FormBuilder?null:this.Parent.FormBuilder}GetFields(e=!1,t=!1,i=!0){let s=[];for(let t of this.Rows)for(let r of t.Columns){let t=r.Field;if(s.push(t),t.Options.IsFieldContainer&&t.Options.Type!=nt.Repeater&&t.Options.Type!=nt.RepeaterItem&&i)for(let e of t.GetFields(!1,!1,!0))s.push(e);if(e&&(t.Options.Type==nt.Repeater||t.Options.Type==nt.RepeaterItem))for(let e of t.GetFields(!0))s.push(e)}return t&&null!=this.FormBuilder&&(s=s.concat(this.FormBuilder.GetFields(!1,!0).filter((e=>!s.some((t=>e.Options.Id==t.Options.Id)))))),s}GetFieldById(e,t=!1,i=!1,s=!1){for(let i of this.GetFields(!1,!1,!1)){if(i.Options.Id==e)return i;if((t||s)&&1==i.IsFieldContainer&&(i=i.GetFieldById(e,t,!1,s),null!=i))return i}if(i){let t=this.FormBuilder;for(;null!=t;){let i=t.GetFields(!1,!1,!1).filter((e=>e!=this));for(let t of i){if(t.Options.Id==e)return t;if(t.IsFieldContainer&&(t=t.GetFieldById(e,!1,!1,!1),null!=t))return t}t=t.FormBuilder}}return null}CreateFieldOptions(e){let t=e;null!=e.Type&&(t=e.Type);let s=i.EventManager.Publish("GetFieldOptions",t);if(null==s)throw Error("Field options type not found "+t);return s.Merge(null!=e.Id?e:null),s}CreateFieldModel(e){let t=i.EventManager.Publish("GetFieldModel",{Options:e,Parent:null});if(null==t)throw new Error("Model type not found "+e.Type);return t}CreateFieldOptionsAndModel(e){let t=this.CreateFieldOptions(e);return this.CreateFieldModel(t)}CreateRowModel(e,t){return new yi(e,t)}CreateRow(e,t=null,i=0){let s=this.CreateRowModel((new se).Merge(e),this);return s.Options.StepId=i,null!==t&&this.InsertRow(s,t),s}ExecuteFirstCalculation(){this.GetFields(!1,!1,!1).forEach((e=>{if(1==e.IsFieldWithPrice){null!=e.ExecuteFirstCalculation&&e.ExecuteFirstCalculation();let t=e;if(null==t.Calculator)return;t.Calculator.GetDependsOnOtherFields()||t.Calculator.ExecuteAndUpdate(),t.Calculator.GetDependsOnOtherFields()&&t.Calculator.ExecuteAndUpdate()}}))}InsertRow(e,t){this.Rows.splice(t,0,e)}async Validate(){let e=!0;this.LastFieldWithErrors=null;let t=[];if(this.IsField&&!this.GetIsVisible())return!0;this.IsField&&(await super.Validate()||(e=!1));for(let i of this.GetFields(!1,!1,!1)){let s=await i.Validate();s instanceof Promise?t.push({Promise:s,Field:i}):s||(e=!1,null==this.LastFieldWithErrors&&(this.LastFieldWithErrors=i))}if(!e)return!1;for(let i of t)await i.Promise||(e=!1,null==this.LastFieldWithErrors&&(this.LastFieldWithErrors=i.Field));return e}async Initialize(){return this instanceof _i&&this.InitializeStartingValues(this.PreviousData),this.GetFields(!1,!1,!1).forEach((async e=>await e.Initialize(this.PreviousData))),this.RootFormBuilder.IsDesign||(this.GetFields(!1,!1,!1).forEach((async e=>{e.IsFieldContainer||await e.InitializeConditions()})),this instanceof _i&&await this.InitializeConditions()),this.GetFields().forEach((e=>{e.IsFieldWithPrice&&e.Options.PriceType!=ot.none&&this.PriceManager.AddField(e)})),this.RootFormBuilder.IsDesign||this.PriceManager.RecalculateTotal(null),this}ParseFixedField(e,t,s){if(!0===c.Sanitizer.GetValueFromPath(t,["FC"]))return i.EventManager.Publish("CallFixedFunction",{Id:e,Op:t,FieldContainer:null!=s?s.FormBuilder:this});let r=c.Sanitizer.GetValueFromPath(t,["Id"]),n=c.Sanitizer.GetValueFromPath(this,["RootFormBuilder","AdditionalOptions","Attributes",e+(""==r?"":"_"+r)]);return null==n?"":n}},l=babelHelpers.applyDecoratedDescriptor(r.prototype,"Rows",[s],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),r}class zi extends($i(e.ModelBase)){constructor(e,t,i={}){super(t),this.FormId=e,this.IsLoaded=!1,this.InternalId=1,this.EntryId="",this.ReferenceId="",this.RunnableAddOns=[],this.AdditionalOptions=i,this.OnLoad=new n.SingleEvent,this.BeforeSubmit=new n.SingleEvent;for(let e of t.Rows)this.Rows.push(this.CreateRowModel(e,this));null!=i.PreviousData&&(this.PreviousData=i.PreviousData,void 0!==i.PreviousData.EntryId&&(this.EntryId=i.PreviousData.EntryId),void 0!==i.PreviousData.ReferenceId&&(this.ReferenceId=i.PreviousData.ReferenceId),this.Status=i.PreviousData.Status)}render(){return t.html`<rn-form-builder .model="${this}"></rn-form-builder>`}SetAddOns(e){this.RunnableAddOns=e}GetIcon(e){return this.Options.ClientOptions.Icons.find((t=>t.Name==e))}set HideSubmitButton(e){null!=this.AdditionalOptions&&(this.AdditionalOptions.HideSubmitButton=e,this.Refresh())}get HideSubmitButton(){var e;return!0===(null===(e=this.AdditionalOptions)||void 0===e?void 0:e.HideSubmitButton)}async Initialize(){return this.ExecuteAddOnMethod("BeforeInit"),await super.Initialize(),i.EventManager.Publish("LoadExtensionOptions",{Model:this}),this.ExecuteAddOnMethod("AfterInit"),this.InitializeFormModel(),this}ExecuteFirstCalculation(){if(super.ExecuteFirstCalculation(),""!=this.Options.ClientOptions.Javascript&&!this.IsDesign){new Function(this.Options.ClientOptions.Javascript).apply(this)}}ExecuteAddOnMethod(e,t=null){this.RunnableAddOns.forEach((i=>i[e].apply(i,t)))}get IsDesign(){return!1}get IsEntry(){return!1}GetHTML(e,t,s){return i.EventManager.Publish("GetHTML",{HTML:t[s],FormBuilder:this})}SerializeEntry(){let e={Entry:{}};e.Entry.FormId=this.AdditionalOptions.FormId,e.Entry.Data=[];for(let t of this.GetFields(!1,!1,!1))t.GetStoresInformation()&&t.GetIsUsed()&&e.Entry.Data.push(t.SerializeEntry());return e.Entry.Total=this.PriceManager.GetGrandTotal(),e.Entry.Quantity=this.PriceManager.GetQuantity(),e.Entry.Status=this.Status,e.Entry.FormId=this.AdditionalOptions.FormId,e}async Save(){try{if(!await this.Validate())return void this.LastFieldWithErrors.ScrollToField()}catch(e){return}let e=this.SerializeEntry(),i={};for(let e of this.GetFields(!0,!1,!0)){if(null==e.GetFiles)continue;e.GetFiles().forEach((e=>i[e.Id]=e.File))}let r="form_submitted";var n;this.IsEdition()?(r="entry_edited",e.EntryId=this.EntryId,e.ReferenceId=this.ReferenceId,e.Nonce=null===(n=this.PreviousData)||void 0===n?void 0:n.EditNonce):e.RequestURL=document.URL;for(let t of this.RunnableAddOns){if(0==await t.BeforeSubmit(r,e,i))return}if(!this.AdditionalOptions.QuickPreview)return await this.SubmitForm(r,e,i);s.Dialog.Show(t.html`<rn-result-dialog .iconType="${"Error"}" .title="${this.AdditionalOptions.QuickPreviewTitle}" .content="${this.AdditionalOptions.QuickPreviewMessage}" .buttonText=${RNTranslate("Done")} ></rn-result-dialog>`)}async SubmitForm(e,i,n){if(!1===this.BeforeSubmit.Publish({Data:i}))return;let l=await r.WpAjaxPost.Post(e,i,"",n,{OnError:(e,i)=>{let r=e;1==this.Options.ClientOptions.EnableDebug&&(r=t.html`<div> <span>${e}</span> <span style="display: block;text-align: left;font-weight: bold;margin-top: 30px">Additional Details</span> <pre style="width: 100%;overflow: auto;height: 200px;display: block;text-align: left;border: 1px solid #dfdfdf;padding: 0;"> ${i} </pre > </div>`),s.Dialog.Show(t.html`<rn-result-dialog .iconType="${"Error"}" .title="${RNTranslate("Sorry, an error occurred")}" .content="${r}" .buttonText="${RNTranslate("Done")}"></rn-result-dialog>`)}});return null!=l&&(await this.MaybeExecuteAConfirmation(l),this.IsEdition()?l.Entry:(null!=this.PreviousData&&(this.PreviousData.Data=[]),void(l.success&&(this.ExecuteAddOnMethod("AfterSubmit"),this.PreviousData={},this.ClearForm()))))}async MaybeExecuteAConfirmation(e){if(null!=e.Action)switch(e.Action.Type){case"message":if(await s.Dialog.Show(t.html` <rn-result-dialog .content="${e.Action.Content}" .title="${e.Action.Title}" .buttonText="${e.Action.ButtonText}" .iconType="${e.Action.IconType}" ></rn-result-dialog>`),null!=e.Action.RedirectURL&&""!=e.Action.RedirectURL)return void(window.location.href=e.Action.RedirectURL);break;case"redirect":return document.location.href=e.Action.URL,new Promise((e=>{}))}for(let t of this.RunnableAddOns){let i=t.ProcessConfirmation(e);if(null!==i)return i}}async ClearForm(){this.Rows=[],this.PriceManager=new ht(this);for(let e of this.Options.Rows)this.Rows.push(this.CreateRowModel(e,this));await this.Initialize(),this.ExecuteFirstCalculation(),this.InternalId++,this.Refresh()}async InitializeFormModel(){null!=this.Options.ClientOptions.MultipleSteps?(this.MultipleStepsModel=i.EventManager.Publish("GetMultipleStepsModel",{Model:this}),await this.MultipleStepsModel.Initialize()):this.MultipleStepsModel=null}IsEdition(){return""!=this.EntryId&&""!=this.ReferenceId}RenderRows(e=null){return null==e&&(e=this.Rows),p.repeat(e,(e=>e.Options.Id),(e=>e.render()))}}var Bi;let Ni=o.customElement("rn-fbrow")(Bi=class extends m.LitModel{get properties(){return{model:{type:Object}}}GetParentClasses(){return"rnRow rnRow_"+this.model.Options.Id}GetParentStyles(){return{width:"100%",display:"flex"}}render(){return t.html` ${p.repeat(this.model.Columns,(e=>e.Options.Id),(e=>e.render()))} `}firstUpdated(e){super.firstUpdated(e),this.model.Instance=this}})||Bi;var Li;let Ai=o.customElement("rn-fbcolumn")(Li=class extends m.LitModel{static get properties(){return{model:{type:Object}}}firstUpdated(e){super.firstUpdated(e),this.model.Instance=this}GetParentStyles(){return{width:this.model.Options.WidthPercentage+"%"}}disconnectedCallback(){super.disconnectedCallback(),this.model.Instance=this}render(){let e=!this.model.Field.IsVisible||this.model.Field.IsHiddenTypeOfField&&(!this.model.RootFormBuilder.IsDesign||this.model.Field.Options.Type==nt.SubmitButton);return this.style.display=e?"none":"inline-flex",t.html` ${this.model.Field.render()} `}})||Li;var Ui={};!function(e){Object.defineProperty(e,"__esModule",{value:!0});var t="question-circle",i=[],s="f059",r="M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zM262.655 90c-54.497 0-89.255 22.957-116.549 63.758-3.536 5.286-2.353 12.415 2.715 16.258l34.699 26.31c5.205 3.947 12.621 3.008 16.665-2.122 17.864-22.658 30.113-35.797 57.303-35.797 20.429 0 45.698 13.148 45.698 32.958 0 14.976-12.363 22.667-32.534 33.976C247.128 238.528 216 254.941 216 296v4c0 6.627 5.373 12 12 12h56c6.627 0 12-5.373 12-12v-1.333c0-28.462 83.186-29.647 83.186-106.667 0-58.002-60.165-102-116.531-102zM256 338c-25.365 0-46 20.635-46 46 0 25.364 20.635 46 46 46s46-20.636 46-46c0-25.365-20.635-46-46-46z";e.definition={prefix:"fas",iconName:t,icon:[512,512,i,s,r]},e.faQuestionCircle=e.definition,e.prefix="fas",e.iconName=t,e.width=512,e.height=512,e.ligatures=i,e.unicode=s,e.svgPathData=r}(Ui);var Hi,ki={};!function(e){Object.defineProperty(e,"__esModule",{value:!0});var t="spinner",i=[],s="f110",r="M304 48c0 26.51-21.49 48-48 48s-48-21.49-48-48 21.49-48 48-48 48 21.49 48 48zm-48 368c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zm208-208c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zM96 256c0-26.51-21.49-48-48-48S0 229.49 0 256s21.49 48 48 48 48-21.49 48-48zm12.922 99.078c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.491-48-48-48zm294.156 0c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.49-48-48-48zM108.922 60.922c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.491-48-48-48z";e.definition={prefix:"fas",iconName:t,icon:[512,512,i,s,r]},e.faSpinner=e.definition,e.prefix="fas",e.iconName=t,e.width=512,e.height=512,e.ligatures=i,e.unicode=s,e.svgPathData=r}(ki);class Qi extends m.LitModel{static get properties(){return{model:{type:Object}}}GetParentStyles(){return{display:"flex"}}GetParentClasses(){let e=super.GetParentClasses();return""!=e&&(e+=" "),e+="rnFieldContainer",e}disconnectedCallback(){super.disconnectedCallback()}connectedCallback(){this.model.Instance=this,super.connectedCallback()}render(){return this.GetWrapper(t.html` <div class=${this.model.Options.ClassName+" "+this.model.GetAdditionalClasses().join(" ")+(this.model.GetIsBusy()?"isBusy ":"")+" rnField rnField_"+this.model.Options.Id+" rn"+this.model.Options.Type+" "+(this.model.GetIsValid()?"":"rnInvalid")+(this.model.IsFocused?" RNFocus":"")} > ${d.rnIf(this.model.GetIsBusy()&&t.html`<div class="isBusyContainer"><rn-fontawesome .icon="${ki.faSpinner}" .spin="${!0}"></rn-fontawesome></div>`)} <div class="rnFieldAndLabel"> ${this.GetLabel()} <div class="rnFieldContainer">${this.SubRender()}</div> ${this.AfterField()} ${d.rnIf(!this.model.GetIsValid()&&t.html` <span class="rnValidationMessage"> ${this.model.Errors[0].Message} </span> `)} </div> ${d.rnIf(null!=this.model.Options.Description&&(this.model.GetIsUsed()||"WhenFilled"!=this.model.GetAS("ShowDesc"))&&t.html`<div class="description">${this.model.RootFormBuilder.GetHTML(this.model,this.model.Options,"Description").Code}</div>`)} </div> `)}GetText(e,t){let i=e[t];return this.model.RootFormBuilder.IsDesign?i:_rnt(i)}GetLabel(e=null,i="",s=!1){return null==e&&(e=this.model.Options,i="Label",this.model.Options.HideLabel&&!this.model.RootFormBuilder.IsDesign)?null:""!=e[i]?t.html` <div class="rednaoLabel" style="margin-bottom: 5px;display: block;"> <label style="display: inline-block" >${this.GetText(e,i)} ${d.rnIf(null!=this.model.Options.Tooltip&&!s&&this.MaybeCreateTooltip())} ${d.rnIf(this.model.Options.Required&&t.html`<span class="rnRequiredInd">*</span>`)} </label> </div> `:null}GetWrapper(e){return e}MaybeCreateTooltip(){let e=i.EventManager.Publish("GetHTML",{HTML:this.model.Options.Tooltip,FormBuilder:this.model.FormBuilder});return null==e.Code?null:t.html`<rn-tooltip .tooltip="${e.Code}" .content="${t.html`<rn-fontawesome .icon="${Ui.faQuestionCircle}"></rn-fontawesome>`}" class="rnTooltip" style="cursor:pointer;margin-left: 3px" ></rn-tooltip>`}AfterField(){return null}}o.customElement("rn-icon-displayer")(class extends u.LitElementBase{constructor(...e){super(...e),this.size="18px"}static get properties(){return{}}GetParentStyles(){return{display:"inline-flex"}}render(){if("icon"==this.icon.ImageType){let e=null;e=null!=this.formBuilder.RootFormBuilder?this.formBuilder.RootFormBuilder.GetIcon(this.icon.Ref.Name):e.Ref;let i=this.style.color;return""==i&&(i="inherit"),t.html` <div class="RNIconOrImage" style="display:inline-flex;align-items: center;justify-content: center; height:100%;color: ${i};top:0;left: 3px" > <rn-fontawesome .icon=${e}></rn-fontawesome> </div> `}if("image"==this.icon.ImageType)return t.html` <div style="width:100%;display:flex;align-items:center;justify-content:center;height:100%;color:white;font-size:18px"> <img style="width: ${this.size};height: ${this.size};" src=${this.icon.Ref.URL} alt={''}/> </div> `}});class Wi extends ut{constructor(...e){super(...e),this.Hide=!1}LoadDefaultValues(){super.LoadDefaultValues(),this.Type=nt.SubmitButton,this.Label="Submit",this.Icon=(new _e).Merge(),this.Hide=!1}}class ji extends _i{InitializeStartingValues(e){}get IsHiddenTypeOfField(){return this.RootFormBuilder.HideSubmitButton}GetStoresInformation(){return!1}render(){return t.html`<rn-submit-button .model="${this}"></rn-submit-button>`}InternalSerialize(e){}}i.EventManager.Subscribe("GetFieldOptions",(e=>{if(e==nt.SubmitButton)return new Wi})),i.EventManager.Subscribe("GetFieldModel",(e=>{if(e.Options.Type==nt.SubmitButton)return new ji(e.Options,e.Parent)}));let qi=o.customElement("rn-submit-button")(Hi=class extends Qi{constructor(...e){super(...e),this.isBusy=!1}static get properties(){return{isBusy:{type:Boolean}}}SubRender(){return t.html` <rn-spinner-button .isBusy="${this.isBusy}" @click="${e=>this.Click()}" class="primary" .label="${this.GetText(this.model.Options,"Label")}" .icon="${d.rnIf("none"!=this.model.Options.Icon.ImageType&&t.html` <rn-icon-displayer style="margin-right: 3px" .icon="${this.model.Options.Icon}" .formBuilder="${this.model.RootFormBuilder}"></rn-icon-displayer> `)}" > </rn-spinner-button> `}GetLabel(e="",t,i=!1){return null}async Click(){this.isBusy=!0,await this.model.RootFormBuilder.Save(),this.isBusy=!1}})||Hi;class Ji extends Qi{AfterField(){return 0==this.model.GetPrice()||null==this.model.GetPrice()||this.model.Options.HidePrice||this.model.Options.PriceType==ot.none||"basic"==this.model.Options.PriceType?null:t.html` <rn-price .amount="${this.model.GetPrice()}"></rn-price> `}}class Yi{constructor(){this.IsDiscount=!1,this.PriceUpdated=new n.SingleEvent,this.Price=null,this.RegularPrice=null,this.Quantity=0,this.RequireInstanceToCalculate=!1,this.ExecuteCalculation=this.ExecuteCalculation.bind(this)}CanCalculateQuantity(){return!1}GetDependsOnOtherFields(){return!1}GetUnitPrice(){return this.UnitPrice}Destroy(){this.PriceUpdated.Unsubscribe(this),this.Field.ValueChanged.Unsubscribe(this)}Initialize(e){return this.InitializeFieldOnly(e),this}GetForceUpdateWhenFieldChange(){return!1}InitializeFieldOnly(e){return this.Field=e,this}async ExecuteAndUpdate(e=!1,t=!1,i=null){let s=this.ExecuteCalculation(null,null),r=!1;if(s instanceof Promise){try{s=await s}catch(e){return}r=!0}let n=this.UpdatePrice(s.RegularPrice,s.Quantity,e,t,i);return r&&this.Field.Refresh(),n}GetIsUsed(){return this.Field.GetIsUsed()}GetPrice(){return this.GetIsUsed()?this.Price:0}GetSelectedValues(){}SerializeItem(e){}GetQuantity(){return this.GetIsUsed()?Math.max(1,this.Quantity):Math.max(0,this.Quantity)}SetQuantity(e){let t=this.Quantity;this.Quantity=e,t!=e&&this.ExecuteAndUpdate(!0)}IsDynamic(){return!1}GetRegularPrice(){return this.RegularPrice}UpdatePrice(e,t=0,i=!1,s=!1,r=null){let n=this.GetIsUsed(),l=this.Price,a=this.Quantity,o=""==e?0:e;if(this.Quantity=t,""===e)this.Price=0,this.Field.Quantity=t,this.UnitPrice=0;else{let i=c.Sanitizer.SanitizeNumber(e,0);this.UnitPrice=i,this.Price=i*t,this.RegularPrice=i*t}if(i||this.GetQuantity()!=a||o!==l||n!=this.GetIsUsed())return this.PriceUpdated.Publish(this.Field),s||this.Field.FireValueChanged(),!0}}class Zi extends Yi{constructor(){super(),this.Quantity=null,this.CustomRegularPrice=null}SetQuantity(e){return this.Quantity=e,this}SetRegularPrice(e){return this.CustomRegularPrice=e,this}ExecuteCalculation(e){null==e&&(e=this.Field.GetValue());let t=null!=this.CustomRegularPrice?this.CustomRegularPrice:this.Field.Options.Price;return isNaN(e)&&e.length>0||!isNaN(e)&&e>0||this.Field.Options.Type==nt.DateRange&&null!=e||this.Field.Options.Type==nt.GoogleMaps&&null!=e||this.Field.Options.Type==nt.TextualImage&&null!=e?{RegularPrice:t,Quantity:this.GetQuantity()}:{RegularPrice:"",Quantity:0}}ParseNumber(e){let t=parseFloat(e);return isNaN(t)?0:t}}class Ki extends Yi{InternalInstanceUpdated(e){}ExecuteCalculation(){return{RegularPrice:"",SalePrice:"",Quantity:this.GetQuantity()}}}class Xi{constructor(){this.IsDiscount=!1,this.PriceUpdated=new n.SingleEvent,this.Price=null,this.RegularPrice=null,this.Quantity=0,this.RequireInstanceToCalculate=!1,this.ExecuteCalculation=this.ExecuteCalculation.bind(this)}CanCalculateQuantity(){return!1}GetDependsOnOtherFields(){return!1}GetUnitPrice(){return this.UnitPrice}Destroy(){this.PriceUpdated.Unsubscribe(this),this.Field.ValueChanged.Unsubscribe(this)}Initialize(e){return this.InitializeFieldOnly(e),this}GetForceUpdateWhenFieldChange(){return!1}InitializeFieldOnly(e){return this.Field=e,this}async ExecuteAndUpdate(e=!1,t=!1,i=null){let s=this.ExecuteCalculation(null,null),r=!1;if(s instanceof Promise){try{s=await s}catch(e){return}r=!0}let n=this.UpdatePrice(s.RegularPrice,s.Quantity,e,t,i);return r&&this.Field.Refresh(),n}GetIsUsed(){return this.Field.GetIsUsed()}GetPrice(){return this.GetIsUsed()?this.Price:0}GetSelectedValues(){}SerializeItem(e){}GetQuantity(){return this.GetIsUsed()?Math.max(1,this.Quantity):Math.max(0,this.Quantity)}SetQuantity(e){let t=this.Quantity;this.Quantity=e,t!=e&&this.ExecuteAndUpdate(!0)}IsDynamic(){return!1}GetRegularPrice(){return this.RegularPrice}UpdatePrice(e,t=0,i=!1,s=!1,r=null){let n=this.GetIsUsed(),l=this.Price,a=this.Quantity,o=""==e?0:e;if(this.Quantity=t,""===e)this.Price=0,this.Field.Quantity=t,this.UnitPrice=0;else{let i=c.Sanitizer.SanitizeNumber(e,0);this.UnitPrice=i,this.Price=i*t,this.RegularPrice=i*t}if(i||this.GetQuantity()!=a||o!==l||n!=this.GetIsUsed())return this.PriceUpdated.Publish(this.Field),s||this.Field.FireValueChanged(),!0}}class es extends Xi{constructor(){super(),this.OptionsTotal=[]}InitializeFieldOnly(e){return super.InitializeFieldOnly(e),this.Field.FormBuilder.PriceManager.FieldPriceUpdated.Subscribe(this,(e=>{e!=this.Field&&this.Field.GetSelectedOptions()})),this}ExecuteCalculation(e){this.OptionsTotal=[];let t=this.Field.GetSelectedOptions();if(0==t.length)return{RegularPrice:"",SalePrice:"",Quantity:this.GetQuantity()};for(let e of t){let t=null;t=(new Zi).InitializeFieldOnly(this.Field).SetRegularPrice(this.Field.GetOptionPrice(e)).SetQuantity(1).ExecuteCalculation("aa");let i={Id:e.Id,RegularPrice:t.RegularPrice,UnitPrice:t.RegularPrice,Quantity:t.Quantity,Price:t.RegularPrice*t.Quantity};""==i.UnitPrice?i.UnitPrice=0:i.UnitPrice=parseFloat(i.UnitPrice),isNaN(i.UnitPrice)&&(i.UnitPrice=0),i.Price=i.UnitPrice*i.Quantity,this.OptionsTotal.push(i)}let i={RegularPrice:0,SalePrice:0,Quantity:this.GetQuantity()};i.Quantity=this.GetQuantity();for(let e of this.OptionsTotal)this.OptionsTotal.some((e=>""!=e.SalePrice))?(i.SalePrice+=c.Sanitizer.SanitizeNumber(e.Price,0),i.RegularPrice+=c.Sanitizer.SanitizeNumber(e.RegularPrice,0)):(i.SalePrice=0,i.RegularPrice+=c.Sanitizer.SanitizeNumber(e.Price,0));return i}GetForceUpdateWhenFieldChange(){return!0}ParseNumber(e){let t=parseFloat(e);return isNaN(t)?0:t}InternalInstanceUpdated(e){}AddOption(e,t){return""!=t.RegularPrice&&(e.RegularPrice=c.Sanitizer.SanitizeNumber(e.RegularPrice,0)+c.Sanitizer.SanitizeNumber(t.RegularPrice,0)),""!=t.SalePrice&&(e.SalePrice=c.Sanitizer.SanitizeNumber(e.SalePrice,0)+c.Sanitizer.SanitizeNumber(t.SalePrice,0)),e}}class ts{static GetCalculator(e){switch(e){case ot.fixed_amount:return new Zi;case ot.options:return new es;case ot.none:return new Ki}let t=i.EventManager.Publish("GetCalculator",e);if(null==t)throw new Error("Calculator "+e+" not found");return t}}class is extends _i{constructor(...e){super(...e),this.IsFieldWithPrice=!0,this.IsPriceField=!0}InitializePriceCalculator(){this.Calculator=ts.GetCalculator(this.Options.PriceType),this.Calculator.Initialize(this)}async InitializeConditions(){null!=this.FormBuilder&&this.InitializePriceCalculator(),super.InitializeConditions()}GetPrice(){return this.GetIsValid()?this.Options.PriceType==ot.none||this.RootFormBuilder.IsDesign?this.GetNumber():this.Calculator.GetPrice():0}FireValueChanged(e=null){if(!this.DisableFireValueChanged)return new Promise((t=>{let i=e;null==e&&(e=new Fi(this)).ChainEnded.Subscribe(this,(e=>t())),null!=this.Calculator&&this.Calculator.ExecuteAndUpdate(this.Calculator.GetForceUpdateWhenFieldChange(),!0,e),super.FireValueChanged(e),null==i&&(e.ChainEnded.Publish(e),t())}))}SetPrice(e){this.GetIsUsed()||(e=0),e=c.Sanitizer.SanitizeNumber(e,0),this.Calculator.UpdatePrice(e,this.Calculator.GetQuantity())}InternalSerialize(e){if(e.PriceType=this.Options.PriceType,null==this.Calculator)return e.SalePrice=0,e.Quantity=0,void(e.UnitPrice=0);e.Price=this.Calculator.GetPrice(),e.Quantity=this.Calculator.GetQuantity(),e.UnitPrice=this.Calculator.GetUnitPrice()}}var ss,rs,ns,ls,as,os,us,ds,hs,cs;class ps extends l.StoreBase{LoadDefaultValues(){this.Id=0,this.Value=""}}let ms=(ss=l.StoreAutoIncrement("ItemOptions"),rs=l.StoreDataType(ps),ns=class extends l.StoreBase{constructor(...e){super(...e),babelHelpers.initializerDefineProperty(this,"Id",ls,this),babelHelpers.initializerDefineProperty(this,"AdditionalOptionValue",as,this)}LoadDefaultValues(){this.Type="",this.Selected=!1,this.Id=0,this.Label="",this.RegularPrice="",this.AdditionalOptionValue=[]}},ls=babelHelpers.applyDecoratedDescriptor(ns.prototype,"Id",[ss],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),as=babelHelpers.applyDecoratedDescriptor(ns.prototype,"AdditionalOptionValue",[rs],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),ns),bs=(os=l.StoreAutoIncrement("AdditionalOptionColumn"),us=l.StoreDataType(Object),ds=class extends l.StoreBase{constructor(...e){super(...e),babelHelpers.initializerDefineProperty(this,"Id",hs,this),babelHelpers.initializerDefineProperty(this,"Options",cs,this)}LoadDefaultValues(){this.Id=0,this.Label="",this.Options=null,this.Type=""}},hs=babelHelpers.applyDecoratedDescriptor(ds.prototype,"Id",[os],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),cs=babelHelpers.applyDecoratedDescriptor(ds.prototype,"Options",[us],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),ds);var fs,ys,gs,Fs,Is;let Cs=(fs=l.StoreDataType(ms),ys=l.StoreDataType(bs),gs=class extends dt{constructor(...e){super(...e),babelHelpers.initializerDefineProperty(this,"Options",Fs,this),babelHelpers.initializerDefineProperty(this,"AdditionalOptionColumn",Is,this)}LoadDefaultValues(){super.LoadDefaultValues(),this.Options=[],this.Options=[(new ms).Merge({Id:1,RegularPrice:"",Label:"Option 1"}),(new ms).Merge({Id:2,RegularPrice:"",Label:"Option 2"}),(new ms).Merge({Id:3,RegularPrice:"",Label:"Option 3"})],this.AdditionalOptionColumn=[]}},Fs=babelHelpers.applyDecoratedDescriptor(gs.prototype,"Options",[fs],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),Is=babelHelpers.applyDecoratedDescriptor(gs.prototype,"AdditionalOptionColumn",[ys],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),gs);class Ps{constructor(e){this.Options=e}static Initialize(e){Ps.WasInitialized=!0,window.RNPriceManager=new Ps(e)}static GetInstance(){return window.RNPriceManager}static FormatPrice(e){return Ps.GetInstance().InternalFormatPrice(e)}InternalFormatPrice(e){e=parseFloat(e),isNaN(e)&&(e=0);let t=e.toFixed(this.Options.Decimals);var i=t.split("."),s=i[0],r=i.length>1?"."+i[1]:"",n=/(\d+)(\d{3})/;if(""!=this.Options.ThousandSeparator)for(;n.test(s);)s=s.replace(n,"$1"+this.Options.ThousandSeparator+"$2");r.length>0&&(r=r.slice(1),r=this.Options.DecimalSeparator+r),t=s+r;let l=this.Options.Format.replace("%2$s",t);return l=l.replace("%1$s",this.Options.Symbol),l}}Ps.WasInitialized=!1,o.customElement("rn-price")(class extends u.LitElementBase{constructor(...e){super(...e),this.amount=0}static get properties(){return{amount:{type:Object}}}render(){return t.html` <span class=${"price rn-price "}> <span class="amount"> ${ai(Ps.FormatPrice(this.amount))} </span> </span> `}});var vs=ri(class extends ni{render(e){return t.noChange}update(e,i){if(0==i.length||null==i[0].ImageType)return t.noChange;let s=e.options.host.model;if(null==s)return t.noChange;let r=i[0],n=e.element;var l;if("none"==r.ImageType)return null===(l=n.parentElement.querySelector(".RNIconOrImage"))||void 0===l||l.remove(),t.noChange;let a=null;return a=t.renderInline(t.html` <rn-icon-displayer .icon="${r}" .formBuilder="${s.RootFormBuilder}"></rn-icon-displayer> `),a.style.position="absolute",a.style.left="3px",a.style.top=0,a.style.height="100%",n.style.paddingLeft="25px",n.parentElement.appendChild(a),t.noChange}});exports.ConditionFactory=at,exports.PriceManager=Ri,exports.FieldTypeEnum={},exports.FieldTypeEnum=nt,exports.FieldWithPrice=Ji,exports.FieldWithPriceModel=is,exports.ScrollingUtil=Ci,exports.FormulaOptions=lt,exports.ExecutionChain=Fi,exports.ConditionProcessorBase=Ti,exports.PriceTypeEnum=ot,exports.IconDirective=vs,exports.CalculatorBase=Xi,exports.PreferredReturnType={},exports.PreferredReturnTypeEnum=Ee,exports.FormBuilderModel=zi,exports.FormBuilderOptions=$e,exports.OptionsCalculator=es,exports.FormBuilder=Vi,exports.CurrencyManager=Ps,exports.FBRow=Ni,exports.FBRowModel=yi,exports.FBRowOptions=se,exports.ElementUsedOptions=H,exports.ElementUsedTypeEnum=L,exports.FieldFactory=Y,exports.FBColumn=Ai,exports.FBColumnOptions=Z,exports.FBColumnModel=ci,exports.FieldBase=Qi,exports.FieldBaseOptions=ut,exports.FieldBaseModel=_i,exports.RunnableAddOnLoader=class{constructor(){i.EventManager.Subscribe("RegisterRunnableAddOn",(e=>{this.FormBuilder=e.FormBuilder,e.AddOns.push(this)}))}AfterInit(){}AfterSubmit(){}BeforeInit(){}async BeforeSubmit(e,t,i){return!0}ProcessConfirmation(e){return null}},exports.MultipleOptionsBaseModel=class extends is{constructor(...e){super(...e),this.SelectedValues=[],this.CustomPrice=new Map,this.PreviouslySelectedValues=new Map,this.PriceAttribute=null}SetSelection(e=null){Array.isArray(e)||(e=[]);let t=[];for(let i of e)i=c.Sanitizer.SanitizeNumber(i),this.OptionItemsToUse.some((e=>e.Id==i))&&t.push(i);this.SelectedValues=t,this.FireValueChanged()}IsOptionSelected(e){return this.SelectedValues.indexOf(e)>=0}GetPriceWithoutFormula(){let e=0;return this.GetSelectedOptions().forEach((t=>e+=c.Sanitizer.SanitizeNumber(this.GetOptionPrice(t)))),e}GetOptionPrice(e,t=!1){if(null===this.PriceAttribute)return!this.CustomPrice.has(e.Id)||t?e.RegularPrice:this.CustomPrice.get(e.Id);let i=e.AdditionalOptionValue.find((e=>e.Id==this.PriceAttribute));return null==i?0:i.Value}SetPriceAttribute(e){this.PriceAttribute=e,this.FireValueChanged()}get AllowMultiple(){return!0}RecreateSelectedOptions(){this.SelectedValues=this.OptionItemsToUse.filter((e=>e.Selected)).map((e=>e.Id))}InternalSerialize(e){if(super.InternalSerialize(e),e.SelectedValues=this.GetSelectedOptions().map((e=>e.ToObject())),e.SelectedValues.forEach((e=>{e.RegularPrice=this.GetOptionPrice(this.GetSelectedOptions().find((t=>e.Id==t.Id)))})),this.Calculator instanceof es)for(let t=0;t<e.SelectedValues.length;t++){let i=this.Calculator.OptionsTotal.find((i=>i.Id==e.SelectedValues[t].Id));null==i&&(i={Id:e.SelectedValues[t].Id,Price:0,Quantity:0,RegularPrice:0,Total:0}),e.SelectedValues[t]=Object.assign(e.SelectedValues[t],i)}}GetStoresInformation(){return!0}GetSelectedOptions(){return this.OptionItemsToUse.filter((e=>this.SelectedValues.indexOf(e.Id)>=0))}GetIsUsed(){return!!super.GetIsUsed()&&this.SelectedValues.length>0}GetValue(){return this.GetIsVisible()?this.SelectedValues:[]}GetColumnValue(e){let t=this.GetSelectedOptions(),i=this.Options.AdditionalOptionColumn.find((t=>t.Id==e||t.Label==e));if(null==i)return null;let s=[];return t.forEach((e=>{let t=e.AdditionalOptionValue.find((e=>e.Id==i.Id));null!=t&&s.push(t.Value)})),0==s.length?null:s}SumColumnValue(e){let t=this.GetColumnValue(e);return null==t?0:t.reduce(((e,t)=>e+c.Sanitizer.SanitizeNumber(t)),0)}GetText(){return this.GetSelectedOptions().map((e=>e.Label)).join(", ")}GetNumber(){return this.GetSelectedOptions().reduce(((e,t)=>e+c.Sanitizer.SanitizeNumber(this.GetOptionPrice(t))),0)}EnableOption(e){this.DisabledValues.indexOf(e)>=0&&this.DisabledValues.splice(this.DisabledValues.indexOf(e),1),this.Refresh()}IsOptionDisabled(e){return this.DisabledValues.indexOf(e)>=0}DisableOption(e){this.DisabledValues.indexOf(e)<0&&this.DisabledValues.push(e),this.SelectedValues.indexOf(e)>=0&&this.SelectedValues.splice(this.SelectedValues.indexOf(e),1),this.Refresh()}Contains(e){return null!=this.GetSelectedOptions().find((t=>t.Label==e))}SetOptionPrice(e,t=null){if(null!=this.Options.Options.find((t=>t.Id==e)))if(null===t)this.CustomPrice.has(e)&&(this.CustomPrice.delete(e),this.FireValueChanged());else{t!=this.CustomPrice.get(e)&&(this.CustomPrice.set(e,t),this.FireValueChanged())}}InitializeStartingValues(){this.CustomPrice.clear(),this.OptionItemsToUse=this.Options.Options,this.PreviouslySelectedValues=new Map;let e=this.OptionItemsToUse.filter((e=>e.Selected)).map((e=>e.Id));if(null!=this.GetPreviousData()){let t=this.GetPreviousDataProperty("SelectedValues",[]);e=this.OptionItemsToUse.filter((e=>t.some((t=>t.Id==e.Id)))).map((e=>e.Id))}this.SelectedValues=e}SetOptionsToUse(e){this.PreviouslySelectedValues.set(this.OptionItemsToUse,this.SelectedValues),this.OptionItemsToUse=null==e?this.Options.Options:e,this.SelectedValues=this.PreviouslySelectedValues.get(this.OptionItemsToUse),null==this.SelectedValues&&(this.SelectedValues=e.filter((e=>e.Selected)).map((e=>e.Id))),this.DisabledValues=[],this.FireValueChanged()}ToggleSelection(e,t){void 0===t&&(t=!this.IsOptionSelected(e));let i=this.OptionItemsToUse.find((t=>t.Id==e));if(null==i){if(!this.AllowMultiple){let t=this.SelectedValues;if(this.SelectedValues=[],this.FireValueChanged(),1==t.length&&t[0]==e)return}return}let s=this.SelectedValues.slice(0);this.AllowMultiple||(s=[]),t&&-1==s.indexOf(i.Id)&&s.push(i.Id),!t&&s.indexOf(i.Id)>=0&&s.splice(s.indexOf(i.Id),1),s.length>0&&this.RemoveError("required"),this.SelectedValues=s,this.FireValueChanged()}get IsReadonly(){var e,t,i;return null==this.FormBuilder||!1===(null===(e=this.RootFormBuilder)||void 0===e||null===(t=e.AdditionalOptions)||void 0===t||null===(i=t.EditOptions)||void 0===i?void 0:i.AllowEdition)}},exports.MultipleOptionsBase=class extends Ji{},exports.MultipleOptionsBaseOptions=Cs,exports.ConditionBaseOptions=k,exports.ConditionLineTypeEnum=B,exports.ConditionLineOptions=A,exports.ConditionGroupOptions=U,exports.IconOptions=_e,exports.SubmitButton=qi,exports.SubmitButtonModel=ji,exports.SubmitButtonOptions=Wi,exports.FieldWithPrice=Ji,exports.FieldWithPriceOptions=dt,exports.FieldWithPriceModel=is,exports.ItemOptionsOptions={},exports.ItemOptionsOptions.ItemOptions=ms,exports.ItemOptionsOptions.AdditionalColumnOptions=bs,exports.ItemOptionsOptions.AdditionalOptionValue=ps,exports.FieldContainerMixin=$i,exports.SubTypeEnum=z,exports.ComparisonTypeEnum=$,exports.RunnableComparatorBase=Pi,exports.ShowHideConditionOptions=Q,exports.ValidationConditionOptions=W,exports.FixedValuesDictionary={FixedValuesDictionary:[]},exports.MultipleStepOptions=Me,exports.MultipleStepItem=Re,exports.FieldConditionProcessorBase=Di,exports.ExecutionOrder=fi}));