@blinkk/root-cms 3.0.6 → 3.1.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.
Files changed (153) hide show
  1. package/README.md +77 -0
  2. package/dist/app.js +6 -4
  3. package/dist/browser-client/browser-client.d.ts +148 -0
  4. package/dist/browser-client/embed-window.d.ts +66 -0
  5. package/dist/browser-client/emitter.d.ts +11 -0
  6. package/dist/browser-client.js +377 -0
  7. package/dist/{chunk-RXWDB3K4.js → chunk-4VZTYUQ7.js} +1 -1
  8. package/dist/{chunk-N4K6ICFR.js → chunk-AFBSITEO.js} +4 -6
  9. package/dist/{chunk-PNLLZXVY.js → chunk-AJDMNTZQ.js} +2 -2
  10. package/dist/chunk-J72JK4KR.js +8 -0
  11. package/dist/{chunk-7L5OI5ES.js → chunk-X5CNR4CK.js} +8 -4
  12. package/dist/cli.js +2 -1
  13. package/dist/client.js +2 -1
  14. package/dist/core/client.d.ts +5 -0
  15. package/dist/core/plugin.d.ts +1 -1
  16. package/dist/core/translations.d.ts +19 -4
  17. package/dist/core.js +4 -2
  18. package/dist/functions.js +4 -3
  19. package/dist/plugin.js +38 -7
  20. package/dist/shared/embed-protocol.d.ts +72 -0
  21. package/dist/shared/translation-languages.d.ts +67 -0
  22. package/dist/ui/AIPage-2N5UYBRX.js +1 -0
  23. package/dist/ui/AssetsPage-KLGNE6D6.js +1 -0
  24. package/dist/ui/CollectionPage-D7IG6526.js +1 -0
  25. package/dist/ui/ComparePage-726NIJW5.js +1 -0
  26. package/dist/ui/DataPage-YMSQCIVK.js +1 -0
  27. package/dist/ui/DataSourcePage-7VPFUG3K.js +1 -0
  28. package/dist/ui/DocTranslationsPage-FO7O76VK.js +1 -0
  29. package/dist/ui/DocumentPage-M7SJ4ITQ.js +1 -0
  30. package/dist/ui/EditDataSourcePage-Y7YK6IWT.js +1 -0
  31. package/dist/ui/EditReleasePage-XZ4RHHRT.js +1 -0
  32. package/dist/ui/EmbeddedAIPage-RJOUIPF2.js +1 -0
  33. package/dist/ui/EmbeddedDocumentPage-4TLMCDSO.js +1 -0
  34. package/dist/ui/{ImageEditorDialog-QEULJAT2.js → ImageEditorDialog-GGS4VFEA.js} +2 -2
  35. package/dist/ui/LogsPage-IGDDZGEI.js +1 -0
  36. package/dist/ui/NewDataSourcePage-YUPRHL7F.js +1 -0
  37. package/dist/ui/NewReleasePage-6HHLYOQP.js +1 -0
  38. package/dist/ui/NotFoundPage-A6OCYREA.js +1 -0
  39. package/dist/ui/ProjectPage-UHRXNN7O.js +1 -0
  40. package/dist/ui/ReleasePage-V2JMPWX7.js +1 -0
  41. package/dist/ui/ReleasesPage-SCR4SVKN.js +1 -0
  42. package/dist/ui/SettingsPage-5XKHPG6K.js +1 -0
  43. package/dist/ui/SidebarToolsPage-VXVRZ2C3.js +1 -0
  44. package/dist/ui/TaskPage-LDPRN3G6.js +1 -0
  45. package/dist/ui/TasksPage-DIXUWYXM.js +1 -0
  46. package/dist/ui/TranslationsArbPage-QPD3ZBT4.js +2 -0
  47. package/dist/ui/TranslationsEditPage-475Z7UPC.js +1 -0
  48. package/dist/ui/{TranslationsPage-OBN6CQZZ.js → TranslationsPage-674JU6L4.js} +32 -32
  49. package/dist/ui/{chunk-N4DFAIC5.js → chunk-2EPQJUGM.js} +1 -1
  50. package/dist/ui/{chunk-WKOX3VFN.js → chunk-2RAVKX2Z.js} +2 -2
  51. package/dist/ui/chunk-2S5HMST6.js +1 -0
  52. package/dist/ui/{chunk-V7RAXP2W.js → chunk-3E6CASIN.js} +1 -1
  53. package/dist/ui/chunk-4ALFT4ES.js +141 -0
  54. package/dist/ui/{chunk-KYKFNAX4.js → chunk-4FGASIIX.js} +1 -1
  55. package/dist/ui/chunk-4ISFTE2G.js +5 -0
  56. package/dist/ui/{chunk-SKEP5WYH.js → chunk-7SK47HHZ.js} +3 -3
  57. package/dist/ui/chunk-AAHM6RYJ.js +1 -0
  58. package/dist/ui/chunk-AGFPVTBA.js +1 -0
  59. package/dist/ui/chunk-BUNR5EU3.js +1 -0
  60. package/dist/ui/{chunk-N5Y5OWTV.js → chunk-BW2MKGNP.js} +1 -1
  61. package/dist/ui/{chunk-2225WAJ2.js → chunk-CAY5NM4Z.js} +1 -1
  62. package/dist/ui/{chunk-4KE2SZKH.js → chunk-D3UIZHRK.js} +1 -1
  63. package/dist/ui/{chunk-HYARD7BK.js → chunk-ENQKSLGJ.js} +1 -1
  64. package/dist/ui/chunk-FBSBL476.js +1 -0
  65. package/dist/ui/{chunk-NQB37NMX.js → chunk-FJLNXXE3.js} +1 -1
  66. package/dist/ui/chunk-GT5EQSEX.js +1 -0
  67. package/dist/ui/{chunk-KPJ53X55.js → chunk-HARRKJFZ.js} +1 -1
  68. package/dist/ui/{chunk-6E7PGMZX.js → chunk-HO3W4RVG.js} +1 -1
  69. package/dist/ui/{chunk-CVGYBXVH.js → chunk-J5E457OI.js} +1 -1
  70. package/dist/ui/{chunk-SEUH7LN2.js → chunk-JBHRZ4EX.js} +1 -1
  71. package/dist/ui/{chunk-W3HIZQ4Z.js → chunk-JS6TK4OP.js} +1 -1
  72. package/dist/ui/{chunk-BEDUTYQP.js → chunk-JTIQBW33.js} +1 -1
  73. package/dist/ui/{chunk-ORXEMIQC.js → chunk-KRNQ6L35.js} +1 -1
  74. package/dist/ui/chunk-LROR6N3B.js +7 -0
  75. package/dist/ui/{chunk-4CUWZQXT.js.LEGAL.txt → chunk-LROR6N3B.js.LEGAL.txt} +6 -1
  76. package/dist/ui/{chunk-6GPTGBA7.js → chunk-MSYTAJBV.js} +1 -1
  77. package/dist/ui/{chunk-RQKL4KXY.js → chunk-N3JSLTMV.js} +1 -1
  78. package/dist/ui/{chunk-NMBXHKIJ.js → chunk-NJMNOITA.js} +1 -1
  79. package/dist/ui/{chunk-D37DCENS.js → chunk-NSOTG64N.js} +1 -1
  80. package/dist/ui/chunk-NWHGT476.js +1 -0
  81. package/dist/ui/chunk-P2Z66DHV.js +1 -0
  82. package/dist/ui/{chunk-4IXGYXA2.js → chunk-PTPYMVFW.js} +1 -1
  83. package/dist/ui/{chunk-OVRTVMO5.js → chunk-Q7IU4QCY.js} +1 -1
  84. package/dist/ui/{chunk-XYBHH5L4.js → chunk-QF3GPZTI.js} +1 -1
  85. package/dist/ui/{chunk-AXETBZ6T.js → chunk-QHJOTXYB.js} +1 -1
  86. package/dist/ui/{chunk-UHWNLNP4.js → chunk-RHAJNURN.js} +1 -1
  87. package/dist/ui/chunk-SENZVSVZ.js +1 -0
  88. package/dist/ui/chunk-SKQECSUR.js +1 -0
  89. package/dist/ui/chunk-TOGLZDK3.js +1 -0
  90. package/dist/ui/chunk-TPJCPCRR.js +1 -0
  91. package/dist/ui/{chunk-EMYXSVTD.js → chunk-TVYAZN2Q.js} +1 -1
  92. package/dist/ui/{chunk-GDSSFO5R.js → chunk-UUVAD4U4.js} +1 -1
  93. package/dist/ui/{chunk-EGEB6N4J.js → chunk-VD6G5NV4.js} +11 -11
  94. package/dist/ui/{chunk-DXKEDMEI.js → chunk-VJUMFJIX.js} +1 -1
  95. package/dist/ui/chunk-W5DOO6ID.js +1 -0
  96. package/dist/ui/{chunk-6MOPIV5T.js → chunk-W6LP22IK.js} +1 -1
  97. package/dist/ui/{chunk-3XYCOR6Z.js → chunk-WFQU7V3W.js} +1 -1
  98. package/dist/ui/chunk-WMICEDOT.js +1 -0
  99. package/dist/ui/chunk-XMESZUC5.js +1 -0
  100. package/dist/ui/{chunk-T47V6AGW.js → chunk-XWX2622O.js} +1 -1
  101. package/dist/ui/chunk-YMBBWVBB.js +3 -0
  102. package/dist/ui/chunk-YXSXWFLZ.js +1 -0
  103. package/dist/ui/chunk-ZMS6NIGG.js +1 -0
  104. package/dist/ui/gcs-ECSDFCIU.js +1 -0
  105. package/dist/ui/ui.css +1 -1
  106. package/dist/ui/ui.js +1 -1
  107. package/package.json +7 -3
  108. package/dist/ui/AIPage-JPZ4QUB4.js +0 -1
  109. package/dist/ui/AssetsPage-GDJMKS3M.js +0 -1
  110. package/dist/ui/CollectionPage-5DVXJEET.js +0 -1
  111. package/dist/ui/ComparePage-LIXA6G66.js +0 -1
  112. package/dist/ui/DataPage-AP4Z5JPS.js +0 -1
  113. package/dist/ui/DataSourcePage-WO3ZKMFI.js +0 -1
  114. package/dist/ui/DocTranslationsPage-QKYFIVHP.js +0 -1
  115. package/dist/ui/DocumentPage-ON43I5KM.js +0 -1
  116. package/dist/ui/EditDataSourcePage-XVMEV2LJ.js +0 -1
  117. package/dist/ui/EditReleasePage-A2NB5TFG.js +0 -1
  118. package/dist/ui/LogsPage-4LZJX3O4.js +0 -1
  119. package/dist/ui/NewDataSourcePage-4YWX7IOG.js +0 -1
  120. package/dist/ui/NewReleasePage-HWLVTEXX.js +0 -1
  121. package/dist/ui/NotFoundPage-72AXQAYX.js +0 -1
  122. package/dist/ui/ProjectPage-L4GYDIA5.js +0 -1
  123. package/dist/ui/ReleasePage-43BSWL5B.js +0 -1
  124. package/dist/ui/ReleasesPage-CJXAZBP6.js +0 -1
  125. package/dist/ui/SettingsPage-SYXAMKSF.js +0 -1
  126. package/dist/ui/SidebarToolsPage-OFF5BOXP.js +0 -1
  127. package/dist/ui/TaskPage-HBDLHFI5.js +0 -1
  128. package/dist/ui/TasksPage-OLCDTQNB.js +0 -1
  129. package/dist/ui/TranslationsArbPage-E3NCMAMS.js +0 -2
  130. package/dist/ui/TranslationsEditPage-IWOI7Y5G.js +0 -1
  131. package/dist/ui/chunk-32LRQ5MJ.js +0 -1
  132. package/dist/ui/chunk-3HVDIPSS.js +0 -1
  133. package/dist/ui/chunk-3IDOZ4MG.js +0 -1
  134. package/dist/ui/chunk-4CUWZQXT.js +0 -7
  135. package/dist/ui/chunk-AOCBDKLV.js +0 -1
  136. package/dist/ui/chunk-DUJYIOLE.js +0 -5
  137. package/dist/ui/chunk-IDYKCAAL.js +0 -1
  138. package/dist/ui/chunk-IKED2IGU.js +0 -1
  139. package/dist/ui/chunk-J3EGGI57.js +0 -1
  140. package/dist/ui/chunk-MZP6RIG2.js +0 -1
  141. package/dist/ui/chunk-NQ5ARARP.js +0 -1
  142. package/dist/ui/chunk-RI2JWWU3.js +0 -141
  143. package/dist/ui/chunk-RPOP6MVJ.js +0 -1
  144. package/dist/ui/chunk-TDKVKTW4.js +0 -1
  145. package/dist/ui/chunk-TZEZEMRQ.js +0 -1
  146. package/dist/ui/chunk-UA7UCTX5.js +0 -1
  147. package/dist/ui/chunk-UFQSZ6J2.js +0 -3
  148. package/dist/ui/gcs-L33FIRZU.js +0 -1
  149. /package/dist/ui/{ImageEditorDialog-QEULJAT2.js.LEGAL.txt → ImageEditorDialog-GGS4VFEA.js.LEGAL.txt} +0 -0
  150. /package/dist/ui/{chunk-RI2JWWU3.js.LEGAL.txt → chunk-4ALFT4ES.js.LEGAL.txt} +0 -0
  151. /package/dist/ui/{chunk-SKEP5WYH.js.LEGAL.txt → chunk-7SK47HHZ.js.LEGAL.txt} +0 -0
  152. /package/dist/ui/{chunk-NMBXHKIJ.js.LEGAL.txt → chunk-NJMNOITA.js.LEGAL.txt} +0 -0
  153. /package/dist/ui/{chunk-EGEB6N4J.js.LEGAL.txt → chunk-VD6G5NV4.js.LEGAL.txt} +0 -0
@@ -1 +1 @@
1
- import{c as b,n as x}from"./chunk-EGEB6N4J.js";async function A(){let r=window.firebase.db,e=window.__ROOT_CTX.rootConfig.projectId||"default",t=b(r,"Projects",e),s=await x(t);if(!s.exists)return[];let n=(s.data()||{}).roles||{},o=[];return Object.entries(n).forEach(([p,d])=>{(d==="ADMIN"||d==="EDITOR"||d==="CONTRIBUTOR")&&o.push(p)}),o}var E=class r{constructor(e){this.spreadsheetId=e}static async create(e){let t=e.share??!1,s={fields:"spreadsheetId"};e?.title&&(s.resource={properties:{title:e.title}});let n=(await gapi.client.sheets.spreadsheets.create(s)).result,o=new r(n.spreadsheetId);if(o.setSpreadsheet(n),e?.parent&&await gapi.client.drive.files.update({fileId:o.spreadsheetId,addParents:e.parent,removeParents:"root",fields:"id, parents",resource:{},supportsAllDrives:!0}),t)try{let p=await A();await o.share(p,"writer")}catch(p){console.warn("Failed to share spreadsheet:",p)}return o}getUrl(){return U({spreadsheetId:this.spreadsheetId})}async getSheet(e){if(this.sheets||await this.fetchSheets(),this.sheets){for(let t=0;t<this.sheets.length;t++)if(this.sheets[t].gid===e)return this.sheets[t]}return null}async createSheet(e){console.log("createSheet",this.spreadsheetId);let t=await gapi.client.sheets.spreadsheets.batchUpdate({spreadsheetId:this.spreadsheetId,resource:{requests:[{addSheet:{properties:{title:e.title}}}]}}),s=t.result.replies||[];if(s&&s.length>0){let i=s[0].addSheet?.properties?.sheetId;if(typeof i=="number")return new I(this,i,e.title)}throw console.error(t),new Error("failed to get gid of new tab")}async fetchSheets(){let t=(await gapi.client.sheets.spreadsheets.get({spreadsheetId:this.spreadsheetId,fields:"sheets.properties"})).result;this.setSpreadsheet(t)}setSpreadsheet(e){this.spreadsheet=e,this.spreadsheet.sheets&&this.setSheets(this.spreadsheet.sheets)}setSheets(e){let t=[];e.forEach(s=>{let i=s.properties?.sheetId,n=s.properties?.title,o=new I(this,i??0,n);t.push(o)}),this.sheets=t}async share(e,t){await Promise.all(e.map(async s=>{let i;s.startsWith("*@")?i={type:"domain",domain:s.slice(2),role:t}:i={type:"user",emailAddress:s,role:t},await gapi.client.drive.permissions.create({fileId:this.spreadsheetId,resource:i,sendNotificationEmail:!1,fields:"id",supportsAllDrives:!0})}))}},I=class{constructor(e,t,s){this.spreadsheet=e,this.gid=t,this.title=s}async updateValuesMap(e,t){let s=t.keyedBy,i=t.preserveColumns||[];if(!s)throw new Error('missing "keyedBy" argument');let[n,o]=await this.getValues(),p=[...n],d=[],w=-1,S=new Set;d.push(n.map((a,u)=>(a===s&&(w=u),i.includes(a)&&S.add(u),{hasChanges:!1,value:a})));function v(a){d[0].push({hasChanges:!0,value:a}),p.push(a)}w===-1&&v(s);let y={};o.forEach((a,u)=>{let h=u+1;d.push(a.map((c,l)=>(l===w&&c&&(c in y?console.warn(`multiple rows keyed by "${c}"`):y[c]=h),{hasChanges:!1,value:c})))});function O(a){for(let h in a)p.includes(h)||v(h);return p.map(h=>a[h]??null)}e.forEach(a=>{let u=O(a),h=a[s],c=y[h];if(c){let l=d[c];u.map((m,g)=>{g>=l.length?l.push({hasChanges:!0,value:m||""}):m!==null&&l[g].value!==m&&(!S.has(g)||!l[g].value)&&(l[g]={hasChanges:!0,value:m})})}else d.push(u.map(l=>({hasChanges:!!l,value:l||""})))});let C=p.length,R=d.length,$=n.length,F=o.length+1;(C>$||R>F)&&await this.resizeSheet({numCols:C+2,numRows:R+20});let f=[];d.forEach((a,u)=>{for(;a.length>0&&a.at(-1)?.hasChanges===!1;)a.pop();if(a.length!==0){if(a.every(h=>h.hasChanges)){f.push({range:`${this.title}!A${u+1}`,majorDimension:"ROWS",values:[a.map(h=>h.value||"")]});return}a.forEach((h,c)=>{if(h.hasChanges){let l=P(c);f.push({range:`${this.title}!${l}${u+1}`,majorDimension:"ROWS",values:[[h.value||""]]})}})}}),f.length>0&&await gapi.client.sheets.spreadsheets.values.batchUpdate({spreadsheetId:this.spreadsheet.spreadsheetId,resource:{data:f,valueInputOption:"RAW"}})}async replaceSheet(e,t){let s=e.length,i=t.length+1,n=[];n.push(e),n.push(...t.map(p=>e.map(d=>p[d]||""))),await this.resizeSheet({numCols:s+2,numRows:i+20}),console.log("updating cell values");let o=P(s-1);await gapi.client.sheets.spreadsheets.values.update({spreadsheetId:this.spreadsheet.spreadsheetId,range:`${this.title}!A1:${o}${i}`,valueInputOption:"RAW",resource:{range:`${this.title}!A1:${o}${i}`,majorDimension:"ROWS",values:n}})}async resizeSheet(e){let t=[];e.numCols&&t.push({updateSheetProperties:{properties:{sheetId:this.gid,gridProperties:{columnCount:e.numCols}},fields:"gridProperties.columnCount"}}),e.numRows&&t.push({updateSheetProperties:{properties:{sheetId:this.gid,gridProperties:{rowCount:e.numRows}},fields:"gridProperties.rowCount"}}),t.length>0&&(console.log("resizing sheet"),await gapi.client.sheets.spreadsheets.batchUpdate({spreadsheetId:this.spreadsheet.spreadsheetId,resource:{requests:t}}))}async getValues(){let t=(await gapi.client.sheets.spreadsheets.values.get({spreadsheetId:this.spreadsheet.spreadsheetId,range:this.title})).result.values;if(!t||t.length===0)return[[],[]];let s=t[0],i=t.slice(1);return[s,i]}async getValuesMap(){let[e,t]=await this.getValues();return t.map(i=>{let n={};return i.forEach((o,p)=>{let d=e[p];d&&(n[d]=String(o||""))}),n})}async setTitle(e){await gapi.client.sheets.spreadsheets.batchUpdate({spreadsheetId:this.spreadsheet.spreadsheetId,resource:{requests:[{updateSheetProperties:{properties:{title:e,sheetId:this.gid},fields:"title"}}]}}),this.title=e}getUrl(){return U({spreadsheetId:this.spreadsheet.spreadsheetId,gid:this.gid})}async applyL10nTheme(){await gapi.client.sheets.spreadsheets.batchUpdate({spreadsheetId:this.spreadsheet.spreadsheetId,resource:{requests:[{repeatCell:{range:{sheetId:this.gid,startRowIndex:0},cell:{userEnteredFormat:{textFormat:{fontFamily:"Ubuntu",fontSize:10}}},fields:"userEnteredFormat(textFormat)"}},{repeatCell:{range:{sheetId:this.gid,startRowIndex:0,endRowIndex:1},cell:{userEnteredFormat:{textFormat:{bold:!0,fontFamily:"Ubuntu",fontSize:10}}},fields:"userEnteredFormat(textFormat)"}},{updateSheetProperties:{properties:{sheetId:this.gid,gridProperties:{frozenRowCount:1}},fields:"gridProperties.frozenRowCount"}},{updateDimensionProperties:{range:{sheetId:this.gid,dimension:"COLUMNS",startIndex:0,endIndex:1},properties:{pixelSize:320},fields:"pixelSize"}},{updateDimensionProperties:{range:{sheetId:this.gid,dimension:"COLUMNS",startIndex:1},properties:{pixelSize:320},fields:"pixelSize"}},{repeatCell:{range:{sheetId:this.gid,startRowIndex:1,startColumnIndex:0},cell:{userEnteredFormat:{wrapStrategy:"WRAP"}},fields:"userEnteredFormat(wrapStrategy)"}}]}})}};function U(r){let t=[`https://docs.google.com/spreadsheets/d/${r.spreadsheetId}/edit`];return typeof r.gid=="number"&&t.push(`#gid=${r.gid}`),t.join("")}function k(r){if(!r.startsWith("https://docs.google.com/spreadsheets/d/"))return null;let e=r.split("/"),t=e[e.length-2],i=r.slice(r.indexOf("#")).match(/gid=(\d+)/),n=0;return i&&i[1]&&(n=parseInt(i[1])),{spreadsheetId:t,gid:n}}function P(r){let e=[];for(;r>=0;){let t=r%26;e.push(String.fromCharCode(t+65)),r=(r-t-1)/26}return e.reverse().join("")}function z(r){if(!r)return;if(!r.startsWith("https://drive.google.com/drive/folders/")){let s=r.trim();if(s.length===33&&/^[a-zA-Z0-9_-]+$/.test(s))return s}let e=r.trim().split("/");return e[e.length-1]||void 0}function W(r){let e=z(r);return e?`https://drive.google.com/drive/folders/${e}`:"https://drive.google.com/drive"}export{E as a,U as b,k as c,z as d,W as e};
1
+ import{c as b,n as x}from"./chunk-VD6G5NV4.js";async function A(){let r=window.firebase.db,e=window.__ROOT_CTX.rootConfig.projectId||"default",t=b(r,"Projects",e),s=await x(t);if(!s.exists)return[];let n=(s.data()||{}).roles||{},o=[];return Object.entries(n).forEach(([p,d])=>{(d==="ADMIN"||d==="EDITOR"||d==="CONTRIBUTOR")&&o.push(p)}),o}var E=class r{constructor(e){this.spreadsheetId=e}static async create(e){let t=e.share??!1,s={fields:"spreadsheetId"};e?.title&&(s.resource={properties:{title:e.title}});let n=(await gapi.client.sheets.spreadsheets.create(s)).result,o=new r(n.spreadsheetId);if(o.setSpreadsheet(n),e?.parent&&await gapi.client.drive.files.update({fileId:o.spreadsheetId,addParents:e.parent,removeParents:"root",fields:"id, parents",resource:{},supportsAllDrives:!0}),t)try{let p=await A();await o.share(p,"writer")}catch(p){console.warn("Failed to share spreadsheet:",p)}return o}getUrl(){return U({spreadsheetId:this.spreadsheetId})}async getSheet(e){if(this.sheets||await this.fetchSheets(),this.sheets){for(let t=0;t<this.sheets.length;t++)if(this.sheets[t].gid===e)return this.sheets[t]}return null}async createSheet(e){console.log("createSheet",this.spreadsheetId);let t=await gapi.client.sheets.spreadsheets.batchUpdate({spreadsheetId:this.spreadsheetId,resource:{requests:[{addSheet:{properties:{title:e.title}}}]}}),s=t.result.replies||[];if(s&&s.length>0){let i=s[0].addSheet?.properties?.sheetId;if(typeof i=="number")return new I(this,i,e.title)}throw console.error(t),new Error("failed to get gid of new tab")}async fetchSheets(){let t=(await gapi.client.sheets.spreadsheets.get({spreadsheetId:this.spreadsheetId,fields:"sheets.properties"})).result;this.setSpreadsheet(t)}setSpreadsheet(e){this.spreadsheet=e,this.spreadsheet.sheets&&this.setSheets(this.spreadsheet.sheets)}setSheets(e){let t=[];e.forEach(s=>{let i=s.properties?.sheetId,n=s.properties?.title,o=new I(this,i??0,n);t.push(o)}),this.sheets=t}async share(e,t){await Promise.all(e.map(async s=>{let i;s.startsWith("*@")?i={type:"domain",domain:s.slice(2),role:t}:i={type:"user",emailAddress:s,role:t},await gapi.client.drive.permissions.create({fileId:this.spreadsheetId,resource:i,sendNotificationEmail:!1,fields:"id",supportsAllDrives:!0})}))}},I=class{constructor(e,t,s){this.spreadsheet=e,this.gid=t,this.title=s}async updateValuesMap(e,t){let s=t.keyedBy,i=t.preserveColumns||[];if(!s)throw new Error('missing "keyedBy" argument');let[n,o]=await this.getValues(),p=[...n],d=[],w=-1,S=new Set;d.push(n.map((a,u)=>(a===s&&(w=u),i.includes(a)&&S.add(u),{hasChanges:!1,value:a})));function v(a){d[0].push({hasChanges:!0,value:a}),p.push(a)}w===-1&&v(s);let y={};o.forEach((a,u)=>{let h=u+1;d.push(a.map((c,l)=>(l===w&&c&&(c in y?console.warn(`multiple rows keyed by "${c}"`):y[c]=h),{hasChanges:!1,value:c})))});function O(a){for(let h in a)p.includes(h)||v(h);return p.map(h=>a[h]??null)}e.forEach(a=>{let u=O(a),h=a[s],c=y[h];if(c){let l=d[c];u.map((m,g)=>{g>=l.length?l.push({hasChanges:!0,value:m||""}):m!==null&&l[g].value!==m&&(!S.has(g)||!l[g].value)&&(l[g]={hasChanges:!0,value:m})})}else d.push(u.map(l=>({hasChanges:!!l,value:l||""})))});let C=p.length,R=d.length,$=n.length,F=o.length+1;(C>$||R>F)&&await this.resizeSheet({numCols:C+2,numRows:R+20});let f=[];d.forEach((a,u)=>{for(;a.length>0&&a.at(-1)?.hasChanges===!1;)a.pop();if(a.length!==0){if(a.every(h=>h.hasChanges)){f.push({range:`${this.title}!A${u+1}`,majorDimension:"ROWS",values:[a.map(h=>h.value||"")]});return}a.forEach((h,c)=>{if(h.hasChanges){let l=P(c);f.push({range:`${this.title}!${l}${u+1}`,majorDimension:"ROWS",values:[[h.value||""]]})}})}}),f.length>0&&await gapi.client.sheets.spreadsheets.values.batchUpdate({spreadsheetId:this.spreadsheet.spreadsheetId,resource:{data:f,valueInputOption:"RAW"}})}async replaceSheet(e,t){let s=e.length,i=t.length+1,n=[];n.push(e),n.push(...t.map(p=>e.map(d=>p[d]||""))),await this.resizeSheet({numCols:s+2,numRows:i+20}),console.log("updating cell values");let o=P(s-1);await gapi.client.sheets.spreadsheets.values.update({spreadsheetId:this.spreadsheet.spreadsheetId,range:`${this.title}!A1:${o}${i}`,valueInputOption:"RAW",resource:{range:`${this.title}!A1:${o}${i}`,majorDimension:"ROWS",values:n}})}async resizeSheet(e){let t=[];e.numCols&&t.push({updateSheetProperties:{properties:{sheetId:this.gid,gridProperties:{columnCount:e.numCols}},fields:"gridProperties.columnCount"}}),e.numRows&&t.push({updateSheetProperties:{properties:{sheetId:this.gid,gridProperties:{rowCount:e.numRows}},fields:"gridProperties.rowCount"}}),t.length>0&&(console.log("resizing sheet"),await gapi.client.sheets.spreadsheets.batchUpdate({spreadsheetId:this.spreadsheet.spreadsheetId,resource:{requests:t}}))}async getValues(){let t=(await gapi.client.sheets.spreadsheets.values.get({spreadsheetId:this.spreadsheet.spreadsheetId,range:this.title})).result.values;if(!t||t.length===0)return[[],[]];let s=t[0],i=t.slice(1);return[s,i]}async getValuesMap(){let[e,t]=await this.getValues();return t.map(i=>{let n={};return i.forEach((o,p)=>{let d=e[p];d&&(n[d]=String(o||""))}),n})}async setTitle(e){await gapi.client.sheets.spreadsheets.batchUpdate({spreadsheetId:this.spreadsheet.spreadsheetId,resource:{requests:[{updateSheetProperties:{properties:{title:e,sheetId:this.gid},fields:"title"}}]}}),this.title=e}getUrl(){return U({spreadsheetId:this.spreadsheet.spreadsheetId,gid:this.gid})}async applyL10nTheme(){await gapi.client.sheets.spreadsheets.batchUpdate({spreadsheetId:this.spreadsheet.spreadsheetId,resource:{requests:[{repeatCell:{range:{sheetId:this.gid,startRowIndex:0},cell:{userEnteredFormat:{textFormat:{fontFamily:"Ubuntu",fontSize:10}}},fields:"userEnteredFormat(textFormat)"}},{repeatCell:{range:{sheetId:this.gid,startRowIndex:0,endRowIndex:1},cell:{userEnteredFormat:{textFormat:{bold:!0,fontFamily:"Ubuntu",fontSize:10}}},fields:"userEnteredFormat(textFormat)"}},{updateSheetProperties:{properties:{sheetId:this.gid,gridProperties:{frozenRowCount:1}},fields:"gridProperties.frozenRowCount"}},{updateDimensionProperties:{range:{sheetId:this.gid,dimension:"COLUMNS",startIndex:0,endIndex:1},properties:{pixelSize:320},fields:"pixelSize"}},{updateDimensionProperties:{range:{sheetId:this.gid,dimension:"COLUMNS",startIndex:1},properties:{pixelSize:320},fields:"pixelSize"}},{repeatCell:{range:{sheetId:this.gid,startRowIndex:1,startColumnIndex:0},cell:{userEnteredFormat:{wrapStrategy:"WRAP"}},fields:"userEnteredFormat(wrapStrategy)"}}]}})}};function U(r){let t=[`https://docs.google.com/spreadsheets/d/${r.spreadsheetId}/edit`];return typeof r.gid=="number"&&t.push(`#gid=${r.gid}`),t.join("")}function k(r){if(!r.startsWith("https://docs.google.com/spreadsheets/d/"))return null;let e=r.split("/"),t=e[e.length-2],i=r.slice(r.indexOf("#")).match(/gid=(\d+)/),n=0;return i&&i[1]&&(n=parseInt(i[1])),{spreadsheetId:t,gid:n}}function P(r){let e=[];for(;r>=0;){let t=r%26;e.push(String.fromCharCode(t+65)),r=(r-t-1)/26}return e.reverse().join("")}function z(r){if(!r)return;if(!r.startsWith("https://drive.google.com/drive/folders/")){let s=r.trim();if(s.length===33&&/^[a-zA-Z0-9_-]+$/.test(s))return s}let e=r.trim().split("/");return e[e.length-1]||void 0}function W(r){let e=z(r);return e?`https://drive.google.com/drive/folders/${e}`:"https://drive.google.com/drive"}export{E as a,U as b,k as c,z as d,W as e};
@@ -1 +1 @@
1
- import{i as t,j as i}from"./chunk-4CUWZQXT.js";import{j as r,k as o}from"./chunk-KUCVLANF.js";o();i();var s=r(null);function n(){let e=t(s);if(!e)throw new Error("useFirebase() should be called within a <FirebaseProvider>");return e}export{s as a,n as b};
1
+ import{i as t,j as i}from"./chunk-LROR6N3B.js";import{j as r,k as o}from"./chunk-KUCVLANF.js";o();i();var s=r(null);function n(){let e=t(s);if(!e)throw new Error("useFirebase() should be called within a <FirebaseProvider>");return e}export{s as a,n as b};
@@ -1 +1 @@
1
- import{b as g,g as d,i as l,j as p,o as h}from"./chunk-EGEB6N4J.js";var r={year:31536e6,month:2628e6,week:6048e5,day:864e5,hour:36e5,minute:6e4,second:1e3};function w(e,t){let n=Math.abs(e-new Date().getTime());if(n<r.second)return"just now";let i=t||{numeric:"auto"},o=new Intl.RelativeTimeFormat("en",i);return n<r.minute?o.format(Math.round(-n/r.second),"second"):n<r.hour?o.format(Math.round(-n/r.minute),"minute"):n<r.day?o.format(Math.round(-n/r.hour),"hour"):n<r.week?o.format(Math.round(-n/r.day),"day"):new Date(e).toLocaleDateString("en",{year:"numeric",month:"short",day:"numeric"})}function f(){return Math.floor(new Date().getTime())}function I(e){return new Date(e.toMillis()).toLocaleDateString("en",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function M(){let e=a=>a<10?"0"+a:a,t=new Date,n=t.getFullYear(),i=e(t.getMonth()+1),o=e(t.getDate()),s=e(t.getHours()),u=e(t.getMinutes());return`${n}-${i}-${o}T${s}:${u}`}var y={};async function O(e,t){let n=t?.throttle||0,i=t?.throttleId?`${e}::${t.throttleId}`:e;if(b(i,n))return;let o=await fetch("/cms/api/actions.log",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({action:e,metadata:t?.metadata||{},links:t?.links})});if(o.status!==200){let s=await o.text();console.error(`failed to log action "${e}":`,s);return}y[i]=f()}async function k(e){let t=window.__ROOT_CTX.rootConfig.projectId,n=window.firebase.db,i=g(n,"Projects",t,"ActionLogs"),o=e?.limit,s;if(o){let c=Math.ceil(o*1.5);s=d(i,l("timestamp","desc"),p(c))}else s=d(i,l("timestamp","desc"));let u=await h(s),a=[];function T(c){if(a.length===0)return!1;let m=a.at(-1);return c.action==="doc.save"&&m.action==="doc.save"&&c.by===m.by&&c.metadata.docId===m.metadata.docId&&c.timestamp.toMillis()-m.timestamp.toMillis()<60*r.minute}for(let c of u.docs){if(o&&a.length>=o)break;let m=c.data();T(m)||a.push(m)}return a}function b(e,t){if(t===0)return!1;let n=y[e];return n?f()-n<t:!1}export{r as a,w as b,f as c,I as d,M as e,O as f,k as g};
1
+ import{b as g,g as d,i as l,j as p,o as h}from"./chunk-VD6G5NV4.js";var r={year:31536e6,month:2628e6,week:6048e5,day:864e5,hour:36e5,minute:6e4,second:1e3};function w(e,t){let n=Math.abs(e-new Date().getTime());if(n<r.second)return"just now";let i=t||{numeric:"auto"},o=new Intl.RelativeTimeFormat("en",i);return n<r.minute?o.format(Math.round(-n/r.second),"second"):n<r.hour?o.format(Math.round(-n/r.minute),"minute"):n<r.day?o.format(Math.round(-n/r.hour),"hour"):n<r.week?o.format(Math.round(-n/r.day),"day"):new Date(e).toLocaleDateString("en",{year:"numeric",month:"short",day:"numeric"})}function f(){return Math.floor(new Date().getTime())}function I(e){return new Date(e.toMillis()).toLocaleDateString("en",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function M(){let e=a=>a<10?"0"+a:a,t=new Date,n=t.getFullYear(),i=e(t.getMonth()+1),o=e(t.getDate()),s=e(t.getHours()),u=e(t.getMinutes());return`${n}-${i}-${o}T${s}:${u}`}var y={};async function O(e,t){let n=t?.throttle||0,i=t?.throttleId?`${e}::${t.throttleId}`:e;if(b(i,n))return;let o=await fetch("/cms/api/actions.log",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({action:e,metadata:t?.metadata||{},links:t?.links})});if(o.status!==200){let s=await o.text();console.error(`failed to log action "${e}":`,s);return}y[i]=f()}async function k(e){let t=window.__ROOT_CTX.rootConfig.projectId,n=window.firebase.db,i=g(n,"Projects",t,"ActionLogs"),o=e?.limit,s;if(o){let c=Math.ceil(o*1.5);s=d(i,l("timestamp","desc"),p(c))}else s=d(i,l("timestamp","desc"));let u=await h(s),a=[];function T(c){if(a.length===0)return!1;let m=a.at(-1);return c.action==="doc.save"&&m.action==="doc.save"&&c.by===m.by&&c.metadata.docId===m.metadata.docId&&c.timestamp.toMillis()-m.timestamp.toMillis()<60*r.minute}for(let c of u.docs){if(o&&a.length>=o)break;let m=c.data();T(m)||a.push(m)}return a}function b(e,t){if(t===0)return!1;let n=y[e];return n?f()-n<t:!1}export{r as a,w as b,f as c,I as d,M as e,O as f,k as g};