taulukko-common-scripts-dnd5ed 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,83 @@
1
+ (function(){"use strict";var D={},v={},b={},U;function M(){if(U)return b;U=1,Object.defineProperty(b,"__esModule",{value:!0}),b.StringsUtil=void 0;class s{left(o,e){return e>0?o.slice(0,e):""}trim(o){return o.trim()}right(o,e){return e>0?o.slice(-e):""}repeat(o,e,r){return e>0?Array.from({length:e},()=>o).join(r):""}leftPadding(o,e,r){return e>0?o.padStart(e,r).slice(-e):""}rightPadding(o,e,r){return e>0?o.padEnd(e,r).slice(0,e):""}count(o,e){return o.split(e).length-1}hashNumber(o){let e=0,r,n;if(o.length===0)return e;for(r=0;r<o.length;r++)n=o.codePointAt(r),e=(e<<5)-e+n,e|=0;return e}hashString(o){return this.hashNumber(o).toString(36)}}return b.StringsUtil=s,b}var A;function T(){if(A)return v;A=1,Object.defineProperty(v,"__esModule",{value:!0}),v.DatesUtil=void 0;const s=M();class t{stringUtil=new s.StringsUtil;addDays(e,r){const n=new Date(e);return n.setDate(e.getDate()+r),n}parseYYYYMMDDHHMMSS(e){if(e.length!==14)throw new Error("Date format YYYYMMDDHHMMSS incorrect!");const r=this.stringUtil.right(e,6);if(isNaN(Number(r)))throw new Error("Time must be numeric integer");const n=this.stringUtil.left(r,2);if(isNaN(Number(n)))throw new Error("Hour must be numeric integer");const c=this.stringUtil.left(this.stringUtil.right(r,4),2);if(isNaN(Number(c)))throw new Error("Minute must be numeric integer");const i=this.stringUtil.right(r,2);if(isNaN(Number(i)))throw new Error("Second must be numeric integer");const l=this.parseYYYYMMDD(this.stringUtil.left(e,8));return l.setHours(Number.parseInt(n,10)),l.setMinutes(Number.parseInt(c,10)),l.setSeconds(Number.parseInt(i,10)),l}parseYYYYMMDD(e){if(e.length!==8)throw new Error("Date format YYYYMMDD incorrect!");const r=this.stringUtil.left(e,4);if(isNaN(Number(r)))throw new Error("Year must be numeric integer");const n=this.stringUtil.right(this.stringUtil.left(e,6),2);if(isNaN(Number(n)))throw new Error("Month must be numeric integer");const c=this.stringUtil.right(e,2);if(isNaN(Number(c)))throw new Error("Day must be numeric integer");return this.parse(Number.parseInt(r,10),Number.parseInt(n,10),Number.parseInt(c,10))}parse(e,r,n,c=0,i=0,l=0){return new Date(e,r-1,n,c,i,l)}getYear(e){return e.getFullYear()}getMonth(e){return e.getMonth()+1}getMonthIndex(e){return e.getMonth()}getDay(e){return e.getDate()}getDayOfWeak(e){return e.getDay()+1}getDayOfWeakIndex(e){return e.getDay()}toString(e,r=14){if(r<1)return"";r>14&&(r=14);const n=e.getFullYear().toString().padStart(4,"0"),c=(e.getMonth()+1).toString().padStart(2,"0"),i=e.getDate().toString().padStart(2,"0"),l=e.getHours().toString().padStart(2,"0"),u=e.getMinutes().toString().padStart(2,"0"),g=e.getSeconds().toString().padStart(2,"0"),d=`${n}${c}${i}${l}${u}${g}`;return this.stringUtil.left(d,r)}}return v.DatesUtil=t,v}var C={},R;function Z(){if(R)return C;R=1,Object.defineProperty(C,"__esModule",{value:!0}),C.KeyTool=void 0;const s=M(),t="10";class o{stringUtil=new s.StringsUtil;generateUUID(){var r=new Date().getTime(),n=typeof performance<"u"&&performance.now&&performance.now()*1e3||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(c){var i=Math.random()*16;return r>0?(i=(r+i)%16|0,r=Math.floor(r/16)):(i=(n+i)%16|0,n=Math.floor(n/16)),(c==="x"?i:i&3|8).toString(16)})}build(r,n){if(r>=1e3||r<0)throw new Error("Cluster must be between 0-999");if(n<0)throw new Error("ProccessID must be >= 0");n=n%1e6;const c=this.stringUtil.right("0000"+Math.round(Math.random()*9999),4),i=this.generateUUID();return t+this.stringUtil.right("000"+r,3)+this.stringUtil.right("000000"+n,6)+c+"--"+i}}return C.KeyTool=o,C}var y={},k;function ee(){if(k)return y;k=1,Object.defineProperty(y,"__esModule",{value:!0}),y.ObjectsUtil=void 0;class s{shallowCopy(o){return JSON.parse(JSON.stringify(o))}partialCopy(o,e,r){const n=this.shallowCopy(e);for(const c of r)n[c]=o[c];return n}}return y.ObjectsUtil=s,y}var P={},N={},x;function O(){if(x)return N;x=1,Object.defineProperty(N,"__esModule",{value:!0}),N.InjectorFactory=void 0;class s{factory;constructor(o){this.factory=o}build(){return this.factory()}}return N.InjectorFactory=s,N}var w={},H;function _(){if(H)return w;H=1,Object.defineProperty(w,"__esModule",{value:!0}),w.injectController=void 0;const s=O();class t{registrations=new Map;registerByClass(e){let r;return e instanceof s.InjectorFactory?r=e.build().constructor.name:r=e.constructor.name,this.registerByName(r,e)}registerByName(e,r){return this.registrations.set(e,r),this}resolve(e){if(!this.registrations.has(e))throw new Error("key ["+e+"] not registered");const r=this.registrations.get(e);return r instanceof s.InjectorFactory?r.build():r}has(e){return typeof e!="string"&&(e=e.constructor.name),this.registrations.has(e)}clearAll(){return this.registrations.clear(),this}unregister(e){return typeof e!="string"&&(e=e.constructor.name),this.registrations.delete(e),this}}return w.injectController=new t,w}var G;function te(){return G||(G=1,(function(s){Object.defineProperty(s,"__esModule",{value:!0}),s.injectController=s.InjectorFactory=void 0;var t=O();Object.defineProperty(s,"InjectorFactory",{enumerable:!0,get:function(){return t.InjectorFactory}});var o=_();Object.defineProperty(s,"injectController",{enumerable:!0,get:function(){return o.injectController}})})(P)),P}var L={},I={},B;function q(){return B||(B=1,(function(s){Object.defineProperty(s,"__esModule",{value:!0}),s.Level=void 0,(function(t){t.CRITICAL="CRITICAL",t.ERROR="ERROR",t.WARN="WARN",t.INFO="INFO",t.DEBUG="DEBUG"})(s.Level||(s.Level={}))})(I)),I}var S={},F;function oe(){return F||(F=1,(function(s){Object.defineProperty(s,"__esModule",{value:!0}),s.LogGenericImpl=s.BUILD_DATE_KEY=void 0;const t=T(),o=_(),e=q();s.BUILD_DATE_KEY="LogGenericImpl.BuildDate";const r={[e.Level.DEBUG]:0,[e.Level.INFO]:1,[e.Level.WARN]:2,[e.Level.ERROR]:3,[e.Level.CRITICAL]:4};class n{#e=e.Level.INFO;#t;#r;#n;#i;#s;#o;#a;#l=new t.DatesUtil;constructor(i={prefix:"",hasDate:!0,hasLevel:!0,format:""}){const l="LogGenericImpl.";this.#t=o.injectController.has(l+e.Level.CRITICAL)?o.injectController.resolve(l+e.Level.CRITICAL):console.error,this.#r=o.injectController.has(l+e.Level.ERROR)?o.injectController.resolve(l+e.Level.ERROR):console.error,this.#n=o.injectController.has(l+e.Level.WARN)?o.injectController.resolve(l+e.Level.WARN):console.warn,this.#i=o.injectController.has(l+e.Level.INFO)?o.injectController.resolve(l+e.Level.INFO):console.info,this.#s=o.injectController.has(l+e.Level.DEBUG)?o.injectController.resolve(l+e.Level.DEBUG):console.debug,this.#a=o.injectController.has(s.BUILD_DATE_KEY)?o.injectController.resolve(s.BUILD_DATE_KEY):()=>new Date,this.#o=i}level(i=void 0){return i!=null&&(this.#e=i),this.#e}isCompatible(i){const l=r[this.#e];return r[i]>=l}log(i,l,...u){if(!this.isCompatible(l))return;const g=this.#l.toString(this.#a(),14),d=[];this.#o.prefix&&d.push(this.#o.prefix),this.#o.hasLevel&&d.push(`[${l}]`),this.#o.hasDate&&d.push(g);const m=d.join(" ");m?i(m,...u):i(...u)}critical(...i){this.log(this.#t,e.Level.CRITICAL,...i)}error(...i){this.log(this.#r,e.Level.ERROR,...i)}warn(...i){this.log(this.#n,e.Level.WARN,...i)}info(...i){this.log(this.#i,e.Level.INFO,...i)}debug(...i){this.log(this.#s,e.Level.DEBUG,...i)}}s.LogGenericImpl=n})(S)),S}var Y;function re(){return Y||(Y=1,(function(s){Object.defineProperty(s,"__esModule",{value:!0}),s.BUILD_DATE_KEY=s.LogGenericImpl=s.Level=void 0;var t=q();Object.defineProperty(s,"Level",{enumerable:!0,get:function(){return t.Level}});var o=oe();Object.defineProperty(s,"LogGenericImpl",{enumerable:!0,get:function(){return o.LogGenericImpl}}),Object.defineProperty(s,"BUILD_DATE_KEY",{enumerable:!0,get:function(){return o.BUILD_DATE_KEY}})})(L)),L}var K;function ne(){return K||(K=1,(function(s){Object.defineProperty(s,"__esModule",{value:!0}),s.BUILD_DATE_KEY=s.LogGenericImpl=s.Level=s.InjectorFactory=s.injectController=s.StringsUtil=s.ObjectsUtil=s.KeyTool=s.DatesUtil=void 0;var t=T();Object.defineProperty(s,"DatesUtil",{enumerable:!0,get:function(){return t.DatesUtil}});var o=Z();Object.defineProperty(s,"KeyTool",{enumerable:!0,get:function(){return o.KeyTool}});var e=ee();Object.defineProperty(s,"ObjectsUtil",{enumerable:!0,get:function(){return e.ObjectsUtil}});var r=M();Object.defineProperty(s,"StringsUtil",{enumerable:!0,get:function(){return r.StringsUtil}});var n=te();Object.defineProperty(s,"injectController",{enumerable:!0,get:function(){return n.injectController}}),Object.defineProperty(s,"InjectorFactory",{enumerable:!0,get:function(){return n.InjectorFactory}});var c=re();Object.defineProperty(s,"Level",{enumerable:!0,get:function(){return c.Level}}),Object.defineProperty(s,"LogGenericImpl",{enumerable:!0,get:function(){return c.LogGenericImpl}}),Object.defineProperty(s,"BUILD_DATE_KEY",{enumerable:!0,get:function(){return c.BUILD_DATE_KEY}})})(D)),D}var a=ne();function ie(s){a.injectController.resolve("Log").debug(`Message: ${s}!`)}function se(s,t){return a.injectController.resolve("Log").debug("The addition is performed."),s+t}function ae(){Hooks.once("onReadyCommonSocket",async()=>{const s=a.injectController.resolve("Log"),t=a.injectController.resolve("Socket");s.debug("onReadyCommonSocket 20"),t.register("showMessage",ie),t.register("add",se),s.debug("Socketlib finish the register events");try{if(t.isReadyToSendToGM())if(s.debug("Gm esta pronto pra receber mensagens test1"),t.executeForAll("showMessage","test1"),s.debug("Depois de usar executeForAll test1"),game.user.isGM){s.debug("Before executeAsGM add 5+6");let i=await t.executeAsGM("add",5,6);s.debug(`The result of executeAsGM add 5+6 is: ${i}`),await t.executeAsGM("showMessage","test2"),s.debug("depois de executeAsGM test2")}else{t.executeForAll("showMessage","test3"),s.debug("Depois de executeForAll");try{s.debug("Before executeAsGM test4"),await t.executeAsGM("showMessage","test4"),s.debug("depois de executeAsGM test4")}catch(i){s.debug("erro ao tentar executar executeAsGM sendo apenas jogador",i)}}else s.debug("A minha implementacao notou que o gm nao foi carregado ainda 1");s.debug("Before executeForAll test5"),t.executeForAll("showMessage","test5"),s.debug("depois de executeForAll test5"),s.debug("Before executeToGM test6"),t.executeToGM("showMessage","test6"),s.debug("depois de executeToGM test6");let o=game.users.map(i=>i.id);s.debug("Meu userid",game.user.id),o=o.filter(i=>(a.injectController.resolve("Log").debug("id recebido e meu user id",i,game.user.id),i!=game.user.id)),s.debug("Ids dos outros jogadores",o);let e=Math.round(1e3*Math.random())+1e3,r=Math.round(o.length*Math.random());r=r==o.length?r-1:r;const n=o.at(r);s.debug(`Sending to player random: ${n} , I am userid: ${game.user.id} and number random is ${e}`);let c=await t.executeIn("add",[n],e,1);s.debug(`The player random calculated: ${c}`),s.debug("Antes do executeIn test7"),t.executeIn("showMessage",[n],"teste7:"+game.user.id),s.debug("Depois do showMessage test7")}catch(o){s.debug("Common socket error",o)}})}class z{#e=!1;isReady(){return this.#e}async init(){this.initHooks(),await this.waitReady(),this.#e=!0}async whaitFor(t,o=6e4,e=100){const r=a.injectController.resolve("Log");let n=0;return new Promise((i,l)=>{const u=setInterval(()=>{if(r.debug("Total time:",n," for function ",t),t()){clearInterval(u),i();return}n>o&&(r.debug("Timeout for test:",t),clearInterval(u),l(new Error("timeout while wait For in common module"))),n+=e},e)})}}class f extends z{}const V=document,W={MODULE_NAME:"common-assets",TOOGLE_VISIBILITY:"common-assets-toogle-visibility-regions"};class le extends f{#e=!1;initHooks(){Hooks.on("onInitCommonModule",()=>{const t=a.injectController.resolve("RegionUtils");a.injectController.resolve("Log").info("Loading Region Utils"),t.registerKeybindings(),t.#e=!0})}async waitReady(){const t=a.injectController.resolve("Log"),o=300*1e3;if(await this.whaitFor(()=>this.#e,o),!this.#e)throw new Error("Timeout waiting for hooks");Hooks.callAll("onReadyRegionUtils",{}),t.debug("Region Utils ready")}sendMessageToChat(t,o){const e={user:t,speaker:"Game Master",content:o,whisper:game.users.filter(r=>r.isGM).map(r=>r._id)};ChatMessage.create(e,{})}stop(t){const o=a.injectController.resolve("Log"),e=t?.region?.shapes[0];if(o.debug("event:",t,",shape:",e),!e){o.error("shape not found");return}const r=e.width,n=e.height,c=e.x+Math.round(r/2),i=e.y+Math.round(n/2),l=t?.data?.token;l.x=c,l.y=i,o.debug("Token indo para x:",c,",y:",i),l.update({x:l.x,y:l.y})}toggleVisibilityRegions(){const t=a.injectController.resolve("Log");t.debug("toggleVisibilityRegions called");const o=game.scenes.current;if(!o){t.error("No scene active");return}o.regions.forEach(e=>{a.injectController.resolve("Log").debug("region",e),e.update({visibility:!e.visibility})})}registerKeybindings(){game.keybindings.register(W.MODULE_NAME,W.TOOGLE_VISIBILITY,{name:"Alternar visão das regiões da cena",hint:"Liga/desliga visibilidade das regiões da cena atual.",editable:[{key:"KeyG",modifiers:["Shift"]}],onDown:async()=>{V.COMMON_MODULE.debug("onDown will be called"),V.COMMON_MODULE.REGION_UTILS.toggleVisibilityRegions()},restricted:!0,reservedModifiers:[],precedence:CONST.KEYBINDING_PRECEDENCE.NORMAL})}}class ce extends f{#e=!1;initHooks(){Hooks.on("onReadyCommonModule",async()=>{const t=a.injectController.resolve("PlayersTools");a.injectController.resolve("Log").info("Starting Hability hero processing"),t.initializeFlyMeasure(),t.#e=!0})}async waitReady(){if(await this.whaitFor(()=>this.#e,3e5),!this.#e)throw new Error("Timeout waiting for hooks");Hooks.callAll("onReadyPlayersTools",{})}initializeFlyMeasure(){a.injectController.resolve("Log").debug("initlizeFlyMeasure init")}}class ue{constructor(t,o,e=!1,r="screen",n){this.action=t,this.label=o,this.defaultValue=e,this.type=r,this.callback=n}}const $="999";class de{constructor(t,o,e="ogg"){this.name=t,this.imageUrl=o,this.formatSound=e}DEFAULT_STYLE=`
2
+ <style>
3
+ .select-action { padding: 20px; background: #222; color: #eee; }
4
+ .select-action button { margin: 5px; padding: 5px 10px; }
5
+ .brizola-actions-buttons { display: flex; flex-direction: column; gap: 8px; }
6
+ `;actor;groups=new Set;screens=new Array;async whaitFor(t,o=6e4,e=100){const r=a.injectController.resolve("Log");let n=0;return new Promise((i,l)=>{const u=setInterval(()=>{if(r.debug("Total time:",n," for function ",t),t()){clearInterval(u),i(void 0);return}n>o&&(r.debug("Timeout for test:",t),clearInterval(u),l(new Error("timeout while wait For in common module"))),n+=e},e)})}async init(){if(await this.whaitFor(()=>a.injectController.resolve("NPCDialog"),3e5),!a.injectController.resolve("NPCDialog"))throw new Error("Timeout waiting for hooks");if(await this.whaitFor(()=>a.injectController.resolve("DialogUtils"),3e5),!a.injectController.resolve("DialogUtils"))throw new Error("Timeout waiting for hooks");const o=a.injectController.resolve("NPCDialog");this.screens.push({name:"npc-dialog",callback:o.showNPCChooseDialog})}decrementGroup(){const t=a.injectController.resolve("NPCDialog"),e=[...t.activeNPC.groups].slice(0,-1);t.activeNPC.groups=new Set(e)}getAlias(){return this.name.toLocaleLowerCase()}async createDialog(t,o,e,r){const n=a.injectController.resolve("NPCDialog"),c=a.injectController.resolve("DialogUtils"),i=a.injectController.resolve("Log"),l=n.activeNPC.getAlias();let u=`
7
+ <DIV class="${l}-actions-buttons">
8
+ <SELECT>
9
+ <option selected="selected" value="${l}-random">Aleatório dado o contexto até aqui</option>
10
+ `;e.forEach(d=>{const m=`${l}-back`,h=`${l}-send`,p=`${l}-cancel`;d.action==m||d.action==h||d.action==p||(i.debug("NPC.createDialog:5 for,button:",d),u+=`
11
+ <option value="${d.action}">${d.label} </option>
12
+ `)}),u+=`
13
+ </SELECT>
14
+ </DIV>
15
+ `,i.debug("NPC.createDialog:10",e),i.debug("NPC.createDialog:15:activeNPC.groups:",n.activeNPC.groups),r||(i.debug("NPC.createDialog:20"),r=[c.createButton("send","Enviar",!0,"action",async()=>{i.debug("NPC.createDialog, before creating send:",n.activeNPC.groups),i.debug("NPC.createDialog [10]: Escolhido a opcao enviar");const m=(document.querySelector(`.${l}-actions-buttons SELECT`)||null)?.value;if(m==null){i.error("NPC.createDialog: Erro ao obter a opcao selecionada");return}if(i.debug("NPC.createDialog [20]: depois de selecionar o resultado",m),m===`${l}-random`){const h=n.activeNPC.screens.at(-1);n.activeNPC.screens.push({name:m,callback:n.activeNPC.send,type:h.type}),i.debug("NPC.createDialog, before random send:",n.activeNPC.groups),n.activeNPC.send(!1),i.debug("NPC.createDialog, after random send:",n.activeNPC.groups);return}e.forEach(h=>{h.action==m&&(i.debug("NPC.Enviado a opcao :"+m),n.activeNPC.screens.push({name:m,callback:h.callback,type:h.type}),h.callback(),i.debug("NPC.createDialog, after 3 creating send:",n.activeNPC.groups))})}),c.createButton("back","Voltar",!0,"action",async()=>{i.debug("NPC.screens ao voltar - antes: ",n.activeNPC.screens);const d=n.activeNPC.screens.at(-2),m=n.activeNPC.screens.pop();i.debug("lastScreen:",m),i.debug("screens ao voltar - depois: ",n.activeNPC.screens),m.type=="screen-context"&&n.activeNPC.decrementGroup(),d.callback()}),c.createButton("cancel","Cancelar",!0,"action",async()=>{i.debug("NPC.Cancelado a tela do ",l)})],i.debug("NPC.createDialog:25. Create submits",r),i.debug("NPC.createDialog:30 - depois de criar submits"));const g=(d,m,h,p)=>{};i.debug("NPC.createDialog:40 - antes de criar dialogo"),c.createDialog(t,n.activeNPC.DEFAULT_STYLE,u,r,[g],200,void 0,400),i.debug("NPC.createDialog:50 - depois de criar dialogo")}async getListLinesFromGroup(t){const o=a.injectController.resolve("NPCDialog"),e=a.injectController.resolve("Log"),r=Array.from(t).map(Number).sort((c,i)=>c-i);if(r.length===0&&t.size===0)return new Array;if(r.length===0&&r.push(Number.parseInt(t.get(0),10)),r.length==1)return r;let n=await o.activeNPC.getCombinations(r);return e.debug("groups:",r),e.debug("keys:",n),n}async getCombinations(t,o=";"){const e=a.injectController.resolve("NPCDialog"),r=a.injectController.resolve("Log"),n=new Array;if(t.length==0||t.length==1)return[...t];r.debug("numbers:",t);const c=(i,l)=>{r.debug("generate start:",i,",path",l);let u=t.join(";");if(r.debug("combinationKey:",u),r.debug("groupToLines:",e.activeNPC.groupToLines,"-",typeof u),e.activeNPC.groupToLines.has(u))return r.debug("find, return the combination"),n.push(u),n;r.debug("combinationKey not found:",u);for(let g=i;g<t.length;g++){const d=[...l,t[g]];r.debug("novaCombinacao:",d),u=d.join(";"),n.push(u),c(g+1,d)}};return c(0,[]),n}async speak(t){const o=a.injectController.resolve("NPCDialog"),e=a.injectController.resolve("Log"),r=o.activeNPC.lines[t];e.debug("speak:talk:",r),e.debug("disparando o evento pra todo mundo:"),console.log("[NPC Portrait] Enviando para todos..."),await ChatMessage.create({content:"NPC Portrait Event",whisper:Array.from(game.users?.values()||[]).map(u=>u.id),flags:{"forgotten-realms":{type:"npcDialogOnTalk",payload:{imageUrl:this.imageUrl,npcName:this.name,dialogText:r}}}}),e.debug(" evento disparado pra todo mundo:");const n=t.toString().padStart(3,"0"),c=o.activeNPC.name,i=`modules/forgotten-realms/sounds/npcs/${c}/${n}/${c}${n}.${o.activeNPC.formatSound}`,l=await this.playSoundWithNoEffect(i);e.debug("Retorno do play:",l)}async playSoundWithNoEffect(t){a.injectController.resolve("NPCDialog");const o=a.injectController.resolve("Log");try{const e=await fetch(t,{method:"HEAD"});return e.ok?(foundry.audio.AudioHelper.play({src:t,autoplay:!0},!0),!0):(console.warn(`Arquivo não encontrado: ${t} (${e.status})`),!1)}catch(e){return o.error("Erro ao reproduzir o som:",t,e),!1}}async send(t=!0){const o=a.injectController.resolve("NPCDialog"),e=a.injectController.resolve("Log");o.activeNPC.groups.size===0&&o.activeNPC.groups.add($);const r=await o.activeNPC.getListLinesFromGroup(o.activeNPC.groups);e.debug("NPC.send, before send,list:",r);const n=new Array;for(const u of r){const g=u.toString();if(e.debug("group:",g),!o.activeNPC.groupToLines.has(g)){e.warn(`NPC.send, afterSend:Grupo ${g} não encontrado em groupToLines!`);continue}const d=g.split(";").length+1,m=o.activeNPC.groupToLines.get(g);e.debug("NPC.send, 50,linesForThisGroupConcat:",m,"-size:",d);const h=m.split(";");e.debug("NPC.send, 60,linesForThisGroup:",h),h.forEach(p=>{for(let Q=0;Q<d;Q++)n.push(p)})}e.debug("NPC.send, afterSend,lines:",n);let c=Math.abs(Math.round(Math.random()*n.length));c=c>=n.length?n.length-1:c,e.debug("NPC.send, afterSend,randomIndex:",c);const i=Number.parseInt(n[c],10);e.debug("NPC.send, afterSend,lineIndex:",i),o.activeNPC.speak(i),e.debug("NPC.send, afterSend,activeScreen:",o.activeNPC.screens);const l=o.activeNPC.screens.at(-2);o.activeNPC.screens.pop(),l.callback(),o.activeNPC.groups.delete($),t&&o.activeNPC.decrementGroup(),e.debug("NPC.send, afterSend:",o.activeNPC.groups)}}class E extends Application{imageUrl;npcName;dialogText;constructor(t={}){super(),this.imageUrl=t.imageUrl||"YOUR_IMAGE_URL_HERE",this.npcName=t.npcName||"NPC",this.dialogText=t.dialogText||"Olá, aventureiro..."}static get defaultOptions(){return foundry.utils.mergeObject(Application.defaultOptions,{id:"npc-portrait-dialog",classes:["npc-portrait-app"],title:"",width:600,height:400,resizable:!1,minimizable:!1,popOut:!0})}get template(){return"modules/forgotten-realms/scripts/templates/npc-talk.hbs"}async getData(){return{imageUrl:this.imageUrl,npcName:this.npcName,dialogText:this.dialogText}}activateListeners(t){super.activateListeners(t),t.on("click",".close-button",()=>{this.close()})}static renderTalk(t){new E({imageUrl:t.imageUrl,npcName:t.npcName,dialogText:t.dialogText}).render(!0)}async showToAllPlayers(){if(this.render(!0),game.user?.isGM){const t={type:"showNPCPortrait",data:{imageUrl:this.imageUrl,npcName:this.npcName,dialogText:this.dialogText}};game.socket.emit("module.seu-modulo",t)}}}console.log("npcDialog.ts loaded 10");class ge extends f{npcSelected;activeNPC;npcs=new Map;buttonloaded=!1;#e=!1;initHooks(){Hooks.on("createChatMessage",async t=>{const o=a.injectController.resolve("Log"),e=a.injectController.resolve("NPCDialog"),r=300*1e3;if(await e.whaitFor(()=>a.injectController.has("DialogUtils"),r),!a.injectController.has("DialogUtils")){o.error("Givup chat message ",t," because timeout wiaiting for DialogUtils");return}try{if(o.debug("createChatMessage recebido..."),t.flags?.["common-assets"]?.type==="npcDialogOnTalk"){const n=t.flags["common-assets"].payload;o.debug("[NPC Portrait] Evento recebido dos jogadores:",n),E.renderTalk(n)}}catch(n){o.error("[NPC Portrait] Erro ao processar evento:",n)}}),Hooks.on("getSceneControlButtons",async t=>{const o=a.injectController.resolve("Log"),e=a.injectController.resolve("NPCDialog"),r=300*1e3;if(await e.whaitFor(()=>a.injectController.has("DialogUtils"),r),!a.injectController.has("DialogUtils")){o.error("Givup getSceneControlButtons ",t," because timeout wiaiting for DialogUtils");return}o.debug("On getSceneControlButtons 05...",t,e),await e.addNPCButtons(t),e.#e=!0,o.debug("On getSceneControlButtons...:20")})}async waitReady(){if(await this.whaitFor(()=>this.#e,3e5),!this.#e)throw new Error("Timeout waiting for hooks");Hooks.callAll("onReadyNPCDialog",{})}async addNPCButtons(t){const o=a.injectController.resolve("Log"),e=a.injectController.resolve("NPCDialog");if(!game.user.isGM){o.debug("NPC Buttons off");return}o.debug("Criando botão dos NPCs especiais",t),t.tokens.tools.npcButton={name:"npcButton",title:"NPCs Especiais",icon:"fa-solid fa-web-awesome",button:!0,toggle:!1,onClick:()=>{o.debug("Botão de NPCs especiais pressionado"),console.log("npcDialog",e),e.showNPCChooseDialog(),o.debug("Após abrir janela de NPCs especiais")}},o.debug("Botão de NPC criado")}async showNPCChooseDialog(){const t=a.injectController.resolve("Log"),o=a.injectController.resolve("NPCDialog"),e=a.injectController.resolve("DialogUtils");t.debug("Botão NPCsespecial pressionado, mostrando diálogo...");const r="Escolha um NPC Especial",n=`
16
+ .select-npc { padding: 20px; background: #222; color: #eee; }
17
+ .select-npc button { margin: 5px; padding: 5px 10px; }
18
+ `,c=`
19
+ <div class="select-npc">
20
+ <H1>Escolha uma opção:</H1>
21
+ </div>`;t.debug("showNPCChooseDialog:10 before creating buttons",o);let i=[];o.npcs.forEach(l=>{t.debug("showNPCChooseDialog:15 add NPC ",l.name,l),i.push(e.createButton(l.name.toLocaleLowerCase(),l.name,!0,"screen",o.callNPC(l)))}),i.push(e.createButton("cancel","Cancel",!1,"screen")),t.debug("showNPCChooseDialog:20 after creating buttons"),e.createDialog(r,n,c,i,void 0,200,void 0,400),t.debug("showNPCChooseDialog:30 after createDialog")}helpSubmit=`
22
+ Submit need be a function:
23
+ (action,label,defaultValue,callback)=>{
24
+ return result => {
25
+ if ( result === "minsc" ) console.log("User picked minsc options.");
26
+ else console.log("User picked option: ", rsult );
27
+ }
28
+ }
29
+ `;async callNPC(t){const o=a.injectController.resolve("NPCDialog");a.injectController.resolve("Log").debug("Selecionado ...",t),o.npcSelected=t,await o.npcSelected.startScreen()}}class me extends f{npctype=de;NPC_DIALOG=new ge;#e=!1;async waitReady(){const t=a.injectController.resolve("Log"),o=300*1e3;if(await this.whaitFor(()=>this.#e,o),!this.#e)throw new Error("Timeout waiting for hooks");Hooks.callAll("onReadyDialogUtils",{}),t.debug("Dialog Utils ready")}initHooks(){Hooks.on("onReadyCommonModule",async t=>{const o=a.injectController.resolve("DialogUtils");a.injectController.resolve("Log").debug("Dialog Utils loading on onReadyCommonModule"),o.#e=!0})}createButton(t,o,e=!1,r="screen",n=void 0){return new ue(t,o,e,r,n)}createDialog(t,o="",e="",r=new Array,n=new Array,c=void 0,i=void 0,l="auto",u="auto"){const g=a.injectController.resolve("Log");if(g.debug("Dialog Utils creating dialog width: ",l," height: ",u),!r?.length||r.length===0)throw new Error("DIALOG_UTILS.createDialog: buttons array must have at least one button");const d={window:{title:t,resizable:!0},content:`<style>${o}</style>
30
+ <div>${e}</div>`,buttons:r,submit:n,position:{width:l,height:u,left:c,top:i}};g.debug("Dialog Utils dialog options: ",d);const m=new foundry.applications.api.DialogV2(d);return m.render({force:!0}),m}}class he extends f{#e=!1;initHooks(){Hooks.on("onReadyDialogUtils",async()=>{const t=a.injectController.resolve("HeroPoints");a.injectController.resolve("Log").info("Starting Hability hero processing"),t.initializeHabilityHero(),t.#e=!0})}async waitReady(){if(await this.whaitFor(()=>this.#e,3e5),!this.#e)throw new Error("Timeout waiting for hooks");Hooks.callAll("onReadyHeroPoints",{})}removeAttribute(t){const o=a.injectController.resolve("Log");let e=document.querySelectorAll("div.ability-score[data-ability='hon']");if(e.length==0){o.debug("This sheet not contain honrror field or system not enable honrror field");return}o.debug("Hability hero removed, npc sheet detected"),e.forEach(r=>r.remove())}addEditButtonsToHeroPoints(t){const o=a.injectController.resolve("Log");if(!game.user.isGM)return;let e=t?.querySelectorAll("div.mod span.operator.increment");if(e.length==0){o.error("Hability Hero operator increment not found");return}let r=e.item(0);if(r.onclick=n=>{n.preventDefault();const c=document.querySelectorAll("form.editable div.ability-score.flipped[data-ability='hon'] input");if(c.length!=1){o.error("Hability hero increment hero points not found input to increment ore found more then one, close others sheets before changing hero points");return}const i=c.item(0);if(i.value==null||i.value==""){o.error("Hability hero increment hero points not found input value to increment");return}const u=Number.parseInt(i.value,10)+1;i.value=u.toString(),o.debug(`Hability hero increment hero points to ${u}`)},e=t?.querySelectorAll("div.mod span.operator.reduce"),e.length==0){o.error("Hability Hero operator reduce not found");return}r=e.item(0),r.onclick=n=>{n.preventDefault();const c=document.querySelectorAll("form.editable div.ability-score.flipped[data-ability='hon'] input");if(c.length!=1){o.error("Hability hero increment hero points not found input to increment ore found more then one, close others sheets before changing hero points");return}const i=c.item(0);if(i.value==null||i.value==""){o.error("Hability hero increment hero points not found input value to increment, close others sheets before changing hero points");return}const l=Number.parseInt(i.value,10);if(l==0){o.error("You haven´t hero points to decrement");return}const u=Math.floor(l/2);i.value=u.toString(),o.debug(`Hability hero decrement hero points to ${u}`)}}createDialog(t){const o=a.injectController.resolve("Log"),e=a.injectController.resolve("DialogUtils");let r={};t.onclick=n=>{n.preventDefault(),o.debug("clicou na habilidade");const c=e.createButton("cancel","Cancelar",!0,"action",i=>{r.close()});o.debug("Hero Points dialog closed."),r=e.createDialog("Sobre Hero Points","",`
31
+ <div class="hero-points-info-content">
32
+ <img class="heroic-action-img"
33
+ src="/modules/common-assets/images/cover/heropoint.webp"
34
+ alt="Ícone representando uma ação heróica em um RPG de fantasia"
35
+ />
36
+
37
+ <p>
38
+ <strong>Hero Points</strong> são semelhantes a pontos de inspiração, mas não são limitados a 1.
39
+ Você começa com zero pontos e eles são acumulativos, diferente de inspiração, em que se pode ter apenas 1 ponto ativo.
40
+ </p>
41
+
42
+ <p>
43
+ <strong>Como obter:</strong> quando chegar na sua vez, se você fizer algo que incremente não somente o seu
44
+ background como o de algum colega (semelhante ao ponto de inspiração, mas sem precisar se colocar em situação ruim),
45
+ você ganha 1 ponto. A ação deve melhorar a história tanto do seu personagem quanto a dos demais jogadores.
46
+ </p>
47
+
48
+ <p>
49
+ <strong>Exemplo de ação heróica:</strong> você sabe que um meio-orc do grupo tem fobia de aranha.
50
+ O mestre descreve uma aranha se aproximando e o jogador dono do personagem não percebe.
51
+ Você decide atacar a aranha antes que seu colega se desespere e note a presença dela.
52
+ Ou, se você é um bardo e sabe que um dos jogadores teve um amor perdido,
53
+ canta uma música na sua rodada para dar inspiração dizendo que é sobre o amor perdido desse personagem.
54
+ É importante que tudo faça sentido na história atual, na história do outro jogador e na sua própria.
55
+ Você pode inclusive ajustar a narração, por exemplo, inventando que havia uma aranha que o mestre nem citou
56
+ e dizer que a matou com uma flecha antes que seu amigo entrasse em pânico.
57
+ </p>
58
+
59
+ <p>
60
+ A jogada deve ser rápida e já pensada durante a vez dos outros; você não pode parar para planejar apenas quando sua vez começa.
61
+ Ela precisa ser ágil para incrementar a narração. Se tudo isso for atendido e o mestre concordar,
62
+ 1 ponto de heroísmo é acrescentado ao personagem.
63
+ </p>
64
+
65
+ <p>
66
+ <strong>Usando uma Ação Heróica (gastando pontos):</strong> o ponto ganho pode ser gasto para realizar uma ação especial envolvendo dois personagens;
67
+ o alvo pode ser um jogador ou um NPC, aliado ou inimigo.
68
+ </p>
69
+
70
+ <p>
71
+ <strong>Como reduzir os pontos:</strong> apenas o Mestre pode reduzir ou aumentar o valor total. Os pontos não são gastos de 1 em 1, quando os pontos são gastos,
72
+ divide-se o total por 2 (arredondando para baixo).
73
+ Exemplos: se você tem 5 pontos, passa a ter 2; se tem 3, passa a ter 1; se tem 1 ponto, passa a ter 0.
74
+ </p>
75
+ </div>
76
+ `,[c],new Array)}}changeHabilityHonrrorToHeroPoints(t){const o=a.injectController.resolve("Log"),e=document.querySelectorAll("form.sheet"),r=e.item(0)?.classList.contains("editable")??!1;if(e.length==0){o.error("Hability hero not enable to convert for hero, your cmpaing not use? Code error: 01");return}o.debug("Hability hero found : "+e.length),e.forEach(n=>{n.querySelectorAll("div.ability-score.flipped[data-ability='hon']").forEach(i=>{const l=a.injectController.resolve("HeroPoints"),u=a.injectController.resolve("Log"),g=i;if(u.debug("found one hability "+g.innerHTML,",isEditable",r),g.querySelectorAll("div.score").length!=1){u.error("Hability hero not enable to convert for hero, your cmpaing not use? Code error: 02");return}let m=g.querySelectorAll("div.score").item(0)?.innerHTML??"0";if(!game.user.isGM){let p=g.querySelectorAll("input");r&&(m=p.item(0).value)}u.debug("Hability hero score: ",m),g.innerHTML=`
77
+ <label class="common-assets attribute" title="clique para mais informações">hero</label>
78
+ <div class="mod">
79
+ <span class="operator reduce" title"para editar, altere o personagem para o modo editável"></span>
80
+ <span class="operator increment" title"para editar, altere o personagem para o modo editável"></span>
81
+ </div>
82
+ <div class="score">${m}</div>
83
+ `,l.addEditButtonsToHeroPoints(g);const h=g.querySelectorAll("label")?.item(0);if(h==null){u.warn("Hability hero not enable to convert for hero, your cmpaing not use? Code error: 01");return}l.createDialog(h)})})}initializeHabilityHero(){Hooks.on("renderDocumentSheetV2",async t=>{const o=a.injectController.resolve("HeroPoints"),e=a.injectController.resolve("Log"),r=t;if(!r.actor){e.debug("Isnt a actor sheet");return}if(e.debug("Hability hero called ",r),r.actor.type!="character"){o.removeAttribute(r),e.debug("Hability hero ignoreted sheet because isnt a player sheet, type:",r.actor.type);return}o.changeHabilityHonrrorToHeroPoints(r)})}}class fe extends f{#e=!0;async waitReady(){if(!this.#e)throw new Error("This module is created ready, no need to wait for hooks");Hooks.callAll("onReadyHideUnidentify",{})}initHooks(){Hooks.on("renderItemSheet5e",(t,o)=>{const e=a.injectController.resolve("Log"),r=a.injectController.resolve("HideUnidentify");e.debug("dnd5e.renderItemSheet5e called"),r.removeItemSheetIdentifyInformations(t,o)}),Hooks.on("dnd5e.getItemContextOptions",(t,o)=>{const e=a.injectController.resolve("Log"),r=a.injectController.resolve("HideUnidentify");e.debug("dnd5e.getItemContextOptions called"),r.removeButtonsFromItemContext(t,o)})}removeButtonsFromItemContext(t,o){const e=a.injectController.resolve("Log");if(e.debug("removeButtonsFromItemContext called"),game.user.isGM){e.debug("is GM - not removing Identify button from Item Sheet context menu");return}if(t.system.identified){e.debug("Item:",t.name," - Item is identified - not removing Identify button from Item Sheet context menu");return}["DND5E.Identify","DND5E.ContextMenuActionAttune"].forEach(c=>{const i=o.findIndex(l=>l.name===c);i!==-1&&(e.debug("Item:",t.name," - Removing",c,"button from Item Sheet context menu at index",i),o.splice(i,1))})}removeItemSheetIdentifyInformations(t,o){const e=a.injectController.resolve("Log");if(e.debug("removeButtonsFromItemContext called"),game.user.isGM){e.debug("is GM - not removing Identify button from Item Sheet context menu");return}t.item.system.identified||(document.querySelectorAll(".dnd5e.sheet.item .sheet-header .item-subtitle label:has(input:not([disabled]))").forEach(n=>n.remove()),document.querySelectorAll(".toggle-identified").forEach(n=>n.remove()))}}class pe extends f{initHooks(){Hooks.once("onReadyCommonModule",async()=>{this.init()})}async waitReady(){Hooks.callAll("onReadyCommonSocket",{})}async executeForAll(t,...o){a.injectController.resolve("Log").debug("Socket dummy executeForAll for event:",t,",parameters: ",o,"...parameters",...o)}async executeAsGM(t,...o){const e=a.injectController.resolve("Log");if(!game.user||!game.users)throw new Error("Game isnt complete prepareted yet, player and gm isnt filled the information. Wait for game ready event ");e.debug("Socket dummy executeAsGM for event:",t,",parameters: ",o,"...parameters",...o)}async executeToGM(t,...o){a.injectController.resolve("Log").debug("Socket dummy executeAsGM for event:",t,",parameters: ",o,"...parameters",...o)}async executeIn(t,o,...e){}isReadyToSendToGM(){return!1}async register(t,o){}}const j={MODULE_VERSION:"common-assets-version"},J=document;class ve extends z{name="common-assets";version="1.0.6";startVersion="";#e=!0;#t=!1;async addInitCommonAssetsChanges(){const t=a.injectController.resolve("Log"),o=a.injectController.resolve("CommonModule");t.debug("addInitCommonAssetsChanges:20,register commnModule:",o),this.registerSetting(j.MODULE_VERSION)}async init(){await super.init(),await this.loadSubModules()}async loadSubModules(){[new le,new ce,new me,new he,new fe].forEach(async e=>{a.injectController.registerByClass(e),await e.init()});const o=new pe;a.injectController.registerByName("Socket",o)}async waitReady(){if(await this.whaitFor(()=>this.#t,3e5),!this.#t)throw new Error("Timeout waiting for hooks");Hooks.callAll("onReadyCommonModule",{})}initHooks(){Hooks.once("init",async()=>{const t=a.injectController.resolve("CommonModule");a.injectController.resolve("Log").info("Módulo Common Assets inicalizando..."),await t.addInitCommonAssetsChanges()}),Hooks.once("ready",async()=>{const t=a.injectController.resolve("CommonModule"),o=a.injectController.resolve("Log");if(!t.version){o.error("Módulo Common Assets não está instalado ou não foi iniciado corretamente.");return}game.user.isGM&&(o.debug("GM detected, adding isGM class to body"),document.body.classList.add("isGM")),o.debug(`Getting the old version with key:${j.MODULE_VERSION}`);const e=await t.getSettings(j.MODULE_VERSION);if(await t.addReadyCommonAssetsChanges(),ae(),this.#t=!0,e===t.version){o.info(`Módulo Common Assets v.${t.version} carregado com sucesso!`);return}await t.updateVersions(e,t.version),o.info(`Módulo Common Assets atualizado de ${e} para ${t.version} e carregado com sucesso!`)})}async addReadyCommonAssetsChanges(){const t=a.injectController.resolve("Log");t.info("Criando botão de ajuda de rolagem");const o=J.getElementById("roll-privacy");if(!o){t.error("Menu privacy não encontrado");return}const e=J.createElement("button");e.textContent="?",e.className="ui-control icon fa-solid fa-help common-assets-help",e.addEventListener("click",r=>{r.preventDefault();const n=game.journal.getName("Como Rolar Dados");if(t.info("Mensagem exibida ao clicar no botão ?"),!n){t.error("Journal não instalado!");return}n.sheet.render(!0)}),o.appendChild(e),t.info("Botão de ajuda de rolagem criado")}async registerSetting(t,o=String){const e=a.injectController.resolve("CommonModule");await game.settings.register(e.name,t,{type:o})}async setSettings(t,o){const e=a.injectController.resolve("CommonModule");await game.settings.set(e.name,t,o)}async getSettings(t){const o=a.injectController.resolve("CommonModule");return await game.settings.get(o.name,t)}async updateVersions(t,o){t!==o&&(this.warnAboutUpdate(t,o),t=o,await this.setSettings(j.MODULE_VERSION,t))}async warnAboutUpdate(t,o){a.injectController.resolve("Log").info(`Atualizando da versão : ${t} para a versão ${o}`)}debug(t){return t!==void 0&&(this.#e=t),this.#e}}const X=new ve,be=document,Ce=new a.LogGenericImpl({format:"",prefix:"CA",hasDate:!0,hasLevel:!0});a.injectController.registerByName("FoundryDocument",be),a.injectController.registerByClass(X),a.injectController.registerByName("Log",Ce),X.init()})();
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "taulukko-common-scripts-dnd5ed",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Taulukko Common Scripts for Foundry dnd5ed",
5
- "main": "dist/common-scripts.iife.js",
5
+ "main": "dist/taulukko-common-scripts-dnd5ed.iife.js",
6
6
  "scripts": {
7
7
  "test": "echo \"Error: no test specified\" && exit 1",
8
8
  "build": "tsc && vite build",
@@ -1,55 +0,0 @@
1
- (function(){"use strict";const L=document;class Q{_isReady=!1;constructor(){this.callHooks()}init(){L.COMMON_MODULE.debug("Dummy Socket initializing..."),this._isReady=!0,Hooks.callAll("onReadyCommonSocket",{})}callHooks(){Hooks.once("onReadyCommonModule",async()=>{this.init()})}async executeForAll(t,...o){L.COMMON_MODULE.debug("Socket dummy executeForAll for event:",t,",parameters: ",o,"...parameters",...o)}async executeAsGM(t,...o){if(!game.user||!game.users)throw new Error("Game isnt complete prepareted yet, player and gm isnt filled the information. Wait for game ready event ");L.COMMON_MODULE.debug("Socket dummy executeAsGM for event:",t,",parameters: ",o,"...parameters",...o)}async executeToGM(t,...o){L.COMMON_MODULE.debug("Socket dummy executeAsGM for event:",t,",parameters: ",o,"...parameters",...o)}async executeIn(t,o,...e){}isReadyToSendToGM(){return!1}async register(t,o){}isReady(){return this._isReady}}const Z=new Q;class ee{getSocket(){return Z}}const m=new ee().getSocket();let d=document;function te(){Hooks.once("onReadyCommonSocket",async()=>{d.COMMON_MODULE.debug("onReadyCommonSocket 20"),m.register("helloEveryOne",r),m.register("helloToGM",t),m.register("helloFromGM",o),d.COMMON_MODULE.debug("Socketlib 20"),m.register("add",e),m.register("someusersadd",s),d.COMMON_MODULE.debug("Socketlib finish the register events");function r(i){d.COMMON_MODULE.debug(`User ${i} says hello for everyone!`)}function t(i){d.COMMON_MODULE.debug(`User ${i} says hello to GM!`)}function o(i){d.COMMON_MODULE.debug("GM say hello to you!",i)}function e(i,a){return d.COMMON_MODULE.debug("The addition is performed on a GM client."),i+a}let n=0;function s(i,a){return d.COMMON_MODULE.debug("The addition is performed on a client of manys - addWithErrors."),i+a+n++}try{if(m.isReadyToSendToGM())if(d.COMMON_MODULE.debug("Gm esta pronto pra receber mensagens"),m.executeForAll("helloEveryOne","teste1"),d.COMMON_MODULE.debug("Depois de usar executeForAll"),game.user.isGM){let g=await m.executeAsGM("add",5,6);d.COMMON_MODULE.debug(`The player calculated: ${g}`),await m.executeAsGM("helloFromGM","Hello from ","GM"),d.COMMON_MODULE.debug("depois de helloFromGM 1")}else{m.executeForAll("helloEveryOne","teste2"),d.COMMON_MODULE.debug("Depois de heldebugM");try{await m.executeAsGM("helloEveryOne","teste5")}catch(g){d.COMMON_MODULE.debug("depois de helloToGM 1",g)}}else d.COMMON_MODULE.debug("A minha implementacao notou que o gm nao foi carregado ainda 1");m.executeForAll("helloEveryOne","teste3"),d.COMMON_MODULE.debug("depois de helloEveryOne 2"),m.executeToGM("helloEveryOne","esse-apenas-gm-deveria-receber");let i=game.users.map(g=>g.id);i=i.filter(g=>(d.COMMON_MODULE.debug("id recebido e meu user id",g,game.user.id),g!=game.user.id));let a=Math.round(1e3*Math.random())+1e3,l=Math.round(i.length*Math.random());l=l==i.length?l-1:l;const O=i.at(l);d.COMMON_MODULE.debug(`Sending to player random: ${O} , I am userid: ${game.user.id} and number random is ${a}`);let h=await m.executeIn("add",[O],a,1);d.COMMON_MODULE.debug(`The player random calculated: ${h}`),m.executeIn("helloEveryOne",[O],"teste4:"+game.user.id),d.COMMON_MODULE.debug(`Depois do teste4 seletivo: ${h}`)}catch(i){d.COMMON_MODULE.debug("Common socket error",i)}})}const f={MODULE_NAME:"common-assets",MODULE_VERSION:"common-assets-version"};let c=document;class A{name="common-assets";version="1.0.0";startVersion="";DIALOG_UTILS;REGION_UTILS;NPC_DIALOG;_prefix="CA:";_debugMode=!1;_printData=this._debugMode;formatCompactDate(t=new Date){const o=t.getFullYear().toString().padStart(4,"0"),e=(t.getMonth()+1).toString().padStart(2,"0"),n=t.getDate().toString().padStart(2,"0"),s=t.getHours().toString().padStart(2,"0"),i=t.getMinutes().toString().padStart(2,"0"),a=t.getSeconds().toString().padStart(2,"0"),l=t.getMilliseconds().toString().padStart(3,"0");return`${o}${e}${n}${s}${i}${a}${l}`}get prefix(){return c.COMMON_MODULE._printData?c.COMMON_MODULE.formatCompactDate(new Date)+" "+c.COMMON_MODULE._prefix:c.COMMON_MODULE._prefix}async startModule(){await this.addInitCommonAssetsChanges(),Hooks.callAll("onInitCommonModule",{})}async addReadyCommonAssetsChanges(){this.debug("Criando botão de ajuda de rolagem");const t=c.getElementById("roll-privacy");if(!t){this.error("Menu privacy não encontrado");return}const o=c.createElement("button");o.textContent="?",o.className="ui-control icon fa-solid fa-help common-assets-help",o.addEventListener("click",e=>{e.preventDefault();const n=game.journal.getName("Como Rolar Dados");if(this.log("Mensagem exibida ao clicar no botão ?"),!n){this.error("Journal não instalado!");return}n.sheet.render(!0)}),t.appendChild(o),this.debug("Botão de ajuda de rolagem criado")}async registerSetting(t,o=String){await game.settings.register(f.MODULE_NAME,t,{type:o})}async registerNewSettings(){this.debug("registerNewSettings:10,module_name:",this.name,",key=",f.MODULE_VERSION),this.debug("registerNewSettings:20,register in settings key:",f.MODULE_VERSION),this.registerSetting(f.MODULE_VERSION),this.debug("registerNewSettings:30, registered"),this.debug("registerNewSettings:40,module_name:",this.name)}async setSettings(t,o){await game.settings.set(f.MODULE_NAME,t,o)}async getSettings(t){return await game.settings.get(f.MODULE_NAME,t)}async addInitCommonAssetsChanges(){this.debug("addInitCommonAssetsChanges:10.1"),await this.registerNewSettings(),this.debug("addInitCommonAssetsChanges:20")}async updateVersions(t,o){t!==o&&(this.warnAboutUpdate(t,o),t=o,await this.setSettings(f.MODULE_VERSION,t))}async warnAboutUpdate(t,o){this.log(`Atualizando da versão : ${t} para a versão ${o}`)}async whaitFor(t,o=6e4,e=100){let n=0;return new Promise((i,a)=>{const l=setInterval(()=>{if(c.COMMON_MODULE.debug("Total time:",n," for function ",t),t()){clearInterval(l),i();return}n>o&&(c.COMMON_MODULE.debug("Timeout for test:",t),clearInterval(l),a(new Error("timeout while wait For in common module"))),n+=e},e)})}debugMode(t=void 0){return t===void 0||(c.COMMON_MODULE._debugMode=t),c.COMMON_MODULE._debugMode}logPrefix(t){c.COMMON_MODULE._prefix=t||"CA:"}genericLog(t,o,...e){const n=c.COMMON_MODULE.prefix;if(t(n,...e),!!c.COMMON_MODULE.debugMode())try{throw new Error("Thread trace "+o+" :"+n)}catch(s){console.error("log "+o+":",s)}}log(...t){c.COMMON_MODULE.genericLog(console.log,"log",...t)}info(...t){c.COMMON_MODULE.genericLog(console.log,"info",...t)}error(...t){c.COMMON_MODULE.genericLog(console.log,"error",...t)}warn(...t){c.COMMON_MODULE.genericLog(console.log,"warn",...t)}debug(...t){c.COMMON_MODULE.genericLog(console.log,"debug",...t)}}c=document,c.COMMON_MODULE=new A;function oe(){Hooks.once("init",async()=>{const r=document;r.COMMON_MODULE=new A,r.COMMON_MODULE.log("Módulo Common Assets inicalizando..."),await r.COMMON_MODULE.startModule()}),Hooks.once("ready",async()=>{if(!c.COMMON_MODULE.version){c.COMMON_MODULE.error("Módulo Common Assets não está instalado ou não foi iniciado corretamente.");return}game.user.isGM&&(c.COMMON_MODULE.log("GM detected, adding isGM class to body"),document.body.classList.add("isGM")),c.COMMON_MODULE.log("Módulo Common Assets call all onReadyCommonModule."),c.COMMON_MODULE.log("Módulo Common Assets sent the messages."),c.COMMON_MODULE.log("Módulo Common Assets launched onReadyCommonModule."),c.COMMON_MODULE.log(`Getting the old version with key:${f.MODULE_VERSION}`);const r=await c.COMMON_MODULE.getSettings(f.MODULE_VERSION);let t="1.0.6";if(await c.COMMON_MODULE.addReadyCommonAssetsChanges(),te(),Hooks.callAll("onReadyCommonModule",{}),r===t){c.COMMON_MODULE.log(`Módulo Common Assets v.${t} carregado com sucesso!`);return}await c.COMMON_MODULE.updateVersions(r,t),c.COMMON_MODULE.log(`Módulo Common Assets ${c.COMMON_MODULE.version} carregado com sucesso!`)})}oe();const p=document,R={MODULE_NAME:"common-assets",TOOGLE_VISIBILITY:"common-assets-toogle-visibility-regions"};Hooks.on("onInitCommonModule",()=>{console.log("Loading Region Utils V1.1.1"),p.COMMON_MODULE.REGION_UTILS={sendMessageToChat:(r,t)=>{const o={user:r,speaker:"Game Master",content:t,whisper:game.users.filter(e=>e.isGM).map(e=>e._id)};ChatMessage.create(o,{})},stop:r=>{const t=r?.region?.shapes[0];if(console.log("event:",r,",shape:",t),!t){console.error("shape not found");return}const o=t.width,e=t.height,n=t.x+Math.round(o/2),s=t.y+Math.round(e/2),i=r?.data?.token;i.x=n,i.y=s,console.log("Token indo para x:",n,",y:",s),i.update({x:i.x,y:i.y})},toggleVisibilityRegions:async()=>{p.COMMON_MODULE.debug("toggleVisibilityRegions called");const r=game.scenes.current;if(!r){p.COMMON_MODULE.log("No scene active");return}r.regions.forEach(t=>{p.COMMON_MODULE.debug("region",t),t.update({visibility:!t.visibility})})},registerKeybindings:async()=>{game.keybindings.register(R.MODULE_NAME,R.TOOGLE_VISIBILITY,{name:"Alternar visão das regiões da cena",hint:"Liga/desliga visibilidade das regiões da cena atual.",editable:[{key:"KeyG",modifiers:["Shift"]}],onDown:async()=>{p.COMMON_MODULE.debug("onDown will be called"),p.COMMON_MODULE.REGION_UTILS.toggleVisibilityRegions()},restricted:!0,reservedModifiers:[],precedence:CONST.KEYBINDING_PRECEDENCE.NORMAL})}},p.COMMON_MODULE.REGION_UTILS.registerKeybindings()});const M=document;function re(){M.COMMON_MODULE.HIDE_UNIDENTIFY={removeButtonsFromItemContext:(r,t)=>{if(M.COMMON_MODULE.debug("removeButtonsFromItemContext called"),game.user.isGM){M.COMMON_MODULE.debugMode&&M.COMMON_MODULE.debug("is GM - not removing Identify button from Item Sheet context menu");return}if(r.system.identified){M.COMMON_MODULE.debug("Item:",r.name," - Item is identified - not removing Identify button from Item Sheet context menu");return}["DND5E.Identify","DND5E.ContextMenuActionAttune"].forEach(n=>{const s=t.findIndex(i=>i.name===n);s!==-1&&(M.COMMON_MODULE.debug("Item:",r.name," - Removing",n,"button from Item Sheet context menu at index",s),t.splice(s,1))})},removeItemSheetIdentifyInformations:(r,t)=>{if(game.user.isGM){M.COMMON_MODULE.debugMode&&M.COMMON_MODULE.debug("removing Info from Item Sheet");return}r.item.system.identified||(M.querySelectorAll(".dnd5e.sheet.item .sheet-header .item-subtitle label:has(input:not([disabled]))").forEach(e=>e.remove()),M.querySelectorAll(".toggle-identified").forEach(e=>e.remove()))},removeCharacterSheetIdentifyInformation:r=>{if(game.user.isGM){if(!M.COMMON_MODULE.debugMode){M.COMMON_MODULE.debug("removing Info from Item Sheet");return}M.COMMON_MODULE.debug("is GM in debug mode - removing information from Item Sheet")}}},Hooks.on("renderItemSheet5e",(r,t)=>{M.COMMON_MODULE.debug("dnd5e.renderItemSheet5e called"),M.COMMON_MODULE.HIDE_UNIDENTIFY.removeItemSheetIdentifyInformations(r,t)}),Hooks.on("dnd5e.getItemContextOptions",(r,t)=>{M.COMMON_MODULE.debug("dnd5e.getItemContextOptions called"),M.COMMON_MODULE.HIDE_UNIDENTIFY.removeButtonsFromItemContext(r,t)}),Hooks.on("renderDocumentSheetV2",r=>{M.COMMON_MODULE.debug("renderDocumentSheetV2 called with parameters:",r),M.COMMON_MODULE.HIDE_UNIDENTIFY.removeCharacterSheetIdentifyInformation(r)})}Hooks.on("onReadyCommonModule",()=>{M.COMMON_MODULE.debug("onReadyCommonModule called"),re()});class ne{constructor(t,o,e=!1,n="screen",s){this.action=t,this.label=o,this.defaultValue=e,this.type=n,this.callback=s}}const D=document;class ie{constructor(){}createButton(t,o,e=!1,n="screen",s){return new ne(t,o,e,n,s)}createDialog(t,o="",e,n,s,i=void 0,a=void 0,l,O){if(D.COMMON_MODULE.debug("Dialog Utils creating dialog width: ",l," height: ",O),!n||!n.length||n.length===0)throw new Error("DIALOG_UTILS.createDialog: buttons array must have at least one button");const h={window:{title:t,resizable:!0},content:`<style>${o}</style>
2
- <div>${e}</div>`,buttons:n,submit:s,position:{width:l,height:O,left:i,top:a}};D.COMMON_MODULE.debug("Dialog Utils dialog options: ",h);const g=new foundry.applications.api.DialogV2(h);return g.render({force:!0}),g}}Hooks.on("onReadyCommonModule",async r=>{D.COMMON_MODULE.debug("Dialog Utils loading on onReadyCommonModule"),Hooks.callAll("onInitDialogUtils",{}),D.COMMON_MODULE.DIALOG_UTILS=new ie,D.COMMON_MODULE.debug("Dialog Utils ready"),Hooks.callAll("onReadyDialogUtils",{})});const u=document;function se(r){let t=u.querySelectorAll("div.ability-score[data-ability='hon']");if(t.length==0){u.COMMON_MODULE.debug("This sheet not contain honrror field or system not enable honrror field");return}u.COMMON_MODULE.debug("Hability hero removed, npc sheet detected"),t.forEach(o=>o.remove())}function ae(r){if(!game.user.isGM)return;let t=r?.querySelectorAll("div.mod span.operator.increment");if(t.length==0){u.COMMON_MODULE.error("Hability Hero operator increment not found");return}let o=t.item(0);if(o.onclick=e=>{e.preventDefault();const n=document.querySelectorAll("form.editable div.ability-score.flipped[data-ability='hon'] input");if(n.length!=1){u.COMMON_MODULE.error("Hability hero increment hero points not found input to increment ore found more then one, close others sheets before changing hero points");return}const s=n.item(0);if(s.value==null||s.value==""){u.COMMON_MODULE.error("Hability hero increment hero points not found input value to increment");return}const a=parseInt(s.value,10)+1;s.value=a.toString(),u.COMMON_MODULE.info(`Hability hero increment hero points to ${a}`)},t=r?.querySelectorAll("div.mod span.operator.reduce"),t.length==0){u.COMMON_MODULE.error("Hability Hero operator reduce not found");return}o=t.item(0),o.onclick=e=>{e.preventDefault();const n=document.querySelectorAll("form.editable div.ability-score.flipped[data-ability='hon'] input");if(n.length!=1){u.COMMON_MODULE.error("Hability hero increment hero points not found input to increment ore found more then one, close others sheets before changing hero points");return}const s=n.item(0);if(s.value==null||s.value==""){u.COMMON_MODULE.error("Hability hero increment hero points not found input value to increment, close others sheets before changing hero points");return}const i=parseInt(s.value,10);if(i==0){u.COMMON_MODULE.error("You haven´t hero points to decrement");return}const a=Math.floor(i/2);s.value=a.toString(),u.COMMON_MODULE.info(`Hability hero decrement hero points to ${a}`)}}function le(r){let t={};r.onclick=o=>{o.preventDefault(),u.COMMON_MODULE.log("clicou na habilidade");const e=u.COMMON_MODULE.DIALOG_UTILS.createButton("cancel","Cancelar",!0,"action",n=>{t.close()});u.COMMON_MODULE.log("Hero Points dialog closed."),t=u.COMMON_MODULE.DIALOG_UTILS.createDialog("Sobre Hero Points","",`
3
- <div class="hero-points-info-content">
4
- <img class="heroic-action-img"
5
- src="/modules/common-assets/images/cover/heropoint.webp"
6
- alt="Ícone representando uma ação heróica em um RPG de fantasia"
7
- />
8
-
9
- <p>
10
- <strong>Hero Points</strong> são semelhantes a pontos de inspiração, mas não são limitados a 1.
11
- Você começa com zero pontos e eles são acumulativos, diferente de inspiração, em que se pode ter apenas 1 ponto ativo.
12
- </p>
13
-
14
- <p>
15
- <strong>Como obter:</strong> quando chegar na sua vez, se você fizer algo que incremente não somente o seu
16
- background como o de algum colega (semelhante ao ponto de inspiração, mas sem precisar se colocar em situação ruim),
17
- você ganha 1 ponto. A ação deve melhorar a história tanto do seu personagem quanto a dos demais jogadores.
18
- </p>
19
-
20
- <p>
21
- <strong>Exemplo de ação heróica:</strong> você sabe que um meio-orc do grupo tem fobia de aranha.
22
- O mestre descreve uma aranha se aproximando e o jogador dono do personagem não percebe.
23
- Você decide atacar a aranha antes que seu colega se desespere e note a presença dela.
24
- Ou, se você é um bardo e sabe que um dos jogadores teve um amor perdido,
25
- canta uma música na sua rodada para dar inspiração dizendo que é sobre o amor perdido desse personagem.
26
- É importante que tudo faça sentido na história atual, na história do outro jogador e na sua própria.
27
- Você pode inclusive ajustar a narração, por exemplo, inventando que havia uma aranha que o mestre nem citou
28
- e dizer que a matou com uma flecha antes que seu amigo entrasse em pânico.
29
- </p>
30
-
31
- <p>
32
- A jogada deve ser rápida e já pensada durante a vez dos outros; você não pode parar para planejar apenas quando sua vez começa.
33
- Ela precisa ser ágil para incrementar a narração. Se tudo isso for atendido e o mestre concordar,
34
- 1 ponto de heroísmo é acrescentado ao personagem.
35
- </p>
36
-
37
- <p>
38
- <strong>Usando uma Ação Heróica (gastando pontos):</strong> o ponto ganho pode ser gasto para realizar uma ação especial envolvendo dois personagens;
39
- o alvo pode ser um jogador ou um NPC, aliado ou inimigo.
40
- </p>
41
-
42
- <p>
43
- <strong>Como reduzir os pontos:</strong> apenas o Mestre pode reduzir ou aumentar o valor total. Os pontos não são gastos de 1 em 1, quando os pontos são gastos,
44
- divide-se o total por 2 (arredondando para baixo).
45
- Exemplos: se você tem 5 pontos, passa a ter 2; se tem 3, passa a ter 1; se tem 1 ponto, passa a ter 0.
46
- </p>
47
- </div>
48
- `,[e],new Array)}}function ce(r){const t=u.querySelectorAll("form.sheet"),o=t.item(0)?.classList.contains("editable")??!1;if(t.length==0){u.COMMON_MODULE.error("Hability hero not enable to convert for hero, your cmpaing not use? Code error: 01");return}u.COMMON_MODULE.debug("Hability hero found : "+t.length),t.forEach(e=>{e.querySelectorAll("div.ability-score.flipped[data-ability='hon']").forEach(s=>{const i=s;if(u.COMMON_MODULE.debug("found one hability "+i.innerHTML,",isEditable",o),i.querySelectorAll("div.score").length!=1){u.COMMON_MODULE.error("Hability hero not enable to convert for hero, your cmpaing not use? Code error: 02");return}let l=i.querySelectorAll("div.score").item(0)?.innerHTML??"0";if(!game.user.isGM){let h=i.querySelectorAll("input");o&&(l=h.item(0).value)}u.COMMON_MODULE.debug("Hability hero score: ",l),i.innerHTML=`
49
- <label class="common-assets attribute" title="clique para mais informações">hero</label>
50
- <div class="mod">
51
- <span class="operator reduce" title"para editar, altere o personagem para o modo editável"></span>
52
- <span class="operator increment" title"para editar, altere o personagem para o modo editável"></span>
53
- </div>
54
- <div class="score">${l}</div>
55
- `,ae(i);const O=i.querySelectorAll("label")?.item(0);if(O==null){u.COMMON_MODULE.warn("Hability hero not enable to convert for hero, your cmpaing not use? Code error: 01");return}le(O)})})}function ue(){Hooks.on("renderDocumentSheetV2",async r=>{const t=r;if(!t.actor){u.COMMON_MODULE.debug("Isnt a actor sheet");return}if(u.COMMON_MODULE.debug("Hability hero called ",t),t.actor.type!="character"){se(),u.COMMON_MODULE.debug("Hability hero ignoreted sheet because isnt a player sheet, type:",t.actor.type);return}ce()})}Hooks.on("onReadyCommonModule",async()=>{u.COMMON_MODULE.info("Starting Hability hero processing"),ue(),u.COMMON_MODULE.info("Hability hero initialized")});var U={},b={},E={},G;function N(){if(G)return E;G=1,Object.defineProperty(E,"__esModule",{value:!0}),E.StringsUtil=void 0;class r{left(o,e){return e>0?o.slice(0,e):""}trim(o){return o.trim()}right(o,e){return e>0?o.slice(-e):""}repeat(o,e,n){return e>0?Array.from({length:e},()=>o).join(n):""}leftPadding(o,e,n){return e>0?o.padStart(e,n).slice(-e):""}rightPadding(o,e,n){return e>0?o.padEnd(e,n).slice(0,e):""}count(o,e){return o.split(e).length-1}hashNumber(o){let e=0,n,s;if(o.length===0)return e;for(n=0;n<o.length;n++)s=o.codePointAt(n),e=(e<<5)-e+s,e|=0;return e}hashString(o){return this.hashNumber(o).toString(36)}}return E.StringsUtil=r,E}var H;function T(){if(H)return b;H=1,Object.defineProperty(b,"__esModule",{value:!0}),b.DatesUtil=void 0;const r=N();class t{stringUtil=new r.StringsUtil;addDays(e,n){const s=new Date(e);return s.setDate(e.getDate()+n),s}parseYYYYMMDDHHMMSS(e){if(e.length!==14)throw new Error("Date format YYYYMMDDHHMMSS incorrect!");const n=this.stringUtil.right(e,6);if(isNaN(Number(n)))throw new Error("Time must be numeric integer");const s=this.stringUtil.left(n,2);if(isNaN(Number(s)))throw new Error("Hour must be numeric integer");const i=this.stringUtil.left(this.stringUtil.right(n,4),2);if(isNaN(Number(i)))throw new Error("Minute must be numeric integer");const a=this.stringUtil.right(n,2);if(isNaN(Number(a)))throw new Error("Second must be numeric integer");const l=this.parseYYYYMMDD(this.stringUtil.left(e,8));return l.setHours(Number.parseInt(s,10)),l.setMinutes(Number.parseInt(i,10)),l.setSeconds(Number.parseInt(a,10)),l}parseYYYYMMDD(e){if(e.length!==8)throw new Error("Date format YYYYMMDD incorrect!");const n=this.stringUtil.left(e,4);if(isNaN(Number(n)))throw new Error("Year must be numeric integer");const s=this.stringUtil.right(this.stringUtil.left(e,6),2);if(isNaN(Number(s)))throw new Error("Month must be numeric integer");const i=this.stringUtil.right(e,2);if(isNaN(Number(i)))throw new Error("Day must be numeric integer");return this.parse(Number.parseInt(n,10),Number.parseInt(s,10),Number.parseInt(i,10))}parse(e,n,s,i=0,a=0,l=0){return new Date(e,n-1,s,i,a,l)}getYear(e){return e.getFullYear()}getMonth(e){return e.getMonth()+1}getMonthIndex(e){return e.getMonth()}getDay(e){return e.getDate()}getDayOfWeak(e){return e.getDay()+1}getDayOfWeakIndex(e){return e.getDay()}toString(e,n=14){if(n<1)return"";n>14&&(n=14);const s=e.getFullYear().toString().padStart(4,"0"),i=(e.getMonth()+1).toString().padStart(2,"0"),a=e.getDate().toString().padStart(2,"0"),l=e.getHours().toString().padStart(2,"0"),O=e.getMinutes().toString().padStart(2,"0"),h=e.getSeconds().toString().padStart(2,"0"),g=`${s}${i}${a}${l}${O}${h}`;return this.stringUtil.left(g,n)}}return b.DatesUtil=t,b}var y={},k;function de(){if(k)return y;k=1,Object.defineProperty(y,"__esModule",{value:!0}),y.KeyTool=void 0;const r=N(),t="10";class o{stringUtil=new r.StringsUtil;generateUUID(){var n=new Date().getTime(),s=typeof performance<"u"&&performance.now&&performance.now()*1e3||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(i){var a=Math.random()*16;return n>0?(a=(n+a)%16|0,n=Math.floor(n/16)):(a=(s+a)%16|0,s=Math.floor(s/16)),(i==="x"?a:a&3|8).toString(16)})}build(n,s){if(n>=1e3||n<0)throw new Error("Cluster must be between 0-999");if(s<0)throw new Error("ProccessID must be >= 0");s=s%1e6;const i=this.stringUtil.right("0000"+Math.round(Math.random()*9999),4),a=this.generateUUID();return t+this.stringUtil.right("000"+n,3)+this.stringUtil.right("000000"+s,6)+i+"--"+a}}return y.KeyTool=o,y}var v={},x;function Me(){if(x)return v;x=1,Object.defineProperty(v,"__esModule",{value:!0}),v.ObjectsUtil=void 0;class r{shallowCopy(o){return JSON.parse(JSON.stringify(o))}partialCopy(o,e,n){const s=this.shallowCopy(e);for(const i of n)s[i]=o[i];return s}}return v.ObjectsUtil=r,v}var I={},_={},q;function F(){if(q)return _;q=1,Object.defineProperty(_,"__esModule",{value:!0}),_.InjectorFactory=void 0;class r{factory;constructor(o){this.factory=o}build(){return this.factory()}}return _.InjectorFactory=r,_}var C={},Y;function P(){if(Y)return C;Y=1,Object.defineProperty(C,"__esModule",{value:!0}),C.injectController=void 0;const r=F();class t{registrations=new Map;registerByClass(e){let n;return e instanceof r.InjectorFactory?n=e.build().constructor.name:n=e.constructor.name,this.registerByName(n,e)}registerByName(e,n){return this.registrations.set(e,n),this}resolve(e){if(!this.registrations.has(e))throw new Error("key ["+e+"] not registered");const n=this.registrations.get(e);return n instanceof r.InjectorFactory?n.build():n}has(e){return typeof e!="string"&&(e=e.constructor.name),this.registrations.has(e)}clearAll(){return this.registrations.clear(),this}unregister(e){return typeof e!="string"&&(e=e.constructor.name),this.registrations.delete(e),this}}return C.injectController=new t,C}var B;function ge(){return B||(B=1,(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.injectController=r.InjectorFactory=void 0;var t=F();Object.defineProperty(r,"InjectorFactory",{enumerable:!0,get:function(){return t.InjectorFactory}});var o=P();Object.defineProperty(r,"injectController",{enumerable:!0,get:function(){return o.injectController}})})(I)),I}var S={},w={},V;function K(){return V||(V=1,(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.Level=void 0,(function(t){t.CRITICAL="CRITICAL",t.ERROR="ERROR",t.WARN="WARN",t.INFO="INFO",t.DEBUG="DEBUG"})(r.Level||(r.Level={}))})(w)),w}var j={},W;function me(){return W||(W=1,(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.LogGenericImpl=r.BUILD_DATE_KEY=void 0;const t=T(),o=P(),e=K();r.BUILD_DATE_KEY="LogGenericImpl.BuildDate";const n={[e.Level.DEBUG]:0,[e.Level.INFO]:1,[e.Level.WARN]:2,[e.Level.ERROR]:3,[e.Level.CRITICAL]:4};class s{#t=e.Level.INFO;#o;#r;#n;#i;#s;#e;#a;#l=new t.DatesUtil;constructor(a={prefix:"",hasDate:!0,hasLevel:!0,format:""}){const l="LogGenericImpl.";this.#o=o.injectController.has(l+e.Level.CRITICAL)?o.injectController.resolve(l+e.Level.CRITICAL):console.error,this.#r=o.injectController.has(l+e.Level.ERROR)?o.injectController.resolve(l+e.Level.ERROR):console.error,this.#n=o.injectController.has(l+e.Level.WARN)?o.injectController.resolve(l+e.Level.WARN):console.warn,this.#i=o.injectController.has(l+e.Level.INFO)?o.injectController.resolve(l+e.Level.INFO):console.info,this.#s=o.injectController.has(l+e.Level.DEBUG)?o.injectController.resolve(l+e.Level.DEBUG):console.debug,this.#a=o.injectController.has(r.BUILD_DATE_KEY)?o.injectController.resolve(r.BUILD_DATE_KEY):()=>new Date,this.#e=a}level(a=void 0){return a!=null&&(this.#t=a),this.#t}isCompatible(a){const l=n[this.#t];return n[a]>=l}log(a,l,...O){if(!this.isCompatible(l))return;const h=this.#l.toString(this.#a(),14),g=[];this.#e.prefix&&g.push(this.#e.prefix),this.#e.hasLevel&&g.push(`[${l}]`),this.#e.hasDate&&g.push(h);const X=g.join(" ");X?a(X,...O):a(...O)}critical(...a){this.log(this.#o,e.Level.CRITICAL,...a)}error(...a){this.log(this.#r,e.Level.ERROR,...a)}warn(...a){this.log(this.#n,e.Level.WARN,...a)}info(...a){this.log(this.#i,e.Level.INFO,...a)}debug(...a){this.log(this.#s,e.Level.DEBUG,...a)}}r.LogGenericImpl=s})(j)),j}var z;function Oe(){return z||(z=1,(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.BUILD_DATE_KEY=r.LogGenericImpl=r.Level=void 0;var t=K();Object.defineProperty(r,"Level",{enumerable:!0,get:function(){return t.Level}});var o=me();Object.defineProperty(r,"LogGenericImpl",{enumerable:!0,get:function(){return o.LogGenericImpl}}),Object.defineProperty(r,"BUILD_DATE_KEY",{enumerable:!0,get:function(){return o.BUILD_DATE_KEY}})})(S)),S}var $;function he(){return $||($=1,(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.BUILD_DATE_KEY=r.LogGenericImpl=r.Level=r.InjectorFactory=r.injectController=r.StringsUtil=r.ObjectsUtil=r.KeyTool=r.DatesUtil=void 0;var t=T();Object.defineProperty(r,"DatesUtil",{enumerable:!0,get:function(){return t.DatesUtil}});var o=de();Object.defineProperty(r,"KeyTool",{enumerable:!0,get:function(){return o.KeyTool}});var e=Me();Object.defineProperty(r,"ObjectsUtil",{enumerable:!0,get:function(){return e.ObjectsUtil}});var n=N();Object.defineProperty(r,"StringsUtil",{enumerable:!0,get:function(){return n.StringsUtil}});var s=ge();Object.defineProperty(r,"injectController",{enumerable:!0,get:function(){return s.injectController}}),Object.defineProperty(r,"InjectorFactory",{enumerable:!0,get:function(){return s.InjectorFactory}});var i=Oe();Object.defineProperty(r,"Level",{enumerable:!0,get:function(){return i.Level}}),Object.defineProperty(r,"LogGenericImpl",{enumerable:!0,get:function(){return i.LogGenericImpl}}),Object.defineProperty(r,"BUILD_DATE_KEY",{enumerable:!0,get:function(){return i.BUILD_DATE_KEY}})})(U)),U}var J=he();J.injectController.registerByName("HelloWorld","Hello World"),console.log(J.injectController.resolve("HelloWorld")+" InjectController")})();