diff --git a/ADnD_1E_Revised/1ESheet.html b/ADnD_1E_Revised/1ESheet.html
index 6c7839ddad..4d9aef770e 100644
--- a/ADnD_1E_Revised/1ESheet.html
+++ b/ADnD_1E_Revised/1ESheet.html
@@ -7,12 +7,13 @@
Important Sheet Announcements
-
v • 6/6/26'
+
v • 6/22/26'
Latest
+ Fixed low INT bonus languages to 0.
+ Recent/Previous
Updated the class datalist listing from "Mage" to "Magic-User".
AC & HP sync remains disabled for the Monster page, but the PC and NPC page will adhere to the sync options set in the sheet's settings.
- Recent/Previous
Fixed: repeating_weapon "weapon_attack_type" was always being set to "melee", but it should match whatever repeating_equipment "weapon_type" is when creating/adding an attack from equipment.
When creating/adding an attack from equipment, the uses and max columns, (e.g. equipment_current & equipment_current_max fields) will be used to auto-fill weapon_ammo & weapon_ammo_max.
HP and AC is automatically set to NOT auto-calculated/synced on the Monsters page.
@@ -1868,6 +1869,6 @@
-
\ No newline at end of file
+ &{template:attacks-table} {{color=@{color_option}}} {{ToHitAC-10=[[ @{thac0-10} ]]}} {{ToHitAC-9=[[ @{thac0-9} ]]}} {{ToHitAC-8=[[ @{thac0-8} ]]}} {{ToHitAC-7=[[ @{thac0-7} ]]}} {{ToHitAC-6=[[ @{thac0-6} ]]}} {{ToHitAC-5=[[ @{thac0-5} ]]}} {{ToHitAC-4=[[ @{thac0-4} ]]}} {{ToHitAC-3=[[ @{thac0-3} ]]}} {{ToHitAC-2=[[ @{thac0-2} ]]}} {{ToHitAC-1=[[ @{thac0-1} ]]}} {{ToHitAC0=[[ @{thac00} ]]}} {{ToHitAC1=[[ @{thac01} ]]}} {{ToHitAC2=[[ @{thac02} ]]}} {{ToHitAC3=[[ @{thac03} ]]}} {{ToHitAC4=[[ @{thac04} ]]}} {{ToHitAC5=[[ @{thac05} ]]}} {{ToHitAC6=[[ @{thac06} ]]}} {{ToHitAC7=[[ @{thac07} ]]}} {{ToHitAC8=[[ @{thac08} ]]}} {{ToHitAC9=[[ @{thac09} ]]}} {{ToHitAC10=[[ @{thac010} ]] }}`;return t?l===2?p=g:o===0?(p=u,l=0):(p=m,l=1):r?(p=g,l=2):o===0?(p=u,l=0):(p=m,l=1),e[c]=p,e[s]=l,e};on("change:toggle_to_hit_table change:hide_to_hit_table",async n=>{let a=await y("weapon"),t=a.flatMap(l=>[`repeating_weapon_${l}_weapon_whisper_to_hit_select`,`repeating_weapon_${l}_weapon_whisper_to_hit`]),e=await w(["toggle_to_hit_table","hide_to_hit_table",...t]),o=0,r=a.map(l=>Be(e,l,o)),s=await Promise.all(r),c=Object.assign({},...s);await h(c,{silent:!0})});on("change:repeating_weapon:weapon_whisper_to_hit_select",async n=>{let a=n.sourceAttribute.split("_")[2],t=await w(["toggle_to_hit_table",`repeating_weapon_${a}_weapon_whisper_to_hit_select`,`repeating_weapon_${a}_weapon_whisper_to_hit`]),o=await Be(t,a,1);await h(o,{silent:!0})});on("change:weapon_proficiency_initial change:weapon_proficiency_added_per_level change:weapon_proficiency_penalty",async n=>{let a=await y("weapon"),t={},e=a.flatMap(s=>[`repeating_weapon_${s}_weapon_prof_flag`]),o=await w(["weapon_proficiency_penalty",...e]),r=i(o.weapon_proficiency_penalty);_.each(a,s=>{let c=i(o[`repeating_weapon_${s}_weapon_prof_flag`]);t[`repeating_weapon_${s}_weapon_prof`]=r,t[`repeating_weapon_${s}_weapon_prof_pen`]=c===0?"0":r}),await h(t,{silent:!0})});on("change:repeating_weapon:weapon_prof_flag",async n=>{let a=n.sourceAttribute.split("_")[2],t={},e=await w(["weapon_proficiency_penalty",`repeating_weapon_${a}_weapon_prof_flag`]),o=i(e.weapon_proficiency_penalty),r=i(e[`repeating_weapon_${a}_weapon_prof_flag`]);t[`repeating_weapon_${a}_weapon_prof`]=o,t[`repeating_weapon_${a}_weapon_prof_pen`]=r===0?"0":o,await h(t,{silent:!0})});on("change:backstab change:backstab_bonus change:toggle_thief_skills",async n=>{let a=await y("weapon"),t={},e=a.flatMap(l=>[`repeating_weapon_${l}_weapon_backstab_flag`]),o=await w(["backstab","backstab_bonus","toggle_thief_skills",...e]),r=i(o.toggle_thief_skills),s=i(o.backstab),c=i(o.backstab_bonus);_.each(a,l=>{let p=i(o[`repeating_weapon_${l}_weapon_backstab_flag`]);r===0&&(t[`repeating_weapon_${l}_weapon_backstab_var`]=p===0?0:`+${c}`,t[`repeating_weapon_${l}_weapon_backstab_bonus`]=p===0?0:c,t[`repeating_weapon_${l}_weapon_backstab`]=p===0?1:`x${s}`,t[`repeating_weapon_${l}_weapon_backstab_mult`]=p===0?1:s),r===1&&(t[`repeating_weapon_${l}_weapon_backstab_var`]=0,t[`repeating_weapon_${l}_weapon_backstab_bonus`]=0,t[`repeating_weapon_${l}_weapon_backstab`]=1,t[`repeating_weapon_${l}_weapon_backstab_mult`]=1)}),await h(t,{silent:!0})});on("change:repeating_weapon:weapon_backstab_flag",async n=>{let a=n.sourceAttribute.split("_")[2],t={},e=await w(["backstab","backstab_bonus","toggle_thief_skills",`repeating_weapon_${a}_weapon_backstab_flag`]),o=i(e.toggle_thief_skills),r=i(e.backstab),s=i(e.backstab_bonus),c=i(e[`repeating_weapon_${a}_weapon_backstab_flag`]);o===0&&(t[`repeating_weapon_${a}_weapon_backstab_var`]=c===0?0:`+${s}`,t[`repeating_weapon_${a}_weapon_backstab_bonus`]=c===0?0:s,t[`repeating_weapon_${a}_weapon_backstab`]=c===0?1:`x${r}`,t[`repeating_weapon_${a}_weapon_backstab_mult`]=c===0?1:r),o===1&&(t[`repeating_weapon_${a}_weapon_backstab_var`]=0,t[`repeating_weapon_${a}_weapon_backstab_bonus`]=0,t[`repeating_weapon_${a}_weapon_backstab`]=1,t[`repeating_weapon_${a}_weapon_backstab_mult`]=1),await h(t,{silent:!0})});on("change:repeating_weapon:weapon_dual",async n=>{let a=n.sourceAttribute.split("_")[2],t={},e=await w(["dual_pen_primary","dual_pen_secondary",`repeating_weapon_${a}_weapon_dual`]),o=i(e.dual_pen_primary),r=i(e.dual_pen_secondary),s=e[`repeating_weapon_${a}_weapon_dual`],c=0;s==="Normal"?c=0:s==="Primary"?c=o:s==="Secondary"&&(c=r);let l=Math.min(0,c);t[`repeating_weapon_${a}_weapon_dual_pen`]=l,await h(t,{silent:!0})});var zn=async()=>{let n=await y("weapon"),a={},t=n.flatMap(s=>[`repeating_weapon_${s}_weapon_critdamage_flag`,`repeating_weapon_${s}_weapon_critdamage_mult`]),e=await w(["dual_pen_primary","dual_pen_secondary",...t]),o=i(e.dual_pen_primary),r=i(e.dual_pen_secondary);_.each(n,s=>{let c=e[`repeating_weapon_${s}_weapon_dual`],l=0;c==="Primary"?l=o:c==="Secondary"&&(l=r);let p=Math.min(0,l);a[`repeating_weapon_${s}_weapon_dual_pen`]=p}),await h(a)};on("change:dual_pen_primary change:dual_pen_secondary change:dexterity",async n=>{let a=await w(["dexterity"]),t={},e=i(a.dexterity),o=0;e<6?o=Math.max(-3,e-6):e>=18?o=Math.min(5,Math.floor(e/3)-3):e>15&&(o=e-15);let r=Math.min(0,o-2),s=Math.min(0,o-4);t.dual_pen_primary=r,t.dual_pen_secondary=s,await h(t,{silent:!0}),await zn()});var Kn=async n=>{let a=[`repeating_weapon_${n}_weapon_range`,`repeating_weapon_${n}_weapon_range_short`,`repeating_weapon_${n}_weapon_range_medium`,`repeating_weapon_${n}_weapon_range_long`,`repeating_weapon_${n}_weapon_attack_type`,`repeating_weapon_${n}_weapon_range_error`],t=await w(a),e={},o=i(t[`repeating_weapon_${n}_weapon_attack_type`]);if(o===0||o===2)return;let r=t[`repeating_weapon_${n}_weapon_range`];r=r.replace(/'/g,""),r=r.replace(/"/g,"");let s=r.split("/").join(",").split(" ").join(",").split("-").join(",").split(","),c=Number(s[0]),l=Number(s[1]),p=Number(s[2]);s.length===1&&c>=0&&!l&&!p&&(l=c,p=c),Number.isNaN(c)?(e[`repeating_weapon_${n}_weapon_range_short`]=0,e[`repeating_weapon_${n}_weapon_range_error`]=r===""?1:0):e[`repeating_weapon_${n}_weapon_range_short`]=c,Number.isNaN(l)?(e[`repeating_weapon_${n}_weapon_range_medium`]=0,e[`repeating_weapon_${n}_weapon_range_error`]=r===""?1:0):e[`repeating_weapon_${n}_weapon_range_medium`]=l,Number.isNaN(p)?(e[`repeating_weapon_${n}_weapon_range_long`]=0,e[`repeating_weapon_${n}_weapon_range_error`]=r===""?1:0):e[`repeating_weapon_${n}_weapon_range_long`]=p,!Number.isNaN(c)&&!Number.isNaN(l)&&!Number.isNaN(p)&&(e[`repeating_weapon_${n}_weapon_range_error`]=1),await h(e,{silent:!0})};on("change:repeating_weapon:weapon_range change:repeating_weapon:weapon_attack_type",async n=>{let a=n.sourceAttribute.split("_")[2];await Kn(a)});on("change:repeating_weapon:weapon_attack_type",async n=>{let a=n.sourceAttribute.split("_")[2],t=await w([`repeating_weapon_${a}_weapon_attack_type`,`repeating_weapon_${a}_weapon_attack_type_flag`]),e={},o=i(t[`repeating_weapon_${a}_weapon_attack_type`]),r=i(t[`repeating_weapon_${a}_weapon_attack_type_flag`]);o!==r&&(e[`repeating_weapon_${a}_weapon_attack_type_flag`]=o),await h(e,{silent:!0})});var Te=async()=>{let n=await w(["hitpoints","hitpoints_max","sync_hp_flag","toggle_npc","hitpoints_1_class","hitpoints_2_class","hitpoints_3_class"]),a={},t=i(n.toggle_npc),e=i(n.sync_hp_flag);e=t?0:e;let o=i(n.hitpoints_max),r=Math.max(0,i(n.hitpoints_1_class)),s=Math.max(0,i(n.hitpoints_2_class)),c=Math.max(0,i(n.hitpoints_3_class)),l=r!==0?1:0,p=s!==0?1:0,g=c!==0?1:0,u=l+p+g,m=r+s+c,d=+u>1?O(m/u).toFixed(2):m,f=+(d%1).toFixed(2);a.hitpoints_class_total=m,a.hp_quotient=u,a.hitpoints_total=d,a.hitpoints_remainder_total=f,a.hitpoints_max=e?Math.round(d):o,await h(a,{silent:!0})};on("change:toggle_npc change:sync_hp_flag change:hitpoints change:hitpoints_max change:hitpoints_1_class change:hitpoints_2_class change:hitpoints_3_class",async n=>{await Te()});var F=async n=>{let a=await w([...de,"armor_rating_flag","armorbonus","armorbonus_inverted","armorbonus_toggle","armorclass","armorclass_magic","armorclass_mod","autocalc_ac","current_encumbrance_move","sync_ac_flag","toggle_npc"]);if(i(a.autocalc_ac)+n===0)return;let e={},o=i(a.armorclass),r=i(a.toggle_npc),s=i(a.sync_ac_flag);s=r?0:1;let c=i(a.armor_rating_flag),l=i(a.armorshield_mod)*-1,p=i(a.armorother_mod)*-1,g=i(a.armorother2_mod)*-1,u=i(a.armorother3_mod)*-1,m=i(a.armorother4_mod)*-1,d=i(a.armorother5_mod)*-1,f=i(a.armorother6_mod)*-1,k=i(a.armortype_magic)*-1,v=i(a.armortype2_magic)*-1,E=i(a.armorshield_magic)*-1,N=i(a.armorhelmet_magic)*-1,I=i(a.armorother_magic)*-1,C=i(a.armorother2_magic)*-1,Ue=i(a.armorother3_magic)*-1,je=i(a.armorother4_magic)*-1,We=i(a.armorother5_magic)*-1,Fe=i(a.armorother6_magic)*-1,Ge=i(a.unarmored_worn),be=i(a.armortype_worn),fe=i(a.armortype2_worn),J=i(a.armorshield_worn),dt=i(a.armorhelmet_worn),ee=i(a.armorother_worn),ae=i(a.armorother2_worn),te=i(a.armorother3_worn),ne=i(a.armorother4_worn),oe=i(a.armorother5_worn),re=i(a.armorother6_worn),yt=i(a.current_encumbrance_move),ze=i(a.armorbonus_toggle),R=i(a.armorbonus),Ke=0;yt===3&&R<0?(ze=0,R=0,Ke=1):R<0?R=i(a.armorbonus)*ze:R=i(a.armorbonus),e.encumbrance_flag=Ke;let Xe=i(a.unarmored_base,10),Qe=i(a.armortype_base),Ye=i(a.armortype2_base),Ze=i(a.armorshield_base),Je=i(a.armorother_base),ea=i(a.armorother2_base)>=0?0:-Math.abs(i(a.armorother2_base)),aa=i(a.armorother3_base)>=0?0:-Math.abs(i(a.armorother3_base)),ta=i(a.armorother4_base)>=0?0:-Math.abs(i(a.armorother4_base)),na=i(a.armorother5_base)>=0?0:-Math.abs(i(a.armorother5_base)),oa=i(a.armorother6_base)>=0?0:-Math.abs(i(a.armorother6_base)),ra=i(a.unarmored_ac),sa=i(a.armortype_ac),ca=i(a.armortype2_ac),ia=i(a.armorshield_ac),_a=i(a.armorother_ac),pa=i(a.armorother2_ac)>=0?0:-Math.abs(i(a.armorother2_ac)),la=i(a.armorother3_ac)>=0?0:-Math.abs(i(a.armorother3_ac)),ma=i(a.armorother4_ac)>=0?0:-Math.abs(i(a.armorother4_ac)),ha=i(a.armorother5_ac)>=0?0:-Math.abs(i(a.armorother5_ac)),ga=i(a.armorother6_ac)>=0?0:-Math.abs(i(a.armorother6_ac)),bt=be?Qe:10,ft=fe?Ye:10,$t=J?Ze:0,vt=ee?Je:10,qt=ae?ea:0,kt=te?aa:0,At=ne?ta:0,Mt=oe?na:0,xt=re?oa:0,Tt=Ge?Xe:10,St=be?sa:10,Nt=fe?ca:10,ua=J?ia:0,Ct=ee?_a:10,Dt=ae?pa:0,Ot=te?la:0,Et=ne?ma:0,It=oe?ha:0,Rt=re?ga:0,Ht=Ge?ra:10,se=J?l:0,ce=J?E:0,Pt=Math.min(Qe,Ye,Je,Xe)+Ze+ea+aa+ta+na+oa,Lt=Math.min(sa,ca,_a,ra)+(ia+pa+la+ma+ha+ga),wa=Math.min(bt,ft,vt,Tt)+($t+qt+kt+At+Mt+xt),$e=Math.min(St,Nt,Ct,Ht)+(Dt+Ot+Et+It+Rt),da=k+v+N+I+C+Ue+je+We+Fe+E,Q=be*k+fe*v+dt*N+ee*I+ae*C+te*Ue+ne*je+oe*We+re*Fe,ya=p+g+u+m+d+f+l,Y=ee*p+ae*g+te*u+ne*m+oe*d+re*f,ve=Y+Q,qe=$e+Y+Q,ba=1;R>0&&qe>=10&&(ba=0);let ke=qe+R*ba,G=ua+se+ce,Ae=ke+G;R>0&&G>=10&&(Ae=ke+R+G);let Bt=(-1*(Q+ce)<=0?"":"+")+-1*(Q+ce),Vt=(-1*da<=0?"":"+")+-1*da,Ut=(-1*(Y+se)<=0?"":"+")+-1*(Y+se),jt=(-1*ya<=0?"":"+")+-1*ya,Wt=(-1*R<=0?"":"+")+-1*R,Ft=(-1*ve<=0?"":"+")+-1*ve,Gt=(-1*G<=0?"":"+")+-1*G;e.armorclass_rating_used=wa,e.armorclass_rating=c===1?"-":wa,e.armorclass_rating_best=Pt,e.armorclass_base_used=$e+ua,e.armorclass_base=$e,e.armorclass_base_best=Lt,e.armorclass_magic=Q,e.armorclass_magic_with_shield=Bt,e.armorclass_magic_total=Vt,e.armorclass_mod=Y,e.armorclass_mod_with_shield=Ut,e.armorclass_mod_total=jt,e.armorclass_combined_mod_magic=ve,e.armorclass_combined_mod_magic_inverted=Ft,e.armorclass_rear=qe,e.armorbonus_inverted=Wt,e.armorclass_shieldless=ke,e.armorclass_shield_magic=ce,e.armorclass_shield_mod=se,e.armorclass_combined_shield_mod_magic=G,e.armorclass_combined_shield_mod_magic_inverted=Gt,e.armorclass_total=Ae,e.armorclass=s?Ae:o,await h(e,{silent:!0})};on("change:armor_details_show change:armor_rating_flag change:toggle_npc change:sync_ac_flag change:autocalc_ac change:unarmored change:armortype change:armortype2 change:armorshield change:armorhelmet change:armorother change:armorother2 change:armorother3 change:armorother4 change:armorother5 change:armorother6 change:armorclass_mod change:armorclass_magic change:armorbonus change:armorbonus_toggle change:unarmored_worn change:armortype_worn change:armortype2_worn change:armorshield_worn change:armorhelmet_worn change:armorother_worn change:armorother2_worn change:armorother3_worn change:armorother4_worn change:armorother5_worn change:armorother6_worn change:armortype_base change:armortype2_base change:armorshield_base change:armorother_base change:armorother2_base change:armorother3_base change:armorother4_base change:armorother5_base change:armorother6_base change:unarmored_base change:armortype_ac change:armortype2_ac change:armorshield_ac change:armorhelmet_ac change:armorother_ac change:armorother2_ac change:armorother3_ac change:armorother4_ac change:armorother5_ac change:armorother6_ac change:unarmored_ac change:armorshield_mod change:armorother_mod change:armorother2_mod change:armorother3_mod change:armorother4_mod change:armorother5_mod change:armorother6_mod change:armortype_magic change:armortype2_magic change:armorshield_magic change:armorhelmet_magic change:armorother_magic change:armorother2_magic change:armorother3_magic change:armorother4_magic change:armorother5_magic change:armorother6_magic clicked:calcac",async n=>{let t=n.triggerName==="clicked:calcac"?1:0;await F(t)});var Ve=async(n,a)=>{let t;if(a==null){let m=await w(["toggle_auto_damage"]);t=i(m.toggle_auto_damage)}else t=a;let e={},o=`Damage vs S/M [[ (@{repeating_weapon_${n}_weapon_damagesmallmedium}) * @{repeating_weapon_${n}_weapon_backstab_mult}[MULT] + ( @{repeating_weapon_${n}_weapon_attackdmgbonus}[DMG_BON] ) + ( @{repeating_weapon_${n}_weapon_magicbonus}[MAG_BON] ) + ( ?{Damage Modifier?|0}[MISC_MOD] ) ]]`,r=` vs LG [[ (@{repeating_weapon_${n}_weapon_damagelarge}) * @{repeating_weapon_${n}_weapon_backstab_mult}[MULT] + ( @{repeating_weapon_${n}_weapon_attackdmgbonus}[DMG_BON] ) + ( @{repeating_weapon_${n}_weapon_magicbonus}[MAG_BON] ) + ( ?{Damage Modifier?|0}[MISC_MOD] ) ]]`,s=`Damage vs S/M [[ (@{repeating_weapon_${n}_weapon_damagesmallmedium}) * @{repeating_weapon_${n}_weapon_backstab_mult}[MULT] + ( @{repeating_weapon_${n}_weapon_attackdmgbonus}[DMG_BON] ) + ( @{repeating_weapon_${n}_weapon_magicbonus}[MAG_BON] ) + ( ?{Damage Modifier?|0}[MISC_MOD] ) ]]`,c=` vs LG [[ (@{repeating_weapon_${n}_weapon_damagelarge}) * @{repeating_weapon_${n}_weapon_backstab_mult}[MULT] + ( @{repeating_weapon_${n}_weapon_attackdmgbonus}[DMG_BON] ) + ( @{repeating_weapon_${n}_weapon_magicbonus}[MAG_BON] ) + ( ?{Damage Modifier?|0}[MISC_MOD] ) ]]`,l=`Damage vs S/M [[ (@{repeating_weapon_${n}_weapon_critdamagesmallmedium}) * @{repeating_weapon_${n}_weapon_backstab_mult}[MULT] + ( @{repeating_weapon_${n}_weapon_attackdmgbonus}[DMG_BON] ) + ( @{repeating_weapon_${n}_weapon_magicbonus}[MAG_BON] ) + ( ?{Damage Modifier?|0}[MISC_MOD] ) ]]`,p=` vs LG [[ (@{repeating_weapon_${n}_weapon_critdamagelarge}) * @{repeating_weapon_${n}_weapon_backstab_mult}[MULT] + ( @{repeating_weapon_${n}_weapon_attackdmgbonus}[DMG_BON] ) + ( @{repeating_weapon_${n}_weapon_magicbonus}[MAG_BON] ) + ( ?{Damage Modifier?|0}[MISC_MOD] ) ]]`,g=`Damage vs S/M [[ (@{repeating_weapon_${n}_weapon_critdamagesmallmedium}) * @{repeating_weapon_${n}_weapon_backstab_mult}[MULT] + ( @{repeating_weapon_${n}_weapon_attackdmgbonus}[DMG_BON] ) + ( @{repeating_weapon_${n}_weapon_magicbonus}[MAG_BON] ) + ( ?{Damage Modifier?|0}[MISC_MOD] ) ]]`,u=` vs LG [[ (@{repeating_weapon_${n}_weapon_critdamagelarge}) * @{repeating_weapon_${n}_weapon_backstab_mult}[MULT] + ( @{repeating_weapon_${n}_weapon_attackdmgbonus}[DMG_BON] ) + ( @{repeating_weapon_${n}_weapon_magicbonus}[MAG_BON] ) + ( ?{Damage Modifier?|0}[MISC_MOD] ) ]]`;return t===0?(e[`repeating_weapon_${n}_weapon_damagesmallmedium_chat_menu`]=`[Roll Damage](~@{character_id}|repeating_weapon_${n}_weapon_damagesmallmedium_roll)`,e[`repeating_weapon_${n}_weapon_damagelarge_chat_menu`]=`[Roll Damage vs LG](~@{character_id}|repeating_weapon_${n}_weapon_damagelarge_roll)`,e[`repeating_weapon_${n}_weapon_damagesmallmedium_npc_chat_menu`]=`[Damage](~@{character_id}|repeating_weapon_${n}_weapon_damagesmallmedium_npc_roll)`,e[`repeating_weapon_${n}_weapon_damagelarge_npc_chat_menu`]=`[Damage vs LG](~@{character_id}|repeating_weapon_${n}_weapon_damagelarge_npc_roll)`,e[`repeating_weapon_${n}_weapon_critdamagesmallmedium_chat_menu`]=`[Roll Damage](~@{character_id}|repeating_weapon_${n}_weapon_critdamagesmallmedium_roll)`,e[`repeating_weapon_${n}_weapon_critdamagelarge_chat_menu`]=`[Roll Damage vs LG](~@{character_id}|repeating_weapon_${n}_weapon_critdamagelarge_roll)`,e[`repeating_weapon_${n}_weapon_critdamagesmallmedium_npc_chat_menu`]=`[Damage](~@{character_id}|repeating_weapon_${n}_weapon_critdamagesmallmedium_npc_roll)`,e[`repeating_weapon_${n}_weapon_critdamagelarge_npc_chat_menu`]=`[Damage vs LG](~@{character_id}|repeating_weapon_${n}_weapon_critdamagelarge_npc_roll)`):(e[`repeating_weapon_${n}_weapon_damagesmallmedium_chat_menu`]=o,e[`repeating_weapon_${n}_weapon_damagelarge_chat_menu`]=r,e[`repeating_weapon_${n}_weapon_damagesmallmedium_npc_chat_menu`]=s,e[`repeating_weapon_${n}_weapon_damagelarge_npc_chat_menu`]=c,e[`repeating_weapon_${n}_weapon_critdamagesmallmedium_chat_menu`]=l,e[`repeating_weapon_${n}_weapon_critdamagelarge_chat_menu`]=p,e[`repeating_weapon_${n}_weapon_critdamagesmallmedium_npc_chat_menu`]=g,e[`repeating_weapon_${n}_weapon_critdamagelarge_npc_chat_menu`]=u),e};on("change:repeating_weapon:weapon_name change:repeating_weapon:weapon_damagesmallmedium change:repeating_weapon:weapon_damagelarge change:repeating_weapon:weapon_critdamagesmallmedium change:repeating_weapon:weapon_critdamagelarge change:repeating_weapon:weapon_attackdmgbonus change:repeating_weapon:weapon_critdamage_flag",async n=>{let a=n.sourceAttribute.split("_")[2],t=await Ve(a);await h(t,{silent:!0})});on("change:toggle_critdamage change:toggle_auto_damage",async n=>{let a=await y("weapon"),t=a.map(l=>`repeating_weapon_${l}_weapon_critdamage_flag`),e=await w(["toggle_auto_damage",...t]),o={},r=i(e.toggle_auto_damage),s=a.map(async l=>{let p=`repeating_weapon_${l}_weapon_critdamage_flag`,g=i(e[p]);return o[p]=1-g,await Ve(l,r)});(await Promise.all(s)).forEach(l=>{Object.assign(o,l)}),await h(o,{silent:!0})});var Ua=["weapon_use","weapon_attack_type","weapon_attack_type_flag","weapon_critdamage_flag","weapon_prof_pen","weapon_whisper_to_hit_select","weapon_dual_pen","weapon_backstab_var","weapon_tohitbonus","weapon_magicbonus","weapon_prof","weapon_backstab","weapon_backstab_bonus","weapon_backstab_mult","weapon_attackdmgbonus","weapon_num_attacks","weapon_quantity","weapon_ammo","weapon_ammo_max","weapon_weight","weapon_cost","weapon_range_short","weapon_range_medium","weapon_range_long","weapon_thac_adj0","weapon_thac_adj1","weapon_thac_adj2","weapon_thac_adj3","weapon_thac_adj4","weapon_thac_adj5","weapon_thac_adj6","weapon_thac_adj7","weapon_thac_adj8","weapon_thac_adj9","weapon_thac_adj10"],Xn=["weapon_range_error","weapon_dual","weapon_tohitacadj","weapon_whisper_to_hit","weapon_length","weapon_space","weapon_speed","weapon_misc","weapon_damagesmallmedium_chat_menu","weapon_damagelarge_chat_menu","weapon_damagesmallmedium_npc_chat_menu","weapon_damagelarge_npc_chat_menu","weapon_critdamagesmallmedium_chat_menu","weapon_critdamagelarge_chat_menu","weapon_critdamagesmallmedium_npc_chat_menu","weapon_critdamagelarge_npc_chat_menu","weapon_damage_chat_menu_npc"],qa=[...Ua,...Xn],ja=["equipment_type","equipment_magical","equipment_show_type","equipment_current","equipment_current_max","equipment_carried_select","equipment_carried","equipment_quantity","equipment_quantity_max","equipment_weight","equipment_cost","equipment_armor_type","equipment_armor_worn","equipment_armor_ac","equipment_armor_base","equipment_armor_magic","equipment_armor_mod","equipment_armor_bulk","equipment_sync_armor_flag","equipment_weapon_type"],Qn=["equipment_macro_text","equipment_weapon_speed","equipment_weapon_misc","equipment_weapon_length","equipment_weapon_space","equipment_weapon_damagesmallmedium","equipment_weapon_damagelarge","equipment_weapon_attackdmgtype","equipment_weapon_rateoffire","equipment_weapon_range"],ka=[...ja,...Qn],Wa=["nwp_slots","nwp_modifier"],Yn=["nwp_attribute","nwp_attribute_value","nwp_macro_text"],Aa=[...Wa,...Yn],Zn=async n=>{let a=await w(["default_attack_macro"]),t={},e=a.default_attack_macro||ue;t[`repeating_weapon_${n}_weapon_macro_text`]=e,await h(t,{silent:!0})},Fa=async n=>{let a=["toggle_to_hit_table","hide_to_hit_table"],t=qa.map(l=>X("weapon",n,l)),e=[...a,...t],o=await w(e),r=i(o.toggle_to_hit_table),s=i(o.hide_to_hit_table),c=qa.reduce((l,p)=>{let g=X("weapon",n,p);return rawValue=o[g],Ua.includes(p)&&(l[g]=+rawValue||0),p==="weapon_whisper_to_hit_select"?s?l[g]=2:l[g]=r?1:0:l[g]=rawValue||"",l},{});await h(c)},Jn=async n=>{let a=["equipment_tabs_type","equipment_tabs_carry"],t=ka.map(p=>X("equipment",n,p)),e=[...a,...t],o=await w(e),r=i(o.equipment_tabs_type),s=`repeating_equipment_${n}_equipment_type`,c=i(o[s]),l=ka.reduce((p,g)=>{let u=X("equipment",n,g),m=o[u];return ja.includes(g)?g==="equipment_type"?p[u]=r!==-1?r:c:g==="equipment_magical"?p[u]=c===3||r===3?1:+m||0:p[u]=+m||0:p[u]=m||"",p},{});await h(l,{silent:!0})},eo=async n=>{let a=Aa.map(o=>X("nonweaponproficiencies",n,o)),t=await w(a),e=Aa.reduce((o,r)=>{let s=X("nonweaponproficiencies",n,r),c=t[s];return Wa.includes(r)?o[s]=+c||0:o[s]=c||"",o},{});await h(e,{silent:!0})};on("change:repeating_weapon:weapon_name change:repeating_equipment:equipment_item change:repeating_nonweaponproficiencies:nwp_name",async n=>{if(n.sourceType!=="player"||n.previousValue!==void 0)return;let a=n.sourceAttribute.split("_")[2];n.sourceAttribute.includes("equipment_item")&&await Jn(a),n.sourceAttribute.includes("weapon_name")&&(await Fa(a),await Zn(a)),n.sourceAttribute.includes("nwp_name")&&await eo(a)});on("sheet:opened",async n=>{let a={},t=await y("weapon"),e=await y("ability"),o=await y("nonweaponproficiencies"),r=await y("equipment"),s=await y("spells");if(t.length===0){let c=H();a[`repeating_weapon_${c}_weapon_value`]=1}if(e.length===0){let c=H();a[`repeating_ability_${c}_ability_value`]=1}if(o.length===0){let c=H();a[`repeating_nonweaponproficiencies_${c}_nwp_value`]=1}if(r.length===0){let c=H();a[`repeating_equipment_${c}_equipment_value`]=1}if(s.length===0){let c=H();a[`repeating_spells_${c}_spell_value`]=1}await h(a,{silent:!0})});on("change:default_attack_macro",async n=>{if((await w(["default_attack_macro"])).default_attack_macro!=="")return;let e={};e.default_attack_macro=ue,await h(e,{silent:!0})});on("change:repeating_weapon:weapon_macro_text",async n=>{let a=n.sourceAttribute.split("_")[2],t=await w([`repeating_weapon_${a}_weapon_macro_text`,"default_attack_macro"]);if(t[`repeating_weapon_${a}_weapon_macro_text`]!=="")return;let o={},r=t.default_attack_macro||ue;o[`repeating_weapon_${a}_weapon_macro_text`]=r,await h(o,{silent:!0})});on("clicked:updateweaponsmacros",async n=>{let a={},e=(await w(["default_attack_macro"])).default_attack_macro||ue,o=await y("weapon");_.each(o,r=>{a[`repeating_weapon_${r}_weapon_macro_text`]=e}),await h(a,{silent:!0})});on("clicked:resetallmacros clicked:resetequipmentmacros clicked:resetweaponsmacros clicked:resetabilitiesmacros clicked:resetnwpsmacros clicked:resetspellsmacros",async n=>{let t=n.triggerName.match(/clicked:(\w+)/),e=t?t[1]:null,o={};if(e==="resetallmacros"){o.surprise_macro_text="",o.surprise_others_macro_text="",o.init_macro_text="";let r=await y("equipment");_.each(r,g=>{o[`repeating_equipment_${g}_equipment_macro_text`]=""});let s=await y("weapon");_.each(s,g=>{o[`repeating_weapon_${g}_weapon_macro_text`]=""});let c=await y("ability");_.each(c,g=>{o[`repeating_ability_${g}_ability_macro_text`]=""});let l=await y("nonweaponproficiencies");_.each(l,g=>{o[`repeating_nonweaponproficiencies_${g}_nwp_macro_text`]=""});let p=await y("spells");_.each(p,g=>{o[`repeating_spells_${g}_spell_macro_text`]=""})}if(e==="resetequipmentmacros"){let r=await y("equipment");_.each(r,s=>{o[`repeating_equipment_${s}_equipment_macro_text`]=""})}if(e==="resetweaponsmacros"){let r=await y("weapon");_.each(r,s=>{o[`repeating_weapon_${s}_weapon_macro_text`]=""})}if(e==="resetabilitiesmacros"){let r=await y("ability");_.each(r,s=>{o[`repeating_ability_${s}_ability_macro_text`]=""})}if(e==="resetnwpsmacros"){let r=await y("nonweaponproficiencies");_.each(r,s=>{o[`repeating_nonweaponproficiencies_${s}_nwp_macro_text`]=""})}if(e==="resetspellsmacros"){let r=await y("spells");_.each(r,s=>{o[`repeating_spells_${s}_spell_macro_text`]=""})}h(o,{silent:!0})});var Ga=async n=>{let a=await w(["pickpockets","pickpockets_base","pickpockets_racial_mod","pickpockets_ability_mod","pickpockets_magic"]),t={},e=i(a.pickpockets_base),o=i(a.pickpockets_racial_mod),r=i(a.pickpockets_ability_mod),s=i(a.pickpockets_magic),c=i(a.pickpockets),l=Math.max(0,e+o+r+s);n===1&&c>=0&&l===0?t.pickpockets_base=c:t.pickpockets=l,h(t,{silent:!0})},za=async n=>{let a=await w(["openlocks","openlocks_base","openlocks_racial_mod","openlocks_ability_mod","openlocks_magic"]),t={},e=i(a.openlocks_base),o=i(a.openlocks_racial_mod),r=i(a.openlocks_ability_mod),s=i(a.openlocks_magic),c=i(a.openlocks),l=Math.max(0,Math.min(100,e+o+r+s));n===1&&c>=0&&l===0?t.openlocks_base=c:t.openlocks=l,h(t,{silent:!0})},Ka=async n=>{let a=await w(["findtraps","findtraps_base","findtraps_racial_mod","findtraps_ability_mod","findtraps_magic"]),t={},e=i(a.findtraps_base),o=i(a.findtraps_racial_mod),r=i(a.findtraps_ability_mod),s=i(a.findtraps_magic),c=i(a.findtraps),l=Math.max(0,Math.min(100,e+o+r+s));n===1&&c>=0&&l===0?t.findtraps_base=c:t.findtraps=l,h(t,{silent:!0})},Xa=async n=>{let a=await w(["movequietly","movequietly_base","movequietly_racial_mod","movequietly_ability_mod","movequietly_magic"]),t={},e=i(a.movequietly_base),o=i(a.movequietly_racial_mod),r=i(a.movequietly_ability_mod),s=i(a.movequietly_magic),c=i(a.movequietly),l=Math.max(0,Math.min(100,e+o+r+s));n===1&&c>=0&&l===0?t.movequietly_base=c:t.movequietly=l,h(t,{silent:!0})},Qa=async n=>{let a=await w(["hideinshadows","hideinshadows_base","hideinshadows_racial_mod","hideinshadows_ability_mod","hideinshadows_magic"]),t={},e=i(a.hideinshadows_base),o=i(a.hideinshadows_racial_mod),r=i(a.hideinshadows_ability_mod),s=i(a.hideinshadows_magic),c=i(a.hideinshadows),l=Math.max(0,Math.min(100,e+o+r+s));n===1&&c>=0&&l===0?t.hideinshadows_base=c:t.hideinshadows=l,h(t,{silent:!0})},Ya=async n=>{let a=await w(["hearnoise","hearnoise_base","hearnoise_racial_mod","hearnoise_ability_mod","hearnoise_magic"]),t={},e=i(a.hearnoise_base),o=i(a.hearnoise_racial_mod),r=i(a.hearnoise_ability_mod),s=i(a.hearnoise_magic),c=i(a.hearnoise),l=Math.max(0,Math.min(100,e+o+r+s));n===1&&c>=0&&l===0?t.hearnoise_base=c:t.hearnoise=l,h(t,{silent:!0})},Za=async n=>{let a=await w(["climbwalls","climbwalls_base","climbwalls_racial_mod","climbwalls_ability_mod","climbwalls_magic"]),t={},e=i(a.climbwalls_base);e=e>=99.1?e.toFixed(1):Math.floor(e);let o=i(a.climbwalls_racial_mod),r=i(a.climbwalls_ability_mod),s=i(a.climbwalls_magic),c=i(a.climbwalls),l=Math.max(0,Math.min(100,e+o+r+s)),p="@{whisper_pc} &{template:general} {{color=@{color_option}}} {{name=@{character_name}}} {{subtag=Climb Walls}} {{roll_low=[[ 1d100 ]]%}} {{roll_target=[[ @{climbwalls} ]]%}}",g="@{whisper_pc} &{template:general} {{color=@{color_option}}} {{name=@{character_name}}} {{subtag=Climb Walls}} {{roll_low=[[ 1d100 + [[1d10/10]] ]]%}} {{roll_target=[[ @{climbwalls} ]]%}}";n===1?c>=0&&l===0?t.climbwalls_base=c:t.climbwalls=l:(t.climbwalls=l,t.climbwalls_macro_text=l>=99.1?g:p),h(t,{silent:!0})},Ja=async n=>{let a=await w(["readlanguages","readlanguages_base","readlanguages_racial_mod","readlanguages_ability_mod","readlanguages_magic"]),t={},e=i(a.readlanguages_base),o=i(a.readlanguages_racial_mod),r=i(a.readlanguages_ability_mod),s=i(a.readlanguages_magic),c=i(a.readlanguages),l=Math.max(0,Math.min(100,e+o+r+s));n===1&&c>=0&&l===0?t.readlanguages_base=c:t.readlanguages=l,h(t,{silent:!0})},et=async()=>{let n=await w(["thiefmisc","thiefmisc_base","thiefmisc_racial_mod","thiefmisc_ability_mod","thiefmisc_magic"]),a={},t=i(n.thiefmisc_base),e=i(n.thiefmisc_racial_mod),o=i(n.thiefmisc_ability_mod),r=i(n.thiefmisc_magic),s=Math.max(0,Math.min(100,t+e+o+r));a.thiefmisc=s,h(a,{silent:!0})},at=async()=>{let n=await w(["thiefmisc1","thiefmisc1_base","thiefmisc1_racial_mod","thiefmisc1_ability_mod","thiefmisc1_magic"]),a={},t=i(n.thiefmisc1_base),e=i(n.thiefmisc1_racial_mod),o=i(n.thiefmisc1_ability_mod),r=i(n.thiefmisc1_magic),s=Math.max(0,Math.min(100,t+e+o+r));a.thiefmisc1=s,h(a,{silent:!0})},tt=async()=>{let n=await w(["thiefmisc2","thiefmisc2_base","thiefmisc2_racial_mod","thiefmisc2_ability_mod","thiefmisc2_magic"]),a={},t=i(n.thiefmisc2_base),e=i(n.thiefmisc2_racial_mod),o=i(n.thiefmisc2_ability_mod),r=i(n.thiefmisc2_magic),s=Math.max(0,Math.min(100,t+e+o+r));a.thiefmisc2=s,h(a,{silent:!0})};on("change:pickpockets_base change:pickpockets_racial_mod change:pickpockets_ability_mod change:pickpockets_magic",async n=>{await Ga()});on("change:openlocks_base change:openlocks_racial_mod change:openlocks_ability_mod change:openlocks_magic",async n=>{await za()});on("change:findtraps_base change:findtraps_racial_mod change:findtraps_ability_mod change:findtraps_magic",async n=>{await Ka()});on("change:movequietly_base change:movequietly_racial_mod change:movequietly_ability_mod change:movequietly_magic",async n=>{await Xa()});on("change:hideinshadows_base change:hideinshadows_racial_mod change:hideinshadows_ability_mod change:hideinshadows_magic",async n=>{await Qa()});on("change:hearnoise_base change:hearnoise_racial_mod change:hearnoise_ability_mod change:hearnoise_magic",async n=>{await Ya()});on("change:climbwalls_base change:climbwalls_racial_mod change:climbwalls_ability_mod change:climbwalls_magic",async n=>{await Za()});on("change:readlanguages_base change:readlanguages_racial_mod change:readlanguages_ability_mod change:readlanguages_magic",async n=>{await Ja()});on("change:thiefmisc_base change:thiefmisc_racial_mod change:thiefmisc_ability_mod change:thiefmisc_magic",async n=>{await et()});on("change:thiefmisc1_base change:thiefmisc1_racial_mod change:thiefmisc1_ability_mod change:thiefmisc1_magic",async n=>{await at()});on("change:thiefmisc2_base change:thiefmisc2_racial_mod change:thiefmisc2_ability_mod change:thiefmisc2_magic",async n=>{await tt()});on("change:thief_level change:autofill_thief change:sync_thief_class change:thief_class_selected change:class change:secondclass change:thirdclass change:level change:level_2 change:level_3",async n=>{let a=await w(["thief_level","autofill_thief","sync_thief_class","thief_class_selected","class","secondclass","thirdclass","level","level_2","level_3"]);if(!i(a.autofill_thief))return;let e={},o=["pickpockets_base","openlocks_base","findtraps_base","movequietly_base","hideinshadows_base","hearnoise_base","climbwalls_base","readlanguages_base"],r={0:[0,0,0,0,0,0,0,0],1:[30,25,20,15,10,10,85,0],2:[35,29,25,21,15,10,86,0],3:[40,33,30,27,20,15,87,0],4:[45,37,35,33,25,15,88,20],5:[50,42,40,40,31,20,90,25],6:[55,47,45,47,37,20,92,30],7:[60,52,50,55,43,25,94,35],8:[65,57,55,62,49,25,96,40],9:[70,62,60,70,56,30,98,45],10:[80,67,65,78,63,30,99,50],11:[90,72,70,86,70,35,99.1,55],12:[100,77,75,94,77,35,99.2,60],13:[105,82,80,99,85,40,99.3,65],14:[110,87,85,99,93,40,99.4,70],15:[115,92,90,99,99,50,99.5,75],16:[125,97,95,99,99,50,99.6,80],17:[125,99,99,99,99,55,99.7,80]},s=i(a.sync_thief_class),c=i(a.thief_class_selected),l=i(a.thief_level);if(s&&c>=1&&c<=3){let u=[a.class,a.secondclass,a.thirdclass],m=[a.level,a.level_2,a.level_3],d=c-1,f=(u[d]||"").trim(),k=+m[d]||0,v=await le(f);l=k,e.thief_level=v===4?l:0}let p=Math.min(Math.max(l,0),17),g=r[p];o.forEach((u,m)=>{e[u]=g[m]}),await h(e,{silent:!0})});var nt=async n=>{let a=await w(["saveparalysispoisondeath","saveparalysispoisondeath_base","saveparalysispoisondeath_racial_mod","saveparalysispoisondeath_ability_mod","saveparalysispoisondeath_misc_mod","saveparalysispoisondeath_temp_mod"]),t={},e=i(a.saveparalysispoisondeath_base),o=i(a.saveparalysispoisondeath_racial_mod),r=i(a.saveparalysispoisondeath_ability_mod),s=i(a.saveparalysispoisondeath_misc_mod),c=i(a.saveparalysispoisondeath_temp_mod),l=i(a.saveparalysispoisondeath),p=e+o+r+s+c;n===1&&l<=20&&p===20?t.saveparalysispoisondeath_base=l:t.saveparalysispoisondeath=p,await h(t,{silent:!0})},ot=async n=>{let a=await w(["savepetrificationpolymorph","savepetrificationpolymorph_base","savepetrificationpolymorph_racial_mod","savepetrificationpolymorph_ability_mod","savepetrificationpolymorph_misc_mod","savepetrificationpolymorph_temp_mod"]),t={},e=i(a.savepetrificationpolymorph_base),o=i(a.savepetrificationpolymorph_racial_mod),r=i(a.savepetrificationpolymorph_ability_mod),s=i(a.savepetrificationpolymorph_misc_mod),c=i(a.savepetrificationpolymorph_temp_mod),l=i(a.savepetrificationpolymorph),p=e+o+r+s+c;n===1&&l<=20&&p===20?t.savepetrificationpolymorph_base=l:t.savepetrificationpolymorph=p,await h(t,{silent:!0})},rt=async n=>{let a=await w(["saverodsstaveswands","saverodsstaveswands_base","saverodsstaveswands_racial_mod","saverodsstaveswands_ability_mod","saverodsstaveswands_misc_mod","saverodsstaveswands_temp_mod"]),t={},e=i(a.saverodsstaveswands_base),o=i(a.saverodsstaveswands_racial_mod),r=i(a.saverodsstaveswands_ability_mod),s=i(a.saverodsstaveswands_misc_mod),c=i(a.saverodsstaveswands_temp_mod),l=i(a.saverodsstaveswands),p=e+o+r+s+c;n===1&&l<=20&&p===20?t.saverodsstaveswands_base=l:t.saverodsstaveswands=p,await h(t,{silent:!0})},st=async n=>{let a=await w(["savebreathweapons","savebreathweapons_base","savebreathweapons_racial_mod","savebreathweapons_ability_mod","savebreathweapons_misc_mod","savebreathweapons_temp_mod"]),t={},e=i(a.savebreathweapons_base),o=i(a.savebreathweapons_racial_mod),r=i(a.savebreathweapons_ability_mod),s=i(a.savebreathweapons_misc_mod),c=i(a.savebreathweapons_temp_mod),l=i(a.savebreathweapons),p=e+o+r+s+c;n===1&&l<=20&&p===20?t.savebreathweapons_base=l:t.savebreathweapons=p,await h(t,{silent:!0})},ct=async n=>{let a=await w(["savespells","savespells_base","savespells_racial_mod","savespells_ability_mod","savespells_misc_mod","savespells_temp_mod"]),t={},e=i(a.savespells_base),o=i(a.savespells_racial_mod),r=i(a.savespells_ability_mod),s=i(a.savespells_misc_mod),c=i(a.savespells_temp_mod),l=i(a.savespells),p=e+o+r+s+c;n===1&&l<=20&&p===20?t.savespells_base=l:t.savespells=p,await h(t,{silent:!0})},ao=async()=>{let n=await w(["savemisc","savemisc_base","savemisc_racial_mod","savemisc_ability_mod","savemisc_misc_mod","savemisc_temp_mod"]),a={},t=i(n.savemisc_base),e=i(n.savemisc_racial_mod),o=i(n.savemisc_ability_mod),r=i(n.savemisc_misc_mod),s=i(n.savemisc_temp_mod),c=t+e+o+r+s;a.savemisc=c,await h(a,{silent:!0})},to=async()=>{let n=await w(["savemisc1","savemisc1_base","savemisc1_racial_mod","savemisc1_ability_mod","savemisc1_misc_mod","savemisc1_temp_mod"]),a={},t=i(n.savemisc1_base),e=i(n.savemisc1_racial_mod),o=i(n.savemisc1_ability_mod),r=i(n.savemisc1_misc_mod),s=i(n.savemisc1_temp_mod),c=t+e+o+r+s;a.savemisc1=c,await h(a,{silent:!0})},no=async()=>{let n=await w(["savemisc2","savemisc2_base","savemisc2_racial_mod","savemisc2_ability_mod","savemisc2_misc_mod","savemisc2_temp_mod"]),a={},t=i(n.savemisc2_base),e=i(n.savemisc2_racial_mod),o=i(n.savemisc2_ability_mod),r=i(n.savemisc2_misc_mod),s=i(n.savemisc2_temp_mod),c=t+e+o+r+s;a.savemisc2=c,await h(a,{silent:!0})};on("change:saveparalysispoisondeath_base change:saveparalysispoisondeath_racial_mod change:saveparalysispoisondeath_ability_mod change:saveparalysispoisondeath_misc_mod change:saveparalysispoisondeath_temp_mod",async n=>{await nt()});on("change:savepetrificationpolymorph_base change:savepetrificationpolymorph_racial_mod change:savepetrificationpolymorph_ability_mod change:savepetrificationpolymorph_misc_mod change:savepetrificationpolymorph_temp_mod",async n=>{await ot()});on("change:saverodsstaveswands_base change:saverodsstaveswands_racial_mod change:saverodsstaveswands_ability_mod change:saverodsstaveswands_misc_mod change:saverodsstaveswands_temp_mod",async n=>{await rt()});on("change:savebreathweapons_base change:savebreathweapons_racial_mod change:savebreathweapons_ability_mod change:savebreathweapons_misc_mod change:savebreathweapons_temp_mod",async n=>{await st()});on("change:savespells_base change:savespells_racial_mod change:savespells_ability_mod change:savespells_misc_mod change:savespells_temp_mod",async n=>{await ct()});on("change:savemisc_base change:savemisc_racial_mod change:savemisc_ability_mod change:savemisc_misc_mod change:savemisc_temp_mod",async n=>{await ao()});on("change:savemisc1_base change:savemisc1_racial_mod change:savemisc1_ability_mod change:savemisc1_misc_mod change:savemisc1_temp_mod",async n=>{await to()});on("change:savemisc2_base change:savemisc2_racial_mod change:savemisc2_ability_mod change:savemisc2_misc_mod change:savemisc2_temp_mod",async n=>{await no()});on("change:saves_class change:saves_level change:autofill_saves",async n=>{let a=await w(["saves_class","saves_level","autofill_saves"]);if(!i(a.autofill_saves))return;let e=i(a.saves_class);if(!e)return;let o=["saveparalysispoisondeath_base","savepetrificationpolymorph_base","saverodsstaveswands_base","savebreathweapons_base","savespells_base"],r={assassin:[{lvl:5,s:[13,12,14,16,15]},{lvl:9,s:[12,11,12,15,13]},{lvl:13,s:[11,10,10,14,11]},{lvl:16,s:[10,9,8,13,9]},{lvl:99,s:[10,9,8,13,9]}],cleric:[{lvl:4,s:[10,13,14,16,15]},{lvl:7,s:[9,12,13,15,14]},{lvl:10,s:[7,10,11,13,12]},{lvl:13,s:[6,9,10,12,11]},{lvl:16,s:[5,8,9,11,10]},{lvl:19,s:[4,7,8,10,9]},{lvl:99,s:[2,5,6,8,7]}],druid:[{lvl:4,s:[10,13,14,16,15]},{lvl:7,s:[9,12,13,15,14]},{lvl:10,s:[7,10,11,13,12]},{lvl:13,s:[6,9,10,12,11]},{lvl:15,s:[5,8,9,11,10]},{lvl:99,s:[5,8,9,11,10]}],fighter:[{lvl:1,s:[16,17,18,20,19]},{lvl:3,s:[14,15,16,17,17]},{lvl:5,s:[13,14,15,16,16]},{lvl:7,s:[11,12,13,13,14]},{lvl:9,s:[10,11,12,12,13]},{lvl:11,s:[8,9,10,9,11]},{lvl:13,s:[7,8,9,8,10]},{lvl:15,s:[5,6,7,5,8]},{lvl:17,s:[4,5,6,4,7]},{lvl:99,s:[3,4,5,4,6]}],magicuser:[{lvl:6,s:[14,13,11,15,12]},{lvl:11,s:[13,11,9,13,10]},{lvl:16,s:[11,9,7,11,8]},{lvl:21,s:[10,7,5,9,6]},{lvl:99,s:[8,5,3,7,4]}],thief:[{lvl:5,s:[13,12,14,16,15]},{lvl:9,s:[12,11,12,15,13]},{lvl:13,s:[11,10,10,14,11]},{lvl:17,s:[10,9,8,13,9]},{lvl:21,s:[9,8,6,12,7]},{lvl:99,s:[8,7,4,11,5]}]},c={1:r.cleric,2:r.druid,3:r.fighter,4:r.magicuser,5:r.thief,6:r.thief,7:r.assassin,8:r.fighter}[e];if(!c)return;let l=i(a.saves_level),p=c.find(u=>l{g[u]=p.s[m]}),await h(g)});on("change:matrix_class",async n=>{let a=await w(["matrix_class"]),t={},e=i(a.matrix_class);t.toggle_matrixhd=e===5?1:0,await h(t,{silent:!0})});var le=async n=>{let a=n.trim().toLowerCase();return/cleric|druid|monk/.test(a)?1:/fighter|paladin|ranger|bard|cavalier|barbarian/.test(a)?2:/magic-user|illusionist|magic|mage|wizard/.test(a)?3:/thief|assassin|rogue|thief-acrobat|acrobat/.test(a)?4:99},it=async n=>{let a=await w(["thac00","autofill_matrix"]);if(!i(a.autofill_matrix)||i(a.matrix_level)===0&&n===99)return;let o={},r=i(a.thac00);o["thac0-10"]=r+10,o["thac0-9"]=r+9,o["thac0-8"]=r+8,o["thac0-7"]=r+7,o["thac0-6"]=r+6,o["thac0-5"]=r+5,o["thac0-4"]=r+4,o["thac0-3"]=r+3,o["thac0-2"]=r+2,o["thac0-1"]=r+1,o.thac01=r-1,o.thac02=r-2,o.thac03=r-3,o.thac04=r-4,o.thac05=r-5,o.thac06=r-6,o.thac07=r-7,o.thac08=r-8,o.thac09=r-9,o.thac010=r-10,await h(o,{silent:!0})};on("change:matrix_class change:matrix_level change:matrix_hitdice change:autofill_matrix change:sync_matrix_class change:toggle_fighter5 change:class_selected change:class change:secondclass change:thirdclass change:level change:level_2 change:level_3",async n=>{let a=await w(["matrix_class","matrix_level","matrix_hitdice","autofill_matrix","toggle_fighter5","sync_matrix_class","class_selected","class","secondclass","thirdclass","level","level_2","level_3"]);if(!i(a.autofill_matrix))return;let e={},o=i(a.sync_matrix_class),r=i(a.class_selected),s=i(a.matrix_level),c=i(a.matrix_class),l=(a.class||"").trim(),p=(a.secondclass||"").trim(),g=(a.thirdclass||"").trim(),u=i(a.matrix_hitdice),m=i(a.toggle_fighter5);o&&(r===1&&(c=await le(l),s=i(a.level),e.matrix_level=s,e.matrix_class=c),r===2&&(c=await le(p),s=i(a.level_2),e.matrix_level=s,e.matrix_class=c),r===3&&(c=await le(g),s=i(a.level_3),e.matrix_level=s,e.matrix_class=c)),c!==0&&(c===1&&(s===0||(s<4?(e["thac-10"]=25,e["thac-9"]=24,e["thac-8"]=23,e["thac-7"]=22,e["thac-6"]=21,e["thac-5"]=20,e["thac-4"]=20,e["thac-3"]=20,e["thac-2"]=20,e["thac-1"]=20,e.thac00=20,e.thac0=20,e.thac1=19,e.thac2=18,e.thac3=17,e.thac4=16,e.thac5=15,e.thac6=14,e.thac7=13,e.thac8=12,e.thac9=11,e.thac10=10):s<7?(e["thac-10"]=23,e["thac-9"]=22,e["thac-8"]=21,e["thac-7"]=20,e["thac-6"]=20,e["thac-5"]=20,e["thac-4"]=20,e["thac-3"]=20,e["thac-2"]=20,e["thac-1"]=19,e.thac00=18,e.thac0=18,e.thac1=17,e.thac2=16,e.thac3=15,e.thac4=14,e.thac5=13,e.thac6=12,e.thac7=11,e.thac8=10,e.thac9=9,e.thac10=8):s<10?(e["thac-10"]=21,e["thac-9"]=20,e["thac-8"]=20,e["thac-7"]=20,e["thac-6"]=20,e["thac-5"]=20,e["thac-4"]=20,e["thac-3"]=19,e["thac-2"]=18,e["thac-1"]=17,e.thac00=16,e.thac0=16,e.thac1=15,e.thac2=14,e.thac3=13,e.thac4=12,e.thac5=11,e.thac6=10,e.thac7=9,e.thac8=8,e.thac9=7,e.thac10=6):s<13?(e["thac-10"]=20,e["thac-9"]=20,e["thac-8"]=20,e["thac-7"]=20,e["thac-6"]=20,e["thac-5"]=19,e["thac-4"]=18,e["thac-3"]=17,e["thac-2"]=16,e["thac-1"]=15,e.thac00=14,e.thac0=14,e.thac1=13,e.thac2=12,e.thac3=11,e.thac4=10,e.thac5=9,e.thac6=8,e.thac7=7,e.thac8=6,e.thac9=5,e.thac10=4):s<16?(e["thac-10"]=20,e["thac-9"]=20,e["thac-8"]=20,e["thac-7"]=19,e["thac-6"]=18,e["thac-5"]=17,e["thac-4"]=16,e["thac-3"]=15,e["thac-2"]=14,e["thac-1"]=13,e.thac00=12,e.thac0=12,e.thac1=11,e.thac2=10,e.thac3=9,e.thac4=8,e.thac5=7,e.thac6=6,e.thac7=5,e.thac8=4,e.thac9=3,e.thac10=2):s<19?(e["thac-10"]=20,e["thac-9"]=19,e["thac-8"]=18,e["thac-7"]=17,e["thac-6"]=16,e["thac-5"]=15,e["thac-4"]=14,e["thac-3"]=13,e["thac-2"]=12,e["thac-1"]=11,e.thac00=10,e.thac0=10,e.thac1=9,e.thac2=8,e.thac3=7,e.thac4=6,e.thac5=5,e.thac6=4,e.thac7=3,e.thac8=2,e.thac9=1,e.thac10=0):s>=19&&(e["thac-10"]=19,e["thac-9"]=18,e["thac-8"]=17,e["thac-7"]=16,e["thac-6"]=15,e["thac-5"]=14,e["thac-4"]=13,e["thac-3"]=12,e["thac-2"]=11,e["thac-1"]=10,e.thac00=9,e.thac0=9,e.thac1=8,e.thac2=7,e.thac3=6,e.thac4=5,e.thac5=4,e.thac6=3,e.thac7=2,e.thac8=1,e.thac9=0,e.thac10=-1)),e.attack_matrix_flag=0),(c===2||c===6)&&(s===0?(e["thac-10"]=26,e["thac-9"]=25,e["thac-8"]=24,e["thac-7"]=23,e["thac-6"]=22,e["thac-5"]=21,e["thac-4"]=20,e["thac-3"]=20,e["thac-2"]=20,e["thac-1"]=20,e.thac00=20,e.thac0=20,e.thac1=20,e.thac2=19,e.thac3=18,e.thac4=17,e.thac5=16,e.thac6=15,e.thac7=14,e.thac8=13,e.thac9=12,e.thac10=11):s<3?(e["thac-10"]=25-m,e["thac-9"]=24-m,e["thac-8"]=23-m,e["thac-7"]=22-m,e["thac-6"]=21-m,e["thac-5"]=20,e["thac-4"]=20,e["thac-3"]=20,e["thac-2"]=20,e["thac-1"]=20,e.thac00=20-m,e.thac0=20-m,e.thac1=19-m,e.thac2=18-m,e.thac3=17-m,e.thac4=16-m,e.thac5=15-m,e.thac6=14-m,e.thac7=13-m,e.thac8=12-m,e.thac9=11-m,e.thac10=10-m):s<5?(e["thac-10"]=23-m,e["thac-9"]=22-m,e["thac-8"]=21-m,e["thac-7"]=20,e["thac-6"]=20,e["thac-5"]=20,e["thac-4"]=20,e["thac-3"]=20,e["thac-2"]=20-m,e["thac-1"]=19-m,e.thac00=18-m,e.thac0=18-m,e.thac1=17-m,e.thac2=16-m,e.thac3=15-m,e.thac4=14-m,e.thac5=13-m,e.thac6=12-m,e.thac7=11-m,e.thac8=10-m,e.thac9=9-m,e.thac10=8-m):s<7?(e["thac-10"]=21-m,e["thac-9"]=20,e["thac-8"]=20,e["thac-7"]=20,e["thac-6"]=20,e["thac-5"]=20,e["thac-4"]=20-m,e["thac-3"]=19-m,e["thac-2"]=18-m,e["thac-1"]=17-m,e.thac00=16-m,e.thac0=16-m,e.thac1=15-m,e.thac2=14-m,e.thac3=13-m,e.thac4=12-m,e.thac5=11-m,e.thac6=10-m,e.thac7=9-m,e.thac8=8-m,e.thac9=7-m,e.thac10=6-m):s<9?(e["thac-10"]=20,e["thac-9"]=20,e["thac-8"]=20,e["thac-7"]=20,e["thac-6"]=20-m,e["thac-5"]=19-m,e["thac-4"]=18-m,e["thac-3"]=17-m,e["thac-2"]=16-m,e["thac-1"]=15-m,e.thac00=14-m,e.thac0=14-m,e.thac1=13-m,e.thac2=12-m,e.thac3=11-m,e.thac4=10-m,e.thac5=9-m,e.thac6=8-m,e.thac7=7-m,e.thac8=6-m,e.thac9=5-m,e.thac10=4-m):s<11?(e["thac-10"]=20,e["thac-9"]=20,e["thac-8"]=20-m,e["thac-7"]=19-m,e["thac-6"]=18-m,e["thac-5"]=17-m,e["thac-4"]=16-m,e["thac-3"]=15-m,e["thac-2"]=14-m,e["thac-1"]=13-m,e.thac00=12-m,e.thac0=12-m,e.thac1=11-m,e.thac2=10-m,e.thac3=9-m,e.thac4=8-m,e.thac5=7-m,e.thac6=6-m,e.thac7=5-m,e.thac8=4-m,e.thac9=3-m,e.thac10=2-m):s<13?(e["thac-10"]=20-m,e["thac-9"]=19-m,e["thac-8"]=18-m,e["thac-7"]=17-m,e["thac-6"]=16-m,e["thac-5"]=15-m,e["thac-4"]=14-m,e["thac-3"]=13-m,e["thac-2"]=12-m,e["thac-1"]=11-m,e.thac00=10-m,e.thac0=10-m,e.thac1=9-m,e.thac2=8-m,e.thac3=7-m,e.thac4=6-m,e.thac5=5-m,e.thac6=4-m,e.thac7=3-m,e.thac8=2-m,e.thac9=1-m,e.thac10=0-m):s<15?(e["thac-10"]=18-m,e["thac-9"]=17-m,e["thac-8"]=16-m,e["thac-7"]=15-m,e["thac-6"]=14-m,e["thac-5"]=13-m,e["thac-4"]=12-m,e["thac-3"]=11-m,e["thac-2"]=10-m,e["thac-1"]=9-m,e.thac00=8-m,e.thac0=8-m,e.thac1=7-m,e.thac2=6-m,e.thac3=5-m,e.thac4=4-m,e.thac5=3-m,e.thac6=2-m,e.thac7=1-m,e.thac8=0-m,e.thac9=-1-m,e.thac10=-2-m):s<17?(e["thac-10"]=16-m,e["thac-9"]=15-m,e["thac-8"]=14-m,e["thac-7"]=13-m,e["thac-6"]=12-m,e["thac-5"]=11-m,e["thac-4"]=10-m,e["thac-3"]=9-m,e["thac-2"]=8-m,e["thac-1"]=7-m,e.thac00=6-m,e.thac0=6-m,e.thac1=5-m,e.thac2=4-m,e.thac3=3-m,e.thac4=2-m,e.thac5=1-m,e.thac6=0-m,e.thac7=-1-m,e.thac8=-2-m,e.thac9=-3-m,e.thac10=-4-m):s>=17&&(e["thac-10"]=14-m,e["thac-9"]=13-m,e["thac-8"]=12-m,e["thac-7"]=11-m,e["thac-6"]=10-m,e["thac-5"]=9-m,e["thac-4"]=8-m,e["thac-3"]=7-m,e["thac-2"]=6-m,e["thac-1"]=5-m,e.thac00=4-m,e.thac0=4-m,e.thac1=3-m,e.thac2=2-m,e.thac3=1-m,e.thac4=0-m,e.thac5=-1-m,e.thac6=-2-m,e.thac7=-3-m,e.thac8=-4-m,e.thac9=-5-m,e.thac10=-6-m),e.attack_matrix_flag=0),c===3&&(s===0||(s<6?(e["thac-10"]=26,e["thac-9"]=25,e["thac-8"]=24,e["thac-7"]=23,e["thac-6"]=22,e["thac-5"]=21,e["thac-4"]=20,e["thac-3"]=20,e["thac-2"]=20,e["thac-1"]=20,e.thac00=20,e.thac0=20,e.thac1=20,e.thac2=19,e.thac3=18,e.thac4=17,e.thac5=16,e.thac6=15,e.thac7=14,e.thac8=13,e.thac9=12,e.thac10=11):s<11?(e["thac-10"]=24,e["thac-9"]=23,e["thac-8"]=22,e["thac-7"]=21,e["thac-6"]=20,e["thac-5"]=20,e["thac-4"]=20,e["thac-3"]=20,e["thac-2"]=20,e["thac-1"]=20,e.thac00=19,e.thac0=19,e.thac1=18,e.thac2=17,e.thac3=16,e.thac4=15,e.thac5=14,e.thac6=13,e.thac7=12,e.thac8=11,e.thac9=10,e.thac10=9):s<16?(e["thac-10"]=21,e["thac-9"]=20,e["thac-8"]=20,e["thac-7"]=20,e["thac-6"]=20,e["thac-5"]=20,e["thac-4"]=20,e["thac-3"]=19,e["thac-2"]=18,e["thac-1"]=17,e.thac00=16,e.thac0=16,e.thac1=15,e.thac2=14,e.thac3=13,e.thac4=12,e.thac5=11,e.thac6=10,e.thac7=9,e.thac8=8,e.thac9=7,e.thac10=6):s<21?(e["thac-10"]=20,e["thac-9"]=20,e["thac-8"]=20,e["thac-7"]=20,e["thac-6"]=19,e["thac-5"]=18,e["thac-4"]=17,e["thac-3"]=16,e["thac-2"]=15,e["thac-1"]=14,e.thac00=13,e.thac0=13,e.thac1=12,e.thac2=11,e.thac3=10,e.thac4=9,e.thac5=8,e.thac6=7,e.thac7=6,e.thac8=5,e.thac9=4,e.thac10=3):s>=21&&(e["thac-10"]=20,e["thac-9"]=20,e["thac-8"]=19,e["thac-7"]=18,e["thac-6"]=17,e["thac-5"]=16,e["thac-4"]=15,e["thac-3"]=14,e["thac-2"]=13,e["thac-1"]=12,e.thac00=11,e.thac0=11,e.thac1=10,e.thac2=9,e.thac3=8,e.thac4=7,e.thac5=6,e.thac6=5,e.thac7=4,e.thac8=3,e.thac9=2,e.thac10=1)),e.attack_matrix_flag=0),c===4&&(s===0||(s<5?(e["thac-10"]=26,e["thac-9"]=25,e["thac-8"]=24,e["thac-7"]=23,e["thac-6"]=22,e["thac-5"]=21,e["thac-4"]=20,e["thac-3"]=20,e["thac-2"]=20,e["thac-1"]=20,e.thac00=20,e.thac0=20,e.thac1=20,e.thac2=19,e.thac3=18,e.thac4=17,e.thac5=16,e.thac6=15,e.thac7=14,e.thac8=13,e.thac9=12,e.thac10=11):s<9?(e["thac-10"]=24,e["thac-9"]=23,e["thac-8"]=22,e["thac-7"]=21,e["thac-6"]=20,e["thac-5"]=20,e["thac-4"]=20,e["thac-3"]=20,e["thac-2"]=20,e["thac-1"]=20,e.thac00=19,e.thac0=19,e.thac1=18,e.thac2=17,e.thac3=16,e.thac4=15,e.thac5=14,e.thac6=13,e.thac7=12,e.thac8=11,e.thac9=10,e.thac10=9):s<13?(e["thac-10"]=21,e["thac-9"]=20,e["thac-8"]=20,e["thac-7"]=20,e["thac-6"]=20,e["thac-5"]=20,e["thac-4"]=20,e["thac-3"]=19,e["thac-2"]=18,e["thac-1"]=17,e.thac00=16,e.thac0=16,e.thac1=15,e.thac2=14,e.thac3=13,e.thac4=12,e.thac5=11,e.thac6=10,e.thac7=9,e.thac8=8,e.thac9=7,e.thac10=6):s<17?(e["thac-10"]=20,e["thac-9"]=20,e["thac-8"]=20,e["thac-7"]=20,e["thac-6"]=20,e["thac-5"]=19,e["thac-4"]=18,e["thac-3"]=17,e["thac-2"]=16,e["thac-1"]=15,e.thac00=14,e.thac0=14,e.thac1=13,e.thac2=12,e.thac3=11,e.thac4=10,e.thac5=9,e.thac6=8,e.thac7=7,e.thac8=6,e.thac9=5,e.thac10=4):s<21?(e["thac-10"]=20,e["thac-9"]=20,e["thac-8"]=20,e["thac-7"]=19,e["thac-6"]=18,e["thac-5"]=17,e["thac-4"]=16,e["thac-3"]=15,e["thac-2"]=14,e["thac-1"]=13,e.thac00=12,e.thac0=12,e.thac1=11,e.thac2=10,e.thac3=9,e.thac4=8,e.thac5=7,e.thac6=6,e.thac7=5,e.thac8=4,e.thac9=3,e.thac10=2):s>=21&&(e["thac-10"]=20,e["thac-9"]=19,e["thac-8"]=18,e["thac-7"]=17,e["thac-6"]=16,e["thac-5"]=15,e["thac-4"]=14,e["thac-3"]=13,e["thac-2"]=12,e["thac-1"]=11,e.thac00=10,e.thac0=10,e.thac1=9,e.thac2=8,e.thac3=7,e.thac4=6,e.thac5=5,e.thac6=4,e.thac7=3,e.thac8=2,e.thac9=1,e.thac10=0)),e.attack_matrix_flag=0),c===5&&(u===0||(u===1?(e["thac-10"]=26,e["thac-9"]=25,e["thac-8"]=24,e["thac-7"]=23,e["thac-6"]=22,e["thac-5"]=21,e["thac-4"]=20,e["thac-3"]=20,e["thac-2"]=20,e["thac-1"]=20,e.thac00=20,e.thac0=20,e.thac1=20,e.thac2=19,e.thac3=18,e.thac4=17,e.thac5=16,e.thac6=15,e.thac7=14,e.thac8=13,e.thac9=12,e.thac10=11):u===2?(e["thac-10"]=25,e["thac-9"]=24,e["thac-8"]=23,e["thac-7"]=22,e["thac-6"]=21,e["thac-5"]=20,e["thac-4"]=20,e["thac-3"]=20,e["thac-2"]=20,e["thac-1"]=20,e.thac00=20,e.thac0=20,e.thac1=19,e.thac2=18,e.thac3=17,e.thac4=16,e.thac5=15,e.thac6=14,e.thac7=13,e.thac8=12,e.thac9=11,e.thac10=10):u===3?(e["thac-10"]=24,e["thac-9"]=23,e["thac-8"]=22,e["thac-7"]=21,e["thac-6"]=20,e["thac-5"]=20,e["thac-4"]=20,e["thac-3"]=20,e["thac-2"]=20,e["thac-1"]=20,e.thac00=19,e.thac0=19,e.thac1=18,e.thac2=17,e.thac3=16,e.thac4=15,e.thac5=14,e.thac6=13,e.thac7=12,e.thac8=11,e.thac9=10,e.thac10=9):u===4?(e["thac-10"]=23,e["thac-9"]=22,e["thac-8"]=21,e["thac-7"]=20,e["thac-6"]=20,e["thac-5"]=20,e["thac-4"]=20,e["thac-3"]=20,e["thac-2"]=20,e["thac-1"]=19,e.thac00=18,e.thac0=18,e.thac1=17,e.thac2=16,e.thac3=15,e.thac4=14,e.thac5=13,e.thac6=12,e.thac7=11,e.thac8=10,e.thac9=9,e.thac10=8):u===5?(e["thac-10"]=21,e["thac-9"]=20,e["thac-8"]=20,e["thac-7"]=20,e["thac-6"]=20,e["thac-5"]=20,e["thac-4"]=20,e["thac-3"]=19,e["thac-2"]=18,e["thac-1"]=17,e.thac00=16,e.thac0=16,e.thac1=15,e.thac2=14,e.thac3=13,e.thac4=12,e.thac5=11,e.thac6=10,e.thac7=9,e.thac8=8,e.thac9=7,e.thac10=6):u===6?(e["thac-10"]=20,e["thac-9"]=20,e["thac-8"]=20,e["thac-7"]=20,e["thac-6"]=20,e["thac-5"]=20,e["thac-4"]=19,e["thac-3"]=18,e["thac-2"]=17,e["thac-1"]=16,e.thac00=15,e.thac0=15,e.thac1=14,e.thac2=13,e.thac3=12,e.thac4=11,e.thac5=10,e.thac6=9,e.thac7=8,e.thac8=7,e.thac9=6,e.thac10=5):u===7?(e["thac-10"]=20,e["thac-9"]=20,e["thac-8"]=20,e["thac-7"]=20,e["thac-6"]=19,e["thac-5"]=18,e["thac-4"]=17,e["thac-3"]=16,e["thac-2"]=15,e["thac-1"]=14,e.thac00=13,e.thac0=13,e.thac1=12,e.thac2=11,e.thac3=10,e.thac4=9,e.thac5=8,e.thac6=7,e.thac7=6,e.thac8=5,e.thac9=4,e.thac10=3):u===8?(e["thac-10"]=20,e["thac-9"]=20,e["thac-8"]=20,e["thac-7"]=19,e["thac-6"]=18,e["thac-5"]=17,e["thac-4"]=16,e["thac-3"]=15,e["thac-2"]=14,e["thac-1"]=13,e.thac00=12,e.thac0=12,e.thac1=11,e.thac2=10,e.thac3=9,e.thac4=8,e.thac5=7,e.thac6=6,e.thac7=5,e.thac8=4,e.thac9=3,e.thac10=2):u===9?(e["thac-10"]=20,e["thac-9"]=19,e["thac-8"]=18,e["thac-7"]=17,e["thac-6"]=16,e["thac-5"]=15,e["thac-4"]=14,e["thac-3"]=13,e["thac-2"]=12,e["thac-1"]=11,e.thac00=10,e.thac0=10,e.thac1=9,e.thac2=8,e.thac3=7,e.thac4=6,e.thac5=5,e.thac6=4,e.thac7=3,e.thac8=2,e.thac9=1,e.thac10=0):u===10?(e["thac-10"]=19,e["thac-9"]=18,e["thac-8"]=17,e["thac-7"]=16,e["thac-6"]=15,e["thac-5"]=14,e["thac-4"]=13,e["thac-3"]=12,e["thac-2"]=11,e["thac-1"]=10,e.thac00=9,e.thac0=9,e.thac1=8,e.thac2=7,e.thac3=6,e.thac4=5,e.thac5=4,e.thac6=3,e.thac7=2,e.thac8=1,e.thac9=0,e.thac10=-1):u===11?(e["thac-10"]=18,e["thac-9"]=17,e["thac-8"]=16,e["thac-7"]=15,e["thac-6"]=14,e["thac-5"]=13,e["thac-4"]=12,e["thac-3"]=11,e["thac-2"]=10,e["thac-1"]=9,e.thac00=8,e.thac0=8,e.thac1=7,e.thac2=6,e.thac3=5,e.thac4=4,e.thac5=3,e.thac6=2,e.thac7=1,e.thac8=0,e.thac9=-1,e.thac10=-2):u===12&&(e["thac-10"]=17,e["thac-9"]=16,e["thac-8"]=15,e["thac-7"]=14,e["thac-6"]=13,e["thac-5"]=12,e["thac-4"]=11,e["thac-3"]=10,e["thac-2"]=9,e["thac-1"]=8,e.thac00=7,e.thac0=7,e.thac1=6,e.thac2=5,e.thac3=4,e.thac4=3,e.thac5=2,e.thac6=1,e.thac7=0,e.thac8=-1,e.thac9=-2,e.thac10=-3)),e.attack_matrix_flag=0),c===99&&(console.error("Error: Class not recognized or class name is empty."),e["thac-10"]=20,e["thac-9"]=20,e["thac-8"]=20,e["thac-7"]=20,e["thac-6"]=20,e["thac-5"]=20,e["thac-4"]=20,e["thac-3"]=20,e["thac-2"]=20,e["thac-1"]=20,e.thac00=20,e.thac0=20,e.thac1=20,e.thac2=20,e.thac3=20,e.thac4=20,e.thac5=20,e.thac6=20,e.thac7=20,e.thac8=20,e.thac9=20,e.thac10=20,e.attack_matrix_flag=0),await h(e,{silent:!0}),await it(c))});on("sheet:opened change:thac0 change:thac00 change:autofill_matrix change:sync_matrix_level change:sync_matrix_class change:sync_class_selected",async n=>{let a=await w(["thac0","thac1","thac2","thac00","thac01","thac02","autofill_matrix"]);if(!i(a.autofill_matrix))return;let e={},o=i(a.thac0),r=i(a.thac1),s=i(a.thac2),c=i(a.thac00),l=i(a.thac01),p=i(a.thac02),g=o+r+s,u=c+l+p;e.attack_matrix_flag=g===60&&u===60?1:0,await h(e,{silent:!0})});on("change:thac00",async n=>{await it()});on("change:sync_caster_class1 change:sync_caster_class2 change:caster_class1_selected change:caster_class2_selected change:class change:secondclass change:thirdclass change:level change:level_2 change:level_3",async n=>{let a=await w(["sync_caster_class1","sync_caster_class2","caster_class1_selected","caster_class2_selected","class","secondclass","thirdclass","level","level_2","level_3"]),t={},e=i(a.sync_caster_class1),o=i(a.sync_caster_class2),r=i(a.caster_class1_selected),s=i(a.caster_class2_selected),c=(a.class||"").trim(),l=(a.secondclass||"").trim(),p=(a.thirdclass||"").trim(),g=i(a.level),u=i(a.level_2),m=i(a.level_3);e&&(r===1&&(t.caster_class1_level=g,t.caster_class1_name=c),r===2&&(t.caster_class1_level=u,t.caster_class1_name=l),r===3&&(t.caster_class1_level=m,t.caster_class1_name=p)),o&&(s===1&&(t.caster_class2_level=g,t.caster_class2_name=c),s===2&&(t.caster_class2_level=u,t.caster_class2_name=l),s===3&&(t.caster_class2_level=u,t.caster_class2_name=p)),await h(t,{silent:!0}),await Pe()});var j=(n,a,t,e)=>ne?(console.log(`WARNING: ${a} value is out of range. [${n}]. Defaulting to ${e}.`),e):Math.min(Math.max(n,t),e),q=class{constructor(a,t,e,o,r,s){this.meleebonus=a,this.dmgbonus=t,this.majorstrengthfeat=s,this.minorstrengthfeat=o,this.minorstrengthfeat_locked=r,this.encumbrancebonus=e}getMeleeAttackBonus(){return this.meleebonus}getMeleeDamageBonus(){return this.dmgbonus}getMajorStrengthCheck(){return this.majorstrengthfeat}getMinorStrengthCheck(a=!1){return a?this.minorstrengthfeat_locked:this.minorstrengthfeat}getEncumbranceBonus(){return this.encumbrancebonus}},Se=class{constructor(){this.strength_dict={3:new q(-3,-1,-350,1,0,0),4:new q(-2,-1,-250,1,0,0),5:new q(-2,-1,-250,1,0,0),6:new q(-1,0,-150,1,0,0),7:new q(-1,0,-150,1,0,0),8:new q(0,0,0,2,0,1),9:new q(0,0,0,2,0,1),10:new q(0,0,0,2,0,2),11:new q(0,0,0,2,0,2),12:new q(0,0,100,2,0,4),13:new q(0,0,100,2,0,4),14:new q(0,0,200,2,0,7),15:new q(0,0,200,2,0,7),16:new q(0,1,350,3,0,10),17:new q(1,1,500,3,0,13),18:{None:new q(1,2,750,3,0,16),"01-50":new q(1,3,1e3,3,0,20),"51-75":new q(2,3,1250,4,0,25),"76-90":new q(2,4,1500,4,0,30),"91-99":new q(2,5,2e3,4,1,35),"00":new q(3,6,3e3,5,2,40)},19:new q(3,7,4500,7,3,50),20:new q(3,8,5e3,7,3,60),21:new q(4,9,6e3,9,4,70),22:new q(4,10,7500,11,4,80),23:new q(5,11,9e3,11,5,90),24:new q(6,12,12e3,19,7,100),25:new q(7,14,15e3,23,9,100)}}getEntry(a,t){let e=j(a,"strength",3,25);return e!==18?this.strength_dict[e]:t<=0?this.strength_dict[e].None:t<=50?this.strength_dict[e]["01-50"]:t<=75?this.strength_dict[e]["51-75"]:t<=90?this.strength_dict[e]["76-90"]:t<=99?this.strength_dict[e]["91-99"]:this.strength_dict[e]["00"]}getStrengthValue(a,t,e=0,o=!1){switch(a){case"Attack":return this.getEntry(t,e).getMeleeAttackBonus();case"Damage":return this.getEntry(t,e).getMeleeDamageBonus();case"Major":return this.getEntry(t,e).getMajorStrengthCheck();case"Minor":return this.getEntry(t,e).getMinorStrengthCheck(o);case"Encumbrance":return this.getEntry(t,e).getEncumbranceBonus();default:return console.log("WARNING: Invalid Test."),"Invalid Test"}}},A=class{constructor(a,t,e,o){this.bonuslanguages=a,this.knowspell=t,this.minspells=e,this.maxspells=o}getBonusLanguages(){return this.bonuslanguages}getKnowSpell(){return this.knowspell}getMinSpells(){return this.minspells}getMaxSpells(){return this.maxspells}},Ne=class{constructor(){this.intelligence_dict={3:new A(0,0,0,0),4:new A(0,0,0,0),5:new A(0,0,0,0),6:new A(0,0,0,0),7:new A(0,0,0,0),8:new A(1,0,0,0),9:new A(1,35,4,6),10:new A(2,45,5,7),11:new A(2,45,5,7),12:new A(3,45,5,7),13:new A(3,55,6,9),14:new A(4,55,6,9),15:new A(4,65,7,11),16:new A(5,65,7,11),17:new A(6,75,8,14),18:new A(7,85,9,18),19:new A(8,95,10,99),20:new A(9,96,11,99),21:new A(10,97,12,99),22:new A(11,98,13,99),23:new A(12,99,14,99),24:new A(13,100,15,99),25:new A(14,100,16,99)}}getEntry(a){return this.intelligence_dict[j(a,"intelligence",3,25)]}},M=class{constructor(a,t,e){this.mentalsavebonus=a,this.spellbonus=t,this.spellfailure=e}getMentalSaveBonus(){return this.mentalsavebonus}getSpellBonus(){return this.spellbonus}getSpellFailure(){return this.spellfailure}},Ce=class{constructor(){this.wisdom_dict={3:new M("-3","None",20),4:new M("-2","None",20),5:new M("-1","None",20),6:new M("-1","None",20),7:new M("-1","None",20),8:new M("0","None",20),9:new M("0","None",20),10:new M("0","None",15),11:new M("0","None",10),12:new M("0","None",5),13:new M("0","1/0/0/0/0/0/0",0),14:new M("0","2/0/0/0/0/0/0",0),15:new M("1","2/1/0/0/0/0/0",0),16:new M("2","2/2/0/0/0/0/0",0),17:new M("3","2/2/1/0/0/0/0",0),18:new M("4","2/2/1/1/0/0/0",0),19:new M("4","3/2/1/2/0/0/0",0),20:new M("4","3/3/1/3/0/0/0",0),21:new M("4","3/3/2/3/1/0/0",0),22:new M("4","3/3/2/4/2/0/0",0),23:new M("4","3/3/2/4/4/0/0",0),24:new M("4","3/3/2/4/4/2/1",0),25:new M("4","3/3/2/4/4/3/1",0)}}getEntry(a){return this.wisdom_dict[j(a,"wisdom",3,25)]}},x=class{constructor(a,t,e){this.surprisebonus=a,this.rangedbonus=t,this.armorbonus=e}getSurpriseBonus(){return this.surprisebonus}getRangedBonus(){return this.rangedbonus}getArmorBonus(){return this.armorbonus}},De=class{constructor(){this.dexterity_dict={3:new x(3,-3,4),4:new x(2,-2,3),5:new x(1,-1,2),6:new x(0,0,1),7:new x(0,0,0),8:new x(0,0,0),9:new x(0,0,0),10:new x(0,0,0),11:new x(0,0,0),12:new x(0,0,0),13:new x(0,0,0),14:new x(0,0,0),15:new x(0,0,-1),16:new x(-1,1,-2),17:new x(-2,2,-3),18:new x(-3,3,-4),19:new x(-3,3,-4),20:new x(-3,3,-4),21:new x(-4,4,-5),22:new x(-4,4,-5),23:new x(-4,4,-5),24:new x(-5,5,-6),25:new x(-5,5,-6)}}getEntry(a){return this.dexterity_dict[j(a,"dexterity",3,25)]}},T=class{constructor(a,t,e){this.hitpointbonus=a,this.systemshock=t,this.resurrectionsurvival=e}getHitpointBonus(){return this.hitpointbonus}getSystemShock(){return this.systemshock}getResurrectionSurvival(){return this.resurrectionsurvival}},Oe=class{constructor(){this.constitution_dict={3:new T("-2",35,40),4:new T("-1",40,45),5:new T("-1",45,50),6:new T("0",50,55),7:new T("0",55,60),8:new T("0",60,65),9:new T("0",65,70),10:new T("0",70,75),11:new T("0",75,80),12:new T("0",80,85),13:new T("0",85,90),14:new T("0",88,92),15:new T("1",91,94),16:new T("2",95,96),17:new T("3",97,98),18:new T("4",99,100),19:new T("5",99,100),20:new T("5",99,100),21:new T("6",99,100),22:new T("6",99,100),23:new T("6",99,100),24:new T("7",99,100),25:new T("7",99,100)}}getEntry(a){return this.constitution_dict[j(a,"constitution",3,25)]}},S=class{constructor(a,t,e,o){this.maximumhenchmen=a,this.loyaltybonus=t,this.reactionbonus=e,this.comeliness=o}MaximumHenchmen(){return this.maximumhenchmen}getLoyaltyBonus(){return this.loyaltybonus}getReactionBonus(){return this.reactionbonus}getComeliness(){return this.comeliness}},Ee=class{constructor(){this.charisma_dict={3:new S(1,-30,-25,-5),4:new S(1,-25,-20,-3),5:new S(2,-20,-15,-3),6:new S(2,-15,-10,-1),7:new S(3,-10,-5,-1),8:new S(3,-5,0,-1),9:new S(4,0,0,0),10:new S(4,0,0,0),11:new S(4,0,0,0),12:new S(5,0,0,0),13:new S(5,0,5,1),14:new S(6,5,10,1),15:new S(7,15,15,1),16:new S(8,20,25,2),17:new S(10,30,30,2),18:new S(15,40,35,3),19:new S(20,50,40,5),20:new S(25,60,45,5),21:new S(30,70,50,5),22:new S(35,80,55,5),23:new S(40,90,60,5),24:new S(45,100,65,5),25:new S(50,100,70,5)}}getEntry(a){return this.charisma_dict[j(a,"charisma",3,25)]}},D=class{constructor(a,t,e,o,r){this.pickPockets=a,this.openLocks=t,this.findRemoveTraps=e,this.moveSilently=o,this.hideInShadows=r}getPickPockets(){return this.pickPockets}getOpenLocks(){return this.openLocks}getFindRemoveTraps(){return this.findRemoveTraps}getMoveSilently(){return this.moveSilently}getHideInShadows(){return this.hideInShadows}},Ie=class{constructor(){this.dexterity_dict={9:new D(-15,-10,-10,-20,-10),10:new D(-10,-5,-10,-15,-5),11:new D(-5,0,-5,-10,0),12:new D(0,0,0,-5,0),13:new D(0,0,0,0,0),14:new D(0,0,0,0,0),15:new D(0,0,0,0,0),16:new D(0,5,0,0,0),17:new D(5,10,0,5,5),18:new D(10,15,5,10,10),19:new D(15,20,10,12,12),20:new D(20,25,15,15,15),21:new D(25,30,20,18,18),22:new D(30,35,25,20,20),23:new D(35,40,30,23,23),24:new D(40,45,35,25,25),25:new D(45,50,40,30,30)}}getEntry(a){return this.dexterity_dict[j(a,"dexterity",9,25)]}},B=class{constructor(a,t,e,o,r,s,c,l){this.pickPockets=a,this.openLocks=t,this.findRemoveTraps=e,this.moveSilently=o,this.hideInShadows=r,this.hearNoise=s,this.climbWalls=c,this.readLanguages=l}getPickPockets(){return this.pickPockets}getOpenLocks(){return this.openLocks}getFindRemoveTraps(){return this.findRemoveTraps}getMoveSilently(){return this.moveSilently}getHideInShadows(){return this.hideInShadows}getHearNoise(){return this.hearNoise}getClimbWalls(){return this.climbWalls}getReadLanguages(){return this.readLanguages}},Re=class{constructor(){this.dexterity_dict={0:new B(0,0,0,0,0,0,0,0),1:new B(0,0,0,0,0,0,0,0),2:new B(0,10,15,0,0,0,-10,-5),3:new B(5,-5,0,5,10,5,0,0),4:new B(0,5,10,5,5,10,-15,0),5:new B(10,0,0,0,5,0,0,0),6:new B(5,5,5,10,15,5,-15,-5),7:new B(-5,5,5,0,0,5,5,-10)}}getEntry(a){return this.dexterity_dict[j(a,"thief_race_selected",0,7)]}},L=new Se,ie=new Ne,_e=new Ce,z=new De,K=new Oe,W=new Ee,Z=new Ie,U=new Re,P=(n,a,t="int")=>t==="int"?parseInt(n[a])||0:t==="float"?parseFloat(n[a])||0:t==="str"?n[a]:null,_t=async()=>{let n=await w(["strength","exceptionalstrength"]),a={},t=await P(n,"strength","int"),e=await P(n,"exceptionalstrength");await P(n,"exceptionalstrength","str")==="00"&&(e=100),a.exceptionalstrength=e,a.meleebonus=(L.getStrengthValue("Attack",t,e)<=0?"":"+")+L.getStrengthValue("Attack",t,e),a.dmgbonus=(L.getStrengthValue("Damage",t,e)<=0?"":"+")+L.getStrengthValue("Damage",t,e),a.majorstrengthfeat=L.getStrengthValue("Major",t,e),a.minorstrengthfeat=L.getStrengthValue("Minor",t,e),a.minorstrengthfeat_locked=L.getStrengthValue("Minor",t,e,!0),a.encumbrancebonus=(L.getStrengthValue("Encumbrance",t,e)<=0?"":"+")+L.getStrengthValue("Encumbrance",t,e),await h(a)},pt=async()=>{let n=await w(["intelligence","bonuslanguages","race"]),a={},t=await P(n,"intelligence","int"),e=await P(n,"race","str"),o=+ie.getEntry(t).getBonusLanguages();/human/gi.test(e)?a.bonuslanguages=o:/dwarf/gi.test(e)||/gnome/gi.test(e)||/orc/gi.test(e)?a.bonuslanguages=Math.min(o,2):/half-elf/gi.test(e)||/halfling/gi.test(e)||/hobbit/gi.test(e)?(o<=5?o=0:o===6?o=1:o===7?o=2:o===8?o=3:o===9?o=4:o===10?o=5:o===11?o=6:o===12?o=7:o===13?o=8:o>=14&&(o=9),a.bonuslanguages=o):/elf/gi.test(e)?(o<=4?o=0:o===5?o=1:o==6?o=2:o===7?o=3:o===8?o=4:o===9?o=5:o===10?o=6:o===11?o=7:o===12?o=8:o===13?o=9:o>=14&&(o=10),a.bonuslanguages=o):a.bonuslanguages=0,a.knowspell=ie.getEntry(t).getKnowSpell(),a.minspells=ie.getEntry(t).getMinSpells(),a.maxspells=ie.getEntry(t).getMaxSpells(),await h(a,{silent:!0})},lt=async()=>{let n=await w(["wisdom"]),a={},t=await P(n,"wisdom","int");a.mentalsavebonus=(_e.getEntry(t).getMentalSaveBonus()<=0?"":"+")+_e.getEntry(t).getMentalSaveBonus(),a.spellbonus=_e.getEntry(t).getSpellBonus(),a.spellfailure=_e.getEntry(t).getSpellFailure(),await h(a,{silent:!0})},mt=async()=>{let n=await w(["dexterity"]),a={},t=await P(n,"dexterity","int"),e=z.getEntry(t).getSurpriseBonus(),o=(-1*e<=0?"":"+")+-1*e;a.surprisebonus=z.getEntry(t).getSurpriseBonus(),a.surprisebonus_inverted=o,a.rangedbonus=(z.getEntry(t).getRangedBonus()<=0?"":"+")+z.getEntry(t).getRangedBonus(),a.armorbonus=(z.getEntry(t).getArmorBonus()<=0?"":"+")+z.getEntry(t).getArmorBonus(),await h(a)},ht=async()=>{let n=await w(["constitution","class","secondclass","thirdclass"]),a={},t=await P(n,"constitution","int"),e=[n.class,n.secondclass,n.thirdclass];/fighter/gi.test(e)||/paladin/gi.test(e)||/ranger/gi.test(e)?a.hitpointbonus=(K.getEntry(t).getHitpointBonus()<=0?"":"+")+K.getEntry(t).getHitpointBonus():a.hitpointbonus=(Math.min(K.getEntry(t).getHitpointBonus(),2)<=0?"":"+")+Math.min(K.getEntry(t).getHitpointBonus(),2),a.systemshock=K.getEntry(t).getSystemShock(),a.resurrectionsurvival=K.getEntry(t).getResurrectionSurvival(),await h(a)},gt=async()=>{let n=await w(["charisma"]),a={},t=await P(n,"charisma","int");a.maximumhenchmen=W.getEntry(t).MaximumHenchmen(),a.loyaltybonus=(W.getEntry(t).getLoyaltyBonus()<=0?"":"+")+W.getEntry(t).getLoyaltyBonus(),a.reactionbonus=(W.getEntry(t).getReactionBonus()<=0?"":"+")+W.getEntry(t).getReactionBonus(),a.comeliness_cha_adj=(W.getEntry(t).getComeliness()<=0?"":"+")+W.getEntry(t).getComeliness(),await setAttrs(a,{silent:!0})},oo=async n=>{let a=await w(["dexterity"]),t={},e=await P(a,"dexterity","int"),o=Z.getEntry(e).getPickPockets(),r=Z.getEntry(e).getOpenLocks(),s=Z.getEntry(e).getFindRemoveTraps(),c=Z.getEntry(e).getMoveSilently(),l=Z.getEntry(e).getHideInShadows();t.pickpockets_ability_mod=n===1?o:0,t.openlocks_ability_mod=n===1?r:0,t.findtraps_ability_mod=n===1?s:0,t.movequietly_ability_mod=n===1?c:0,t.hideinshadows_ability_mod=n===1?l:0,await h(t)},ro=async n=>{let a=await w(["thief_race_selected"]),t={},e=await P(a,"thief_race_selected","int"),o=U.getEntry(e).getPickPockets(),r=U.getEntry(e).getOpenLocks(),s=U.getEntry(e).getFindRemoveTraps(),c=U.getEntry(e).getMoveSilently(),l=U.getEntry(e).getHideInShadows(),p=U.getEntry(e).getHearNoise(),g=U.getEntry(e).getClimbWalls(),u=U.getEntry(e).getReadLanguages();t.pickpockets_racial_mod=n===1?o:0,t.openlocks_racial_mod=n===1?r:0,t.findtraps_racial_mod=n===1?s:0,t.movequietly_racial_mod=n===1?c:0,t.hideinshadows_racial_mod=n===1?l:0,t.hearnoise_racial_mod=n===1?p:0,t.climbwalls_racial_mod=n===1?g:0,t.readlanguages_racial_mod=n===1?u:0,await h(t)};on("change:autofill_thief_dex change:dexterity",async n=>{let a=await w(["autofill_thief_dex"]),t=i(a.autofill_thief_dex);await oo(t)});var so=async n=>{let a=n.trim().toLowerCase();return/human/.test(a)?1:/dwarf/.test(a)?2:/half-elf/.test(a)?5:/elf/.test(a)?3:/gnome/.test(a)?4:/halfling|hobbit/.test(a)?6:/half-orc/.test(a)?7:0};on("change:race change:autofill_thief_race change:thief_race_selected",async n=>{let a=n.sourceAttribute,t=await w(["race","autofill_thief_race"]),e={},o=i(t.autofill_thief_race),r=(t.race||"human").trim();(a==="autofill_thief_race"||a==="race")&&(e.thief_race_selected=await so(r)),await h(e,{silent:!0}),await ro(o)});on("change:strength change:exceptionalstrength",async n=>{await _t()});on("change:intelligence change:race",async n=>{await pt()});on("change:wisdom",async n=>{await lt()});on("change:dexterity",async n=>{await mt()});on("change:constitution change:class change:secondclass change:thirdclass",async n=>{await ht()});on("change:charisma change:comeliness",async n=>{await gt()});var ut=async()=>{let n=await w(["character_avatar","sheet_image","sheet_image_url"]),a={},t=i(n.sheet_image),e=(function(s){let c=/(\.png|\.jpg|\.gif)/i,l=s.match(c);return l?s.slice(0,l.index+l[0].length):s})(n.character_avatar),o=n.sheet_image_url||e;t===0&&(a.sheet_image_src=o),t===1&&(a.sheet_image_src=e),t===2&&(a.sheet_image_src=""),await h(a,{silent:!0})};on("change:character_avatar change:sheet_image change:sheet_image_url",async n=>{await ut()});on("clicked:postimage",async n=>{await ut();let a="?{Display the portrait image?|YES,@{sheet_image_src}|NO, }";await new Promise(t=>{startRoll(a,e=>{finishRoll(e.rollId),t()})})});on("change:psionic_ability_strength_max change:psionic_attack change:psionic_defense",async n=>{let a=await w(["psionic_ability_strength_max"]),t={},e=i(a.psionic_ability_strength_max);t.psionic_attack_max=O(e/2).toFixed(1),t.psionic_defense_max=O(e/2).toFixed(1),await h(t,{silent:!0})});var co=async()=>{let n=await y("weapon"),a={};if(n.length===0){a.weapon_in_use="",a.weapon_in_use_speed="",a.weapon_in_use_misc="",await h(a,{silent:!0});return}let t=[],e=n.flatMap(r=>[`repeating_weapon_${r}_weapon_name`,`repeating_weapon_${r}_weapon_use`,`repeating_weapon_${r}_weapon_speed`,`repeating_weapon_${r}_weapon_misc`]),o=await w(e);if(n.forEach(r=>{let s=i(o[`repeating_weapon_${r}_weapon_use`]);if(s===1){let c=o[`repeating_weapon_${r}_weapon_name`]||"Unknown",p=String(o[`repeating_weapon_${r}_weapon_speed`]||"0").match(/\d+/),g=p?i(p[0]):0,u=o[`repeating_weapon_${r}_weapon_misc`]||"";t.push({id:r,name:c,inUse:s,speed:g,misc:u})}}),t.length>0){t.sort((s,c)=>s.speed-c.speed);let r=t[0];a.weapon_in_use=r.name,a.weapon_in_use_speed=r.speed,a.weapon_in_use_misc=r.misc}else a.weapon_in_use="",a.weapon_in_use_speed="",a.weapon_in_use_misc="";await h(a,{silent:!0})};on("change:repeating_weapon:weapon_name change:repeating_weapon:weapon_use change:repeating_weapon:weapon_speed change:repeating_weapon:weapon_misc remove:repeating_weapon",async n=>{await co()});var wt=async n=>{let a=await y(n),e=(await w([`_reporder_repeating_${n}`]))[`_reporder_repeating_${n}`]||"",r=(e?e.split(","):[]).filter(c=>a.includes(c.toLowerCase()));return[...new Set([...r,...a])]};on("clicked:spell-sort-alphabetical clicked:spell-sort-level",async n=>{let a=n.triggerName.replace("clicked:",""),t=await w(["spells_sheet_busy"]);if(i(t.spells_sheet_busy)!==1){await h({spells_sheet_busy:1});try{let e="spells",o=await wt(e),r=await y(e);if(r.length>0){let s=r.flatMap(d=>[`repeating_spells_${d}_spell_caster_class`,`repeating_spells_${d}_spell_level`,`repeating_spells_${d}_spell_name`]),c=await w(s),l={},p=r.map(d=>({id:d,casterClass:c[`repeating_spells_${d}_spell_caster_class`]||0,level:c[`repeating_spells_${d}_spell_level`],name:(c[`repeating_spells_${d}_spell_name`]||"").trim()})),g=d=>d==="?"?-1:d||0;a==="spell-sort-alphabetical"?p.sort((d,f)=>d.name.localeCompare(f.name,void 0,{sensitivity:"base"})):a==="spell-sort-level"&&p.sort((d,f)=>{let k=g(d.level),v=g(f.level);return d.casterClass-f.casterClass||k-v||d.name.localeCompare(f.name,void 0,{sensitivity:"base"})});let u=p.map(d=>`${d.id}`);setSectionOrder("spells",u),u.length>35?await me(100):await me(20);let m=[...new Set(o.map(d=>d.toLowerCase()))];l.spells_previous_order_array=m.join(","),await h(l,{silent:!0})}}catch(e){console.error("Error: Sort failed.",e)}finally{await h({spells_sheet_busy:0})}}});on("clicked:spell-sort-undo",async n=>{let a=await w(["spells_sheet_busy"]);if(i(a.spells_sheet_busy)!==1){await h({spells_sheet_busy:1});try{let t="spells",[e,o]=await Promise.all([w(["spells_previous_order_array"]),y(t)]),r=e.spells_previous_order_array||"";if(r){let s=new Set(o.map(l=>l.toLowerCase())),c=[...new Set(r.split(",").map(l=>l.toLowerCase()).filter(l=>s.has(l)))];setSectionOrder(t,c),await h({spells_previous_order_array:""},{silent:!0})}}catch(t){console.error("Error: Undo failed",t)}finally{await h({spells_sheet_busy:0})}}});on("clicked:equipment-sort-alphabetical clicked:equipment-sort-location",async n=>{let a=n.triggerName.replace("clicked:",""),t=await w(["equipment_sheet_busy"]);if(i(t.equipment_sheet_busy)!==1){await h({equipment_sheet_busy:1});try{let e="equipment",o=await wt(e),r=await y(e);if(r.length>0){let s=r.flatMap(m=>[`repeating_equipment_${m}_equipment_item`,`repeating_equipment_${m}_equipment_location`]),c=await w(s),l={},p=r.map(m=>({id:m,name:(c[`repeating_equipment_${m}_equipment_item`]||"").trim(),location:(c[`repeating_equipment_${m}_equipment_location`]||"").trim()}));a==="equipment-sort-alphabetical"?p.sort((m,d)=>m.name.localeCompare(d.name,void 0,{sensitivity:"base"})):a==="equipment-sort-location"&&p.sort((m,d)=>{let f=m.location.localeCompare(d.location,void 0,{sensitivity:"base"});return f!==0?f:m.name.localeCompare(d.name,void 0,{sensitivity:"base"})});let g=p.map(m=>m.id);setSectionOrder(e,g),g.length>35?await me(100):await me(20);let u=[...new Set(o.map(m=>m.toLowerCase()))];l.equipment_previous_order_array=u.join(","),await h(l,{silent:!0})}}catch(e){console.error("Error: Sort failed.",e)}finally{await h({equipment_sheet_busy:0})}}});on("clicked:equipment-sort-undo",async n=>{let a=await w(["equipment_sheet_busy"]);if(i(a.equipment_sheet_busy)!==1){await h({equipment_sheet_busy:1});try{let t="equipment",[e,o]=await Promise.all([w(["equipment_previous_order_array"]),y(t)]),r=e.equipment_previous_order_array||"";if(r){let s=new Set(o.map(l=>l.toLowerCase())),c=[...new Set(r.split(",").map(l=>l.toLowerCase()).filter(l=>s.has(l)))];setSectionOrder(t,c),await h({equipment_previous_order_array:""},{silent:!0})}}catch(t){console.error("Error: Undo failed.",t)}finally{await h({equipment_sheet_busy:0})}}});
\ No newline at end of file
diff --git a/ADnD_1E_Revised/src/index.html b/ADnD_1E_Revised/src/index.html
index 6875709f25..872e0649b1 100644
--- a/ADnD_1E_Revised/src/index.html
+++ b/ADnD_1E_Revised/src/index.html
@@ -67,7 +67,7 @@
v
- • 6/18/26'
+ • 6/22/26'