{"version":3,"file":"todo_controller-Dz26Xz3C.js","sources":["../../app/assets/javascript/controllers/channels/todo_controller.js"],"sourcesContent":["import { Controller } from \"@hotwired/stimulus\"\nimport consumer from \"../../channels/consumer\"\n\nexport default class extends Controller {\n static values = {\n id: String,\n payload: Object,\n url: String,\n done: Boolean,\n turboFrame: String,\n };\n\n connect() {\n this.channel = consumer.subscriptions.create(\n { channel: \"TodoChannel\", todo_id: this.idValue },\n { received: (data) => this.receivedMessage(data) }\n );\n\n const event = new CustomEvent(\"todo-status-updated\", {\n detail: { todoId: this.idValue, done: this.doneValue }\n });\n window.dispatchEvent(event);\n }\n\n disconnect() {\n this.channel.unsubscribe();\n }\n\n receivedMessage({ meta, payload }) {\n if (meta.force_refresh) {\n this.processRefresh(payload);\n return;\n }\n\n for (const key in this.payloadValue) {\n if (this.payloadValue[key] !== payload[key]) {\n this.processRefresh(payload);\n return;\n }\n }\n }\n\n processRefresh(payload) {\n this.payloadValue = payload;\n\n const frame = document.querySelector(this.turboFrameValue);\n frame.src = this.urlValue;\n frame.removeAttribute(\"complete\");\n }\n}\n"],"names":["todo_controller","Controller","consumer","data","event","meta","payload","key","frame","__publicField"],"mappings":"6UAGe,MAAKA,UAASC,CAAW,CAStC,SAAU,CACR,KAAK,QAAUC,EAAS,cAAc,OACpC,CAAE,QAAS,cAAe,QAAS,KAAK,OAAS,EACjD,CAAE,SAAWC,GAAS,KAAK,gBAAgBA,CAAI,CAAC,CACjD,EAED,MAAMC,EAAQ,IAAI,YAAY,sBAAuB,CACnD,OAAQ,CAAE,OAAQ,KAAK,QAAS,KAAM,KAAK,SAAS,CAC1D,CAAK,EACD,OAAO,cAAcA,CAAK,CAC9B,CAEE,YAAa,CACX,KAAK,QAAQ,YAAa,CAC9B,CAEE,gBAAgB,CAAE,KAAAC,EAAM,QAAAC,GAAW,CACjC,GAAID,EAAK,cAAe,CACtB,KAAK,eAAeC,CAAO,EAC3B,MACN,CAEI,UAAWC,KAAO,KAAK,aACrB,GAAI,KAAK,aAAaA,CAAG,IAAMD,EAAQC,CAAG,EAAG,CAC3C,KAAK,eAAeD,CAAO,EAC3B,MACR,CAEA,CAEE,eAAeA,EAAS,CACtB,KAAK,aAAeA,EAEpB,MAAME,EAAQ,SAAS,cAAc,KAAK,eAAe,EACzDA,EAAM,IAAM,KAAK,SACjBA,EAAM,gBAAgB,UAAU,CACpC,CACA,CA7CEC,EADkBT,EACX,SAAS,CACd,GAAI,OACJ,QAAS,OACT,IAAK,OACL,KAAM,QACN,WAAY,MACb"}