Browse Source

Initial commit

Nariman Jelveh 1 year ago
commit
fa42b0871e
100 changed files with 18879 additions and 0 deletions
  1. 2 0
      .gitattributes
  2. 5 0
      .gitignore
  3. 661 0
      LICENSE.txt
  4. 78 0
      README.md
  5. 3 0
      build.js
  6. 57 0
      dev-server.js
  7. 8 0
      dist/browserconfig.xml
  8. 6 0
      dist/bundle.min.css
  9. 3 0
      dist/bundle.min.js
  10. BIN
      dist/favicon.ico
  11. BIN
      dist/favicons/android-icon-144x144.png
  12. BIN
      dist/favicons/android-icon-192x192.png
  13. BIN
      dist/favicons/android-icon-36x36.png
  14. BIN
      dist/favicons/android-icon-48x48.png
  15. BIN
      dist/favicons/android-icon-72x72.png
  16. BIN
      dist/favicons/android-icon-96x96.png
  17. BIN
      dist/favicons/apple-icon-114x114.png
  18. BIN
      dist/favicons/apple-icon-120x120.png
  19. BIN
      dist/favicons/apple-icon-144x144.png
  20. BIN
      dist/favicons/apple-icon-152x152.png
  21. BIN
      dist/favicons/apple-icon-180x180.png
  22. BIN
      dist/favicons/apple-icon-57x57.png
  23. BIN
      dist/favicons/apple-icon-60x60.png
  24. BIN
      dist/favicons/apple-icon-72x72.png
  25. BIN
      dist/favicons/apple-icon-76x76.png
  26. BIN
      dist/favicons/apple-icon-precomposed.png
  27. BIN
      dist/favicons/apple-icon.png
  28. 2 0
      dist/favicons/browserconfig.xml
  29. BIN
      dist/favicons/favicon-16x16.png
  30. BIN
      dist/favicons/favicon-32x32.png
  31. BIN
      dist/favicons/favicon-96x96.png
  32. BIN
      dist/favicons/favicon.ico
  33. 41 0
      dist/favicons/manifest.json
  34. BIN
      dist/favicons/ms-icon-144x144.png
  35. BIN
      dist/favicons/ms-icon-150x150.png
  36. BIN
      dist/favicons/ms-icon-310x310.png
  37. BIN
      dist/favicons/ms-icon-70x70.png
  38. 127 0
      dist/gui.js
  39. BIN
      dist/images/screenshot.png
  40. BIN
      dist/images/wallpaper.webp
  41. 41 0
      dist/manifest.json
  42. 137 0
      docs/prod.md
  43. 2510 0
      package-lock.json
  44. 33 0
      package.json
  45. 953 0
      src/IPC.js
  46. 8 0
      src/UI/PuterDialog.js
  47. 96 0
      src/UI/UIAlert.js
  48. 211 0
      src/UI/UIContextMenu.js
  49. 1428 0
      src/UI/UIDesktop.js
  50. 1602 0
      src/UI/UIItem.js
  51. 57 0
      src/UI/UINotification.js
  52. 85 0
      src/UI/UIPopover.js
  53. 103 0
      src/UI/UIPrompt.js
  54. 286 0
      src/UI/UITaskbar.js
  55. 346 0
      src/UI/UITaskbarItem.js
  56. 3233 0
      src/UI/UIWindow.js
  57. 110 0
      src/UI/UIWindowChangePassword.js
  58. 111 0
      src/UI/UIWindowChangeUsername.js
  59. 55 0
      src/UI/UIWindowClaimReferral.js
  60. 110 0
      src/UI/UIWindowColorPicker.js
  61. 73 0
      src/UI/UIWindowConfirmDownload.js
  62. 63 0
      src/UI/UIWindowCopyProgress.js
  63. 189 0
      src/UI/UIWindowDesktopBGSettings.js
  64. 53 0
      src/UI/UIWindowDownloadDirProg.js
  65. 63 0
      src/UI/UIWindowDownloadProgress.js
  66. 258 0
      src/UI/UIWindowEmailConfirmationRequired.js
  67. 80 0
      src/UI/UIWindowFeedback.js
  68. 103 0
      src/UI/UIWindowFontPicker.js
  69. 100 0
      src/UI/UIWindowGetCopyLink.js
  70. 226 0
      src/UI/UIWindowItemProperties.js
  71. 171 0
      src/UI/UIWindowLogin.js
  72. 59 0
      src/UI/UIWindowLoginInProgress.js
  73. 63 0
      src/UI/UIWindowMoveProgress.js
  74. 178 0
      src/UI/UIWindowMyWebsites.js
  75. 56 0
      src/UI/UIWindowNewFolderProgress.js
  76. 126 0
      src/UI/UIWindowNewPassword.js
  77. 56 0
      src/UI/UIWindowProgressEmptyTrash.js
  78. 116 0
      src/UI/UIWindowPublishWebsite.js
  79. 61 0
      src/UI/UIWindowQR.js
  80. 110 0
      src/UI/UIWindowRecoverPassword.js
  81. 102 0
      src/UI/UIWindowRefer.js
  82. 75 0
      src/UI/UIWindowRequestFiles.js
  83. 125 0
      src/UI/UIWindowRequestPermission.js
  84. 167 0
      src/UI/UIWindowSaveAccount.js
  85. 24 0
      src/UI/UIWindowSelfhostedWaitlist.js
  86. 138 0
      src/UI/UIWindowSessionList.js
  87. 186 0
      src/UI/UIWindowSignup.js
  88. 57 0
      src/UI/UIWindowUploadProgress.js
  89. 8 0
      src/browserconfig.xml
  90. 349 0
      src/css/normalize.css
  91. 2936 0
      src/css/style.css
  92. BIN
      src/favicon.ico
  93. BIN
      src/favicons/android-icon-144x144.png
  94. BIN
      src/favicons/android-icon-192x192.png
  95. BIN
      src/favicons/android-icon-36x36.png
  96. BIN
      src/favicons/android-icon-48x48.png
  97. BIN
      src/favicons/android-icon-72x72.png
  98. BIN
      src/favicons/android-icon-96x96.png
  99. BIN
      src/favicons/apple-icon-114x114.png
  100. BIN
      src/favicons/apple-icon-120x120.png

+ 2 - 0
.gitattributes

@@ -0,0 +1,2 @@
+# Auto detect text files and perform LF normalization
+* text=auto

+ 5 - 0
.gitignore

@@ -0,0 +1,5 @@
+.DS_Store
+node_modules/
+*.zip
+*.tgz
+license.config.json

+ 661 - 0
LICENSE.txt

@@ -0,0 +1,661 @@
+                    GNU AFFERO GENERAL PUBLIC LICENSE
+                       Version 3, 19 November 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The GNU Affero General Public License is a free, copyleft license for
+software and other kinds of works, specifically designed to ensure
+cooperation with the community in the case of network server software.
+
+  The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works.  By contrast,
+our General Public Licenses are intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+  Developers that use our General Public Licenses protect your rights
+with two steps: (1) assert copyright on the software, and (2) offer
+you this License which gives you legal permission to copy, distribute
+and/or modify the software.
+
+  A secondary benefit of defending all users' freedom is that
+improvements made in alternate versions of the program, if they
+receive widespread use, become available for other developers to
+incorporate.  Many developers of free software are heartened and
+encouraged by the resulting cooperation.  However, in the case of
+software used on network servers, this result may fail to come about.
+The GNU General Public License permits making a modified version and
+letting the public access it on a server without ever releasing its
+source code to the public.
+
+  The GNU Affero General Public License is designed specifically to
+ensure that, in such cases, the modified source code becomes available
+to the community.  It requires the operator of a network server to
+provide the source code of the modified version running there to the
+users of that server.  Therefore, public use of a modified version, on
+a publicly accessible server, gives the public access to the source
+code of the modified version.
+
+  An older license, called the Affero General Public License and
+published by Affero, was designed to accomplish similar goals.  This is
+a different license, not a version of the Affero GPL, but Affero has
+released a new version of the Affero GPL which permits relicensing under
+this license.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                       TERMS AND CONDITIONS
+
+  0. Definitions.
+
+  "This License" refers to version 3 of the GNU Affero General Public License.
+
+  "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+  "The Program" refers to any copyrightable work licensed under this
+License.  Each licensee is addressed as "you".  "Licensees" and
+"recipients" may be individuals or organizations.
+
+  To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy.  The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+  A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+  To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy.  Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+  To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies.  Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+  An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License.  If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+  1. Source Code.
+
+  The "source code" for a work means the preferred form of the work
+for making modifications to it.  "Object code" means any non-source
+form of a work.
+
+  A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+  The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form.  A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+  The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities.  However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work.  For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+  The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+  The Corresponding Source for a work in source code form is that
+same work.
+
+  2. Basic Permissions.
+
+  All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met.  This License explicitly affirms your unlimited
+permission to run the unmodified Program.  The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work.  This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+  You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force.  You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright.  Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+  Conveying under any other circumstances is permitted solely under
+the conditions stated below.  Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+  No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+  When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+  4. Conveying Verbatim Copies.
+
+  You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+  You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+  5. Conveying Modified Source Versions.
+
+  You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+    a) The work must carry prominent notices stating that you modified
+    it, and giving a relevant date.
+
+    b) The work must carry prominent notices stating that it is
+    released under this License and any conditions added under section
+    7.  This requirement modifies the requirement in section 4 to
+    "keep intact all notices".
+
+    c) You must license the entire work, as a whole, under this
+    License to anyone who comes into possession of a copy.  This
+    License will therefore apply, along with any applicable section 7
+    additional terms, to the whole of the work, and all its parts,
+    regardless of how they are packaged.  This License gives no
+    permission to license the work in any other way, but it does not
+    invalidate such permission if you have separately received it.
+
+    d) If the work has interactive user interfaces, each must display
+    Appropriate Legal Notices; however, if the Program has interactive
+    interfaces that do not display Appropriate Legal Notices, your
+    work need not make them do so.
+
+  A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit.  Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+  6. Conveying Non-Source Forms.
+
+  You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+    a) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by the
+    Corresponding Source fixed on a durable physical medium
+    customarily used for software interchange.
+
+    b) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by a
+    written offer, valid for at least three years and valid for as
+    long as you offer spare parts or customer support for that product
+    model, to give anyone who possesses the object code either (1) a
+    copy of the Corresponding Source for all the software in the
+    product that is covered by this License, on a durable physical
+    medium customarily used for software interchange, for a price no
+    more than your reasonable cost of physically performing this
+    conveying of source, or (2) access to copy the
+    Corresponding Source from a network server at no charge.
+
+    c) Convey individual copies of the object code with a copy of the
+    written offer to provide the Corresponding Source.  This
+    alternative is allowed only occasionally and noncommercially, and
+    only if you received the object code with such an offer, in accord
+    with subsection 6b.
+
+    d) Convey the object code by offering access from a designated
+    place (gratis or for a charge), and offer equivalent access to the
+    Corresponding Source in the same way through the same place at no
+    further charge.  You need not require recipients to copy the
+    Corresponding Source along with the object code.  If the place to
+    copy the object code is a network server, the Corresponding Source
+    may be on a different server (operated by you or a third party)
+    that supports equivalent copying facilities, provided you maintain
+    clear directions next to the object code saying where to find the
+    Corresponding Source.  Regardless of what server hosts the
+    Corresponding Source, you remain obligated to ensure that it is
+    available for as long as needed to satisfy these requirements.
+
+    e) Convey the object code using peer-to-peer transmission, provided
+    you inform other peers where the object code and Corresponding
+    Source of the work are being offered to the general public at no
+    charge under subsection 6d.
+
+  A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+  A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling.  In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage.  For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product.  A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+  "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source.  The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+  If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information.  But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+  The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed.  Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+  Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+  7. Additional Terms.
+
+  "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law.  If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+  When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it.  (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.)  You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+  Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+    a) Disclaiming warranty or limiting liability differently from the
+    terms of sections 15 and 16 of this License; or
+
+    b) Requiring preservation of specified reasonable legal notices or
+    author attributions in that material or in the Appropriate Legal
+    Notices displayed by works containing it; or
+
+    c) Prohibiting misrepresentation of the origin of that material, or
+    requiring that modified versions of such material be marked in
+    reasonable ways as different from the original version; or
+
+    d) Limiting the use for publicity purposes of names of licensors or
+    authors of the material; or
+
+    e) Declining to grant rights under trademark law for use of some
+    trade names, trademarks, or service marks; or
+
+    f) Requiring indemnification of licensors and authors of that
+    material by anyone who conveys the material (or modified versions of
+    it) with contractual assumptions of liability to the recipient, for
+    any liability that these contractual assumptions directly impose on
+    those licensors and authors.
+
+  All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10.  If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term.  If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+  If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+  Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+  8. Termination.
+
+  You may not propagate or modify a covered work except as expressly
+provided under this License.  Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+  However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+  Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+  Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License.  If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+  9. Acceptance Not Required for Having Copies.
+
+  You are not required to accept this License in order to receive or
+run a copy of the Program.  Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance.  However,
+nothing other than this License grants you permission to propagate or
+modify any covered work.  These actions infringe copyright if you do
+not accept this License.  Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+  10. Automatic Licensing of Downstream Recipients.
+
+  Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License.  You are not responsible
+for enforcing compliance by third parties with this License.
+
+  An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations.  If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+  You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License.  For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+  11. Patents.
+
+  A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based.  The
+work thus licensed is called the contributor's "contributor version".
+
+  A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version.  For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+  Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+  In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement).  To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+  If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients.  "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+  If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+  A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License.  You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+  Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+  12. No Surrender of Others' Freedom.
+
+  If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all.  For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+  13. Remote Network Interaction; Use with the GNU General Public License.
+
+  Notwithstanding any other provision of this License, if you modify the
+Program, your modified version must prominently offer all users
+interacting with it remotely through a computer network (if your version
+supports such interaction) an opportunity to receive the Corresponding
+Source of your version by providing access to the Corresponding Source
+from a network server at no charge, through some standard or customary
+means of facilitating copying of software.  This Corresponding Source
+shall include the Corresponding Source for any work covered by version 3
+of the GNU General Public License that is incorporated pursuant to the
+following paragraph.
+
+  Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU General Public License into a single
+combined work, and to convey the resulting work.  The terms of this
+License will continue to apply to the part which is the covered work,
+but the work with which it is combined will remain governed by version
+3 of the GNU General Public License.
+
+  14. Revised Versions of this License.
+
+  The Free Software Foundation may publish revised and/or new versions of
+the GNU Affero General Public License from time to time.  Such new versions
+will be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+  Each version is given a distinguishing version number.  If the
+Program specifies that a certain numbered version of the GNU Affero General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation.  If the Program does not specify a version number of the
+GNU Affero General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+  If the Program specifies that a proxy can decide which future
+versions of the GNU Affero General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+  Later license versions may give you additional or different
+permissions.  However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+  15. Disclaimer of Warranty.
+
+  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. Limitation of Liability.
+
+  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+  17. Interpretation of Sections 15 and 16.
+
+  If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU Affero General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU Affero General Public License for more details.
+
+    You should have received a copy of the GNU Affero General Public License
+    along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+  If your software can interact with users remotely through a computer
+network, you should also make sure that it provides a way for users to
+get its source.  For example, if your program is a web application, its
+interface could display a "Source" link that leads users to an archive
+of the code.  There are many ways you could offer source, and different
+solutions will be better for different programs; see section 13 for the
+specific requirements.
+
+  You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU AGPL, see
+<https://www.gnu.org/licenses/>.

+ 78 - 0
README.md

@@ -0,0 +1,78 @@
+<h3 align="center"><img width="80" alt="Puter.com, The Personal Cloud Computer: All your files, apps, and games in one place accessible from anywhere at any time." src="https://github.com/HeyPuter/gui/assets/1715019/ffdc7427-4ed7-41c0-b539-ae7285bd0ffe"></h3>
+
+<h3 align="center">Desktop Environment in the Browser!</h3>
+
+<p align="center">
+    <a href="https://puter.com/"><strong>« LIVE DEMO »</strong></a>
+    <br />
+    <br />
+    <a href="https://puter.com">Puter.com</a>
+    ·
+    <a href="https://docs.puter.com" target="_blank">SDK</a>
+    ·
+    <a href="https://discord.com/invite/PQcx7Teh8u">Discord</a>
+    ·
+    <a href="https://reddit.com/r/puter">Reddit</a>
+    ·
+    <a href="https://twitter.com/HeyPuter">X (Twitter)</a>
+</p>
+
+<h3 align="center"><img width="700" style="border-radius:5px;" alt="screenshot" src="https://github.com/HeyPuter/gui/assets/1715019/a1579d6a-6a42-4fec-9af2-ca0a31326850"></h3>
+
+<br/>
+
+## Getting Started
+
+```bash
+git clone https://github.com/HeyPuter/puter.com
+cd puter.com
+npm install
+npm start
+```
+
+This will launch Puter in development mode at http://localhost:4000 (or the next available port).
+
+<br/>
+
+## Deploy to Production
+
+Here's a detailed guide on how to run Puter in production: [docs/prod.md](docs/prod.md)
+
+<br/>
+
+## FAQ
+
+### ❓ What's the use case for Puter?
+
+Puter can be used as:
+
+- An alternative to Dropbox, Google Drive, OneDrive, etc. with a fresh interface and powerful features.
+- Remote desktop environment for remote servers and workstations.
+- A platform for building and hosting websites, web apps, and games.
+- A friendly, open-source project and community to learn about web development, cloud computing, distributed systems, and much more!
+
+### ❓ Why isn't Puter built with React, Angular, Vue, etc.?
+
+For performance reasons, Puter is built with vanilla JavaScript and jQuery. Additionally, we'd like to avoid complex abstractions and to remain in control of the entire stack, as much as possible.
+
+Also partly inspired by some of our favorite projects that are not built with frameworks: [VSCode](https://github.com/microsoft/vscode), [Photopea](https://www.photopea.com/), and [OnlyOffice](https://www.onlyoffice.com/).
+
+### ❓ Why jQuery?
+
+Puter interacts directly with the DOM and jQuery provides an elegant yet powerful API to manipulate the DOM, handle events, and much more. It's also fast, mature, and battle-tested. 
+
+<br/>
+
+## Credits
+
+The default wallpaper is created by [Milad Fakurian](https://unsplash.com/photos/blue-orange-and-yellow-wallpaper-E8Ufcyxz514) and published on [Unsplash](https://unsplash.com/).
+
+Icons by [Papirus](https://github.com/PapirusDevelopmentTeam/papirus-icon-theme) under GPL-3.0 license.
+
+Icons by [Iconoir](https://iconoir.com/) under MIT license.
+
+Icons by [Elementary Icons](https://github.com/elementary/icons) under GPL-3.0 license.
+
+Icons by [Tabler Icons](https://tabler.io/) under MIT license.
+
+Icons by [bootstrap-icons](https://icons.getbootstrap.com/) under MIT license.

+ 3 - 0
build.js

@@ -0,0 +1,3 @@
+const {build} = require("./utils.js")
+
+build();

+ 57 - 0
dev-server.js

@@ -0,0 +1,57 @@
+const express = require("express");
+const { generateDevHtml, build } = require("./utils.js");
+const { argv } = require('node:process');
+const chalk = require('chalk');
+
+const app = express();
+let port = 4000; // Starting port
+const maxAttempts = 10; // Maximum number of ports to try
+const env = argv[2] ?? "dev";
+
+const startServer = (attempt) => {
+    if (attempt > maxAttempts) {
+        console.error(chalk.red(`ERROR: Unable to find an available port after ${maxAttempts} attempts.`));
+        return;
+    }
+
+    app.listen(port, () => {
+        console.log("\n-----------------------------------------------------------\n");
+        console.log(`Puter is now live at: `, chalk.underline.blue(`http://localhost:${port}`));
+        console.log("\n-----------------------------------------------------------\n");
+    }).on('error', (err) => {
+        if (err.code === 'EADDRINUSE') { // Check if the error is because the port is already in use
+            console.error(chalk.red(`ERROR: Port ${port} is already in use. Trying next port...`));
+            port++; // Increment the port number
+            startServer(attempt + 1); // Try the next port
+        }
+    });
+};
+
+// Start the server with the first attempt
+startServer(1);
+
+// build the GUI
+build();
+
+app.get(["/", "/app/*", "/action/*"], (req, res) => {
+    res.send(generateDevHtml({
+        env: env,
+        api_origin: "https://api.puter.com",
+        title: "Puter",
+        max_item_name_length: 150,
+        require_email_verification_to_publish_website: false,
+        short_description: `Puter is a privacy-first personal cloud that houses all your files, apps, and games in one private and secure place, accessible from anywhere at any time.`,
+    }));
+})
+app.use(express.static('./'));
+
+if(env === "prod"){
+    // make sure to serve the ./dist/ folder maps to the root of the website
+    app.use(express.static('./dist/'));
+}
+
+if(env === "dev"){
+    app.use(express.static('./src/'));
+}
+
+module.exports = app;

+ 8 - 0
dist/browserconfig.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<browserconfig>
+<msapplication>
+<tile>
+<square70x70logo src="./favicons/ms-icon-70x70.png"/>
+<square150x150logo src="./favicons/ms-icon-150x150.png"/>
+<square310x310logo src="./favicons/ms-icon-310x310.png"/>
+<TileColor>#ffffff</TileColor></tile></msapplication></browserconfig>

File diff suppressed because it is too large
+ 6 - 0
dist/bundle.min.css


File diff suppressed because it is too large
+ 3 - 0
dist/bundle.min.js


BIN
dist/favicon.ico


BIN
dist/favicons/android-icon-144x144.png


BIN
dist/favicons/android-icon-192x192.png


BIN
dist/favicons/android-icon-36x36.png


BIN
dist/favicons/android-icon-48x48.png


BIN
dist/favicons/android-icon-72x72.png


BIN
dist/favicons/android-icon-96x96.png


BIN
dist/favicons/apple-icon-114x114.png


BIN
dist/favicons/apple-icon-120x120.png


BIN
dist/favicons/apple-icon-144x144.png


BIN
dist/favicons/apple-icon-152x152.png


BIN
dist/favicons/apple-icon-180x180.png


BIN
dist/favicons/apple-icon-57x57.png


BIN
dist/favicons/apple-icon-60x60.png


BIN
dist/favicons/apple-icon-72x72.png


BIN
dist/favicons/apple-icon-76x76.png


BIN
dist/favicons/apple-icon-precomposed.png


BIN
dist/favicons/apple-icon.png


+ 2 - 0
dist/favicons/browserconfig.xml

@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="utf-8"?>
+<browserconfig><msapplication><tile><square70x70logo src="/ms-icon-70x70.png"/><square150x150logo src="/ms-icon-150x150.png"/><square310x310logo src="/ms-icon-310x310.png"/><TileColor>#ffffff</TileColor></tile></msapplication></browserconfig>

BIN
dist/favicons/favicon-16x16.png


BIN
dist/favicons/favicon-32x32.png


BIN
dist/favicons/favicon-96x96.png


BIN
dist/favicons/favicon.ico


+ 41 - 0
dist/favicons/manifest.json

@@ -0,0 +1,41 @@
+{
+ "name": "App",
+ "icons": [
+  {
+   "src": "\/android-icon-36x36.png",
+   "sizes": "36x36",
+   "type": "image\/png",
+   "density": "0.75"
+  },
+  {
+   "src": "\/android-icon-48x48.png",
+   "sizes": "48x48",
+   "type": "image\/png",
+   "density": "1.0"
+  },
+  {
+   "src": "\/android-icon-72x72.png",
+   "sizes": "72x72",
+   "type": "image\/png",
+   "density": "1.5"
+  },
+  {
+   "src": "\/android-icon-96x96.png",
+   "sizes": "96x96",
+   "type": "image\/png",
+   "density": "2.0"
+  },
+  {
+   "src": "\/android-icon-144x144.png",
+   "sizes": "144x144",
+   "type": "image\/png",
+   "density": "3.0"
+  },
+  {
+   "src": "\/android-icon-192x192.png",
+   "sizes": "192x192",
+   "type": "image\/png",
+   "density": "4.0"
+  }
+ ]
+}

BIN
dist/favicons/ms-icon-144x144.png


BIN
dist/favicons/ms-icon-150x150.png


BIN
dist/favicons/ms-icon-310x310.png


BIN
dist/favicons/ms-icon-70x70.png


+ 127 - 0
dist/gui.js

@@ -0,0 +1,127 @@
+window.gui_env="prod"; 
+
+window.puter_gui_enabled = true;
+/**
+ * Initializes and configures the GUI (Graphical User Interface) settings based on the provided options.
+ * 
+ * The function sets global variables in the window object for various settings such as origins and domain names.
+ * It also handles loading different resources depending on the environment (development or production).
+ * 
+ * @param {Object} options - Configuration options to initialize the GUI.
+ * @param {string} [options.gui_origin='https://puter.com'] - The origin URL for the GUI.
+ * @param {string} [options.api_origin='https://api.puter.com'] - The origin URL for the API.
+ * @param {number} [options.max_item_name_length=500] - Maximum allowed length for an item name.
+ * @param {boolean} [options.require_email_verification_to_publish_website=true] - Flag to decide whether email verification is required to publish a website.
+ * 
+ * @property {string} [options.app_domain] - Extracted domain name from gui_origin. It's derived automatically if not provided.
+ * @property {string} [window.gui_env] - The environment in which the GUI is running (e.g., "dev" or "prod").
+ * 
+ * @returns {Promise<void>} Returns a promise that resolves when initialization and resource loading are complete.
+ * 
+ * @example
+ * window.gui({
+ *     gui_origin: 'https://myapp.com',
+ *     api_origin: 'https://myapi.com',
+ *     max_item_name_length: 250
+ * });
+ */
+
+window.gui = async function(options){
+    options = options ?? {};
+    // app_origin is deprecated, use gui_origin instead
+    window.gui_origin = options.gui_origin ?? options.app_origin ?? `https://puter.com`;
+    window.app_domain = options.app_domain ?? new URL(window.gui_origin).hostname;
+    window.hosting_domain = options.hosting_domain ?? 'puter.site';
+    window.api_origin = options.api_origin ?? "https://api.puter.com";
+    window.max_item_name_length = options.max_item_name_length ?? 500;
+    window.require_email_verification_to_publish_website = options.require_email_verification_to_publish_website ?? true;
+
+    // Add Puter.JS
+    await loadScript('https://js.puter.com/v2/');
+
+    // DEV: Load the initgui.js file if we are in development mode
+    if(!window.gui_env || window.gui_env === "dev"){
+        await loadScript('/initgui.js', {isModule: true});
+    }
+    
+    // PROD: load the minified bundles if we are in production mode
+    // note: the order of the bundles is important
+    // note: Build script will prepend `window.gui_env="prod"` to the top of the file
+    else if(gui_env === "prod"){
+        // Load the minified bundles
+        await loadCSS('/dist/bundle.min.css');
+        await loadScript('/dist/bundle.min.js');
+    }
+
+    // 🚀 Launch the GUI 🚀
+    initgui();
+}
+
+/**
+* Dynamically loads an external JavaScript file.
+* @param {string} url The URL of the external script to load.
+* @param {Object} [options] Optional configuration for the script. 
+* @param {boolean} [options.isModule] Whether the script is a module.
+* @param {boolean} [options.defer] Whether the script should be deferred.
+* @param {Object} [options.dataAttributes] An object containing data attributes to add to the script element.
+* @returns {Promise} A promise that resolves once the script has loaded, or rejects on error.
+*/
+window.loadScript = async function(url, options = {}) {
+    return new Promise((resolve, reject) => {
+        const script = document.createElement('script');
+        script.src = url;
+
+        // Set default script loading behavior
+        script.async = true;
+
+        // Handle if it is a module
+        if (options.isModule) {
+            script.type = 'module';
+        }
+
+        // Handle defer attribute
+        if (options.defer) {
+            script.defer = true;
+            script.async = false; // When "defer" is true, "async" should be false as they are mutually exclusive
+        }
+
+        // Add arbitrary data attributes
+        if (options.dataAttributes && typeof options.dataAttributes === 'object') {
+            for (const [key, value] of Object.entries(options.dataAttributes)) {
+                script.setAttribute(`data-${key}`, value);
+            }
+        }
+
+        // Resolve the promise when the script is loaded
+        script.onload = () => resolve();
+
+        // Reject the promise if there's an error during load
+        script.onerror = (error) => reject(new Error(`Failed to load script at url: ${url}`));
+
+        // Append the script to the body
+        document.body.appendChild(script);
+    });
+};
+
+/**
+* Dynamically loads an external CSS file.
+* @param {string} url The URL of the external CSS to load.
+* @returns {Promise} A promise that resolves once the CSS has loaded, or rejects on error.
+*/
+window.loadCSS = async function(url) {
+    return new Promise((resolve, reject) => {
+        const link = document.createElement('link');
+        link.rel = 'stylesheet';
+        link.href = url;
+
+        link.onload = () => {
+            resolve();
+        };
+
+        link.onerror = (error) => {
+            reject(new Error(`Failed to load CSS at url: ${url}`));
+        };
+
+        document.head.appendChild(link);
+    });
+}

BIN
dist/images/screenshot.png


BIN
dist/images/wallpaper.webp


+ 41 - 0
dist/manifest.json

@@ -0,0 +1,41 @@
+{
+ "name": "App",
+ "icons": [
+  {
+   "src": "/favicons/android-icon-36x36.png",
+   "sizes": "36x36",
+   "type": "image/png",
+   "density": "0.75"
+  },
+  {
+   "src": "/favicons/android-icon-48x48.png",
+   "sizes": "48x48",
+   "type": "image/png",
+   "density": "1.0"
+  },
+  {
+   "src": "/favicons/android-icon-72x72.png",
+   "sizes": "72x72",
+   "type": "image/png",
+   "density": "1.5"
+  },
+  {
+   "src": "/favicons/android-icon-96x96.png",
+   "sizes": "96x96",
+   "type": "image/png",
+   "density": "2.0"
+  },
+  {
+   "src": "/favicons/android-icon-144x144.png",
+   "sizes": "144x144",
+   "type": "image/png",
+   "density": "3.0"
+  },
+  {
+   "src": "/favicons/android-icon-192x192.png",
+   "sizes": "192x192",
+   "type": "image/png",
+   "density": "4.0"
+  }
+ ]
+}

+ 137 - 0
docs/prod.md

@@ -0,0 +1,137 @@
+# Puter in Production
+
+## Building
+    
+```bash
+npm run build
+```
+
+## Usage
+
+Will build Puter in the `dist` directory. Include the generated `./dist/gui.js` file in your HTML page and call `gui()` when the page is loaded:
+
+```html
+<script type="text/javascript" src="./dist/gui.js"></script>
+<script type="text/javascript">
+    window.addEventListener('load', function() {
+        // Initialize the GUI. All options are optional!
+        gui({
+            // The origin of the app. This is the base URL of the GUI. 
+            gui_origin: "https://puter.com",
+
+            // The origin of the API. This is the base URL of the API endpoints that the GUI will call for all its operations.
+            api_origin: "https://api.puter.com",
+
+            // The domain under which user websites are hosted.
+            hosting_domain: "puter.site",
+
+            // The maximum length of file/directory names.
+            max_item_name_length: 500,
+
+            // If GUI has to enforce email verification before allowing user to publish a website.
+            require_email_verification_to_publish_website: true,
+        })
+    });
+</script>
+```
+
+## Full Production Example
+
+Assuming the following directory structure in production:
+
+```
+.
+├── dist/
+│   ├── favicons/
+│   ├── images/
+│   ├── bundle.min.css
+│   ├── bundle.min.js
+│   ├── gui.js
+│   └── ...
+└── index.html
+```
+
+The `index.html` file below will load Puter and all the necessary meta tags, favicons, and branding assets:
+
+```html
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+    <title>Puter</title>
+    <meta name="author" content="Puter Technologies Inc.">
+    <meta name="description" content="Puter is a privacy-first personal cloud to keep all your files, apps, and games in one private and secure place, accessible from anywhere at any time.">
+    <meta name="facebook-domain-verification" content="e29w3hjbnnnypf4kzk2cewcdaxym1y" />
+    <link rel="canonical" href="https://puter.com">
+
+    <!-- Meta meta tags -->
+    <meta property="og:url" content="https://puter.com">
+    <meta property="og:type" content="website">
+    <meta property="og:title" content="Puter">
+    <meta property="og:description" content="Puter is a privacy-first personal cloud to keep all your files, apps, and games in one private and secure place, accessible from anywhere at any time.">
+    <meta property="og:image" content="./dist/images/screenshot.png">
+
+    <!-- Twitter meta tags -->
+    <meta name="twitter:card" content="summary_large_image">
+    <meta property="twitter:domain" content="puter.com">
+    <meta property="twitter:url" content="https://puter.com">
+    <meta name="twitter:title" content="Puter">
+    <meta name="twitter:description" content="Puter is a privacy-first personal cloud to keep all your files, apps, and games in one private and secure place, accessible from anywhere at any time.">
+    <meta name="twitter:image" content="./dist/images/screenshot.png">
+
+    <!-- favicons -->
+    <link rel="apple-touch-icon" sizes="57x57" href="./dist/favicons/apple-icon-57x57.png">
+    <link rel="apple-touch-icon" sizes="60x60" href="./dist/favicons/apple-icon-60x60.png">
+    <link rel="apple-touch-icon" sizes="72x72" href="./dist/favicons/apple-icon-72x72.png">
+    <link rel="apple-touch-icon" sizes="76x76" href="./dist/favicons/apple-icon-76x76.png">
+    <link rel="apple-touch-icon" sizes="114x114" href="./dist/favicons/apple-icon-114x114.png">
+    <link rel="apple-touch-icon" sizes="120x120" href="./dist/favicons/apple-icon-120x120.png">
+    <link rel="apple-touch-icon" sizes="144x144" href="./dist/favicons/apple-icon-144x144.png">
+    <link rel="apple-touch-icon" sizes="152x152" href="./dist/favicons/apple-icon-152x152.png">
+    <link rel="apple-touch-icon" sizes="180x180" href="./dist/favicons/apple-icon-180x180.png">
+    <link rel="icon" type="image/png" sizes="192x192"  href="./dist/favicons/android-icon-192x192.png">
+    <link rel="icon" type="image/png" sizes="32x32" href="./dist/favicons/favicon-32x32.png">
+    <link rel="icon" type="image/png" sizes="96x96" href="./dist/favicons/favicon-96x96.png">
+    <link rel="icon" type="image/png" sizes="16x16" href="./dist/favicons/favicon-16x16.png">
+    <link rel="manifest" href="./dist/manifest.json">
+    <meta name="msapplication-TileColor" content="#ffffff">
+    <meta name="msapplication-TileImage" content="./dist/favicons/ms-icon-144x144.png">
+    <meta name="theme-color" content="#ffffff">
+
+    <!-- Preload images when applicable -->
+    <link rel="preload" as="image" href="./dist/images/wallpaper.webp">
+</head>
+
+<body>
+    <!-- Load the GUI script -->
+    <script type="text/javascript" src="./dist/gui.js"></script>    
+    <!-- Initialize GUI when document is loaded -->
+    <script type="text/javascript">
+    window.addEventListener('load', function() {
+        gui()
+    });
+    </script>
+</body>
+
+</html>
+```
+
+### Server settings
+
+The GUI is a single page application (SPA) and as best practice any route under root (`/*`) should preferably load the `index.html` file. However, there are situations where we want to load a custom page for a specific route: for example, the `/privacy` route may need to load a page that contains your privacy policy and has nothing to do with the GUI application. In these cases it is ok to load a custom page as long as the following essential GUI routes are loaded with the GUI (i.e. `index.html` file):
+- `/app/*`
+- `/action/*`
+
+In other words, consider the routes above as "reserved" for Puter.
+
+### Best Practices
+
+- The `title` tags and meta tags (`<title></title>`, `<meta property="og:title"`, `<meta name="twitter:title"`, ...) should be dynamically set by the server. For example, if the URL is of an app (e.g. `https://puter.com/app/editor`) the `title` tags and meta tags should contain the app's title rather than the generic Puter title.
+
+- The `description` meta tags (`<meta name="description"`, `<meta property="og:description"`, `<meta name="twitter:description"`, ...) should be dynamically set by the server. For example, if the URL is of an app (e.g. `https://puter.com/app/editor`) the `description` meta tags should contain the app's description rather than the generic Puter description.
+
+- Make sure to escape any HTML code that is dynamically added to the HTML page. For example, if the app's description is `Puter is a <b>privacy-first</b> personal cloud to keep all your files, apps, and games in one private and secure place, accessible from anywhere at any time.` the `<b>` tag should be escaped to `&lt;b&gt;` so that the browser doesn't interpret it as an HTML tag.
+
+- Make sure to replace all new line characters with space when dynamically adding text to the HTML page.
+
+- Generally, for UX and SEO reasons make sure that the tags are filled with relevant information about the state the URL is representing. E.g. is the user on the desktop or an app?

+ 2510 - 0
package-lock.json

@@ -0,0 +1,2510 @@
+{
+  "name": "puter.com",
+  "version": "1.0.0",
+  "lockfileVersion": 3,
+  "requires": true,
+  "packages": {
+    "": {
+      "name": "puter.com",
+      "version": "1.0.0",
+      "license": "AGPL-3.0-only",
+      "devDependencies": {
+        "chalk": "^4.1.0",
+        "clean-css": "^5.3.2",
+        "express": "^4.18.2",
+        "html-entities": "^2.3.3",
+        "nodemon": "^2.0.22",
+        "uglify-js": "^3.17.4",
+        "webpack": "^5.88.2",
+        "webpack-cli": "^5.1.1"
+      }
+    },
+    "node_modules/@discoveryjs/json-ext": {
+      "version": "0.5.7",
+      "resolved": "https://registry.npmjs.org/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz",
+      "integrity": "sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw==",
+      "dev": true,
+      "engines": {
+        "node": ">=10.0.0"
+      }
+    },
+    "node_modules/@jridgewell/gen-mapping": {
+      "version": "0.3.5",
+      "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz",
+      "integrity": "sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg==",
+      "dev": true,
+      "dependencies": {
+        "@jridgewell/set-array": "^1.2.1",
+        "@jridgewell/sourcemap-codec": "^1.4.10",
+        "@jridgewell/trace-mapping": "^0.3.24"
+      },
+      "engines": {
+        "node": ">=6.0.0"
+      }
+    },
+    "node_modules/@jridgewell/resolve-uri": {
+      "version": "3.1.2",
+      "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz",
+      "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==",
+      "dev": true,
+      "engines": {
+        "node": ">=6.0.0"
+      }
+    },
+    "node_modules/@jridgewell/set-array": {
+      "version": "1.2.1",
+      "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.2.1.tgz",
+      "integrity": "sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==",
+      "dev": true,
+      "engines": {
+        "node": ">=6.0.0"
+      }
+    },
+    "node_modules/@jridgewell/source-map": {
+      "version": "0.3.5",
+      "resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.5.tgz",
+      "integrity": "sha512-UTYAUj/wviwdsMfzoSJspJxbkH5o1snzwX0//0ENX1u/55kkZZkcTZP6u9bwKGkv+dkk9at4m1Cpt0uY80kcpQ==",
+      "dev": true,
+      "dependencies": {
+        "@jridgewell/gen-mapping": "^0.3.0",
+        "@jridgewell/trace-mapping": "^0.3.9"
+      }
+    },
+    "node_modules/@jridgewell/sourcemap-codec": {
+      "version": "1.4.15",
+      "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz",
+      "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==",
+      "dev": true
+    },
+    "node_modules/@jridgewell/trace-mapping": {
+      "version": "0.3.25",
+      "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz",
+      "integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==",
+      "dev": true,
+      "dependencies": {
+        "@jridgewell/resolve-uri": "^3.1.0",
+        "@jridgewell/sourcemap-codec": "^1.4.14"
+      }
+    },
+    "node_modules/@types/eslint": {
+      "version": "8.56.5",
+      "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.56.5.tgz",
+      "integrity": "sha512-u5/YPJHo1tvkSF2CE0USEkxon82Z5DBy2xR+qfyYNszpX9qcs4sT6uq2kBbj4BXY1+DBGDPnrhMZV3pKWGNukw==",
+      "dev": true,
+      "dependencies": {
+        "@types/estree": "*",
+        "@types/json-schema": "*"
+      }
+    },
+    "node_modules/@types/eslint-scope": {
+      "version": "3.7.7",
+      "resolved": "https://registry.npmjs.org/@types/eslint-scope/-/eslint-scope-3.7.7.tgz",
+      "integrity": "sha512-MzMFlSLBqNF2gcHWO0G1vP/YQyfvrxZ0bF+u7mzUdZ1/xK4A4sru+nraZz5i3iEIk1l1uyicaDVTB4QbbEkAYg==",
+      "dev": true,
+      "dependencies": {
+        "@types/eslint": "*",
+        "@types/estree": "*"
+      }
+    },
+    "node_modules/@types/estree": {
+      "version": "1.0.5",
+      "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz",
+      "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==",
+      "dev": true
+    },
+    "node_modules/@types/json-schema": {
+      "version": "7.0.15",
+      "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz",
+      "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==",
+      "dev": true
+    },
+    "node_modules/@types/node": {
+      "version": "20.11.24",
+      "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.24.tgz",
+      "integrity": "sha512-Kza43ewS3xoLgCEpQrsT+xRo/EJej1y0kVYGiLFE1NEODXGzTfwiC6tXTLMQskn1X4/Rjlh0MQUvx9W+L9long==",
+      "dev": true,
+      "dependencies": {
+        "undici-types": "~5.26.4"
+      }
+    },
+    "node_modules/@webassemblyjs/ast": {
+      "version": "1.11.6",
+      "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.6.tgz",
+      "integrity": "sha512-IN1xI7PwOvLPgjcf180gC1bqn3q/QaOCwYUahIOhbYUu8KA/3tw2RT/T0Gidi1l7Hhj5D/INhJxiICObqpMu4Q==",
+      "dev": true,
+      "dependencies": {
+        "@webassemblyjs/helper-numbers": "1.11.6",
+        "@webassemblyjs/helper-wasm-bytecode": "1.11.6"
+      }
+    },
+    "node_modules/@webassemblyjs/floating-point-hex-parser": {
+      "version": "1.11.6",
+      "resolved": "https://registry.npmjs.org/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.11.6.tgz",
+      "integrity": "sha512-ejAj9hfRJ2XMsNHk/v6Fu2dGS+i4UaXBXGemOfQ/JfQ6mdQg/WXtwleQRLLS4OvfDhv8rYnVwH27YJLMyYsxhw==",
+      "dev": true
+    },
+    "node_modules/@webassemblyjs/helper-api-error": {
+      "version": "1.11.6",
+      "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-api-error/-/helper-api-error-1.11.6.tgz",
+      "integrity": "sha512-o0YkoP4pVu4rN8aTJgAyj9hC2Sv5UlkzCHhxqWj8butaLvnpdc2jOwh4ewE6CX0txSfLn/UYaV/pheS2Txg//Q==",
+      "dev": true
+    },
+    "node_modules/@webassemblyjs/helper-buffer": {
+      "version": "1.11.6",
+      "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-buffer/-/helper-buffer-1.11.6.tgz",
+      "integrity": "sha512-z3nFzdcp1mb8nEOFFk8DrYLpHvhKC3grJD2ardfKOzmbmJvEf/tPIqCY+sNcwZIY8ZD7IkB2l7/pqhUhqm7hLA==",
+      "dev": true
+    },
+    "node_modules/@webassemblyjs/helper-numbers": {
+      "version": "1.11.6",
+      "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-numbers/-/helper-numbers-1.11.6.tgz",
+      "integrity": "sha512-vUIhZ8LZoIWHBohiEObxVm6hwP034jwmc9kuq5GdHZH0wiLVLIPcMCdpJzG4C11cHoQ25TFIQj9kaVADVX7N3g==",
+      "dev": true,
+      "dependencies": {
+        "@webassemblyjs/floating-point-hex-parser": "1.11.6",
+        "@webassemblyjs/helper-api-error": "1.11.6",
+        "@xtuc/long": "4.2.2"
+      }
+    },
+    "node_modules/@webassemblyjs/helper-wasm-bytecode": {
+      "version": "1.11.6",
+      "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.11.6.tgz",
+      "integrity": "sha512-sFFHKwcmBprO9e7Icf0+gddyWYDViL8bpPjJJl0WHxCdETktXdmtWLGVzoHbqUcY4Be1LkNfwTmXOJUFZYSJdA==",
+      "dev": true
+    },
+    "node_modules/@webassemblyjs/helper-wasm-section": {
+      "version": "1.11.6",
+      "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.11.6.tgz",
+      "integrity": "sha512-LPpZbSOwTpEC2cgn4hTydySy1Ke+XEu+ETXuoyvuyezHO3Kjdu90KK95Sh9xTbmjrCsUwvWwCOQQNta37VrS9g==",
+      "dev": true,
+      "dependencies": {
+        "@webassemblyjs/ast": "1.11.6",
+        "@webassemblyjs/helper-buffer": "1.11.6",
+        "@webassemblyjs/helper-wasm-bytecode": "1.11.6",
+        "@webassemblyjs/wasm-gen": "1.11.6"
+      }
+    },
+    "node_modules/@webassemblyjs/ieee754": {
+      "version": "1.11.6",
+      "resolved": "https://registry.npmjs.org/@webassemblyjs/ieee754/-/ieee754-1.11.6.tgz",
+      "integrity": "sha512-LM4p2csPNvbij6U1f19v6WR56QZ8JcHg3QIJTlSwzFcmx6WSORicYj6I63f9yU1kEUtrpG+kjkiIAkevHpDXrg==",
+      "dev": true,
+      "dependencies": {
+        "@xtuc/ieee754": "^1.2.0"
+      }
+    },
+    "node_modules/@webassemblyjs/leb128": {
+      "version": "1.11.6",
+      "resolved": "https://registry.npmjs.org/@webassemblyjs/leb128/-/leb128-1.11.6.tgz",
+      "integrity": "sha512-m7a0FhE67DQXgouf1tbN5XQcdWoNgaAuoULHIfGFIEVKA6tu/edls6XnIlkmS6FrXAquJRPni3ZZKjw6FSPjPQ==",
+      "dev": true,
+      "dependencies": {
+        "@xtuc/long": "4.2.2"
+      }
+    },
+    "node_modules/@webassemblyjs/utf8": {
+      "version": "1.11.6",
+      "resolved": "https://registry.npmjs.org/@webassemblyjs/utf8/-/utf8-1.11.6.tgz",
+      "integrity": "sha512-vtXf2wTQ3+up9Zsg8sa2yWiQpzSsMyXj0qViVP6xKGCUT8p8YJ6HqI7l5eCnWx1T/FYdsv07HQs2wTFbbof/RA==",
+      "dev": true
+    },
+    "node_modules/@webassemblyjs/wasm-edit": {
+      "version": "1.11.6",
+      "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-edit/-/wasm-edit-1.11.6.tgz",
+      "integrity": "sha512-Ybn2I6fnfIGuCR+Faaz7YcvtBKxvoLV3Lebn1tM4o/IAJzmi9AWYIPWpyBfU8cC+JxAO57bk4+zdsTjJR+VTOw==",
+      "dev": true,
+      "dependencies": {
+        "@webassemblyjs/ast": "1.11.6",
+        "@webassemblyjs/helper-buffer": "1.11.6",
+        "@webassemblyjs/helper-wasm-bytecode": "1.11.6",
+        "@webassemblyjs/helper-wasm-section": "1.11.6",
+        "@webassemblyjs/wasm-gen": "1.11.6",
+        "@webassemblyjs/wasm-opt": "1.11.6",
+        "@webassemblyjs/wasm-parser": "1.11.6",
+        "@webassemblyjs/wast-printer": "1.11.6"
+      }
+    },
+    "node_modules/@webassemblyjs/wasm-gen": {
+      "version": "1.11.6",
+      "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-gen/-/wasm-gen-1.11.6.tgz",
+      "integrity": "sha512-3XOqkZP/y6B4F0PBAXvI1/bky7GryoogUtfwExeP/v7Nzwo1QLcq5oQmpKlftZLbT+ERUOAZVQjuNVak6UXjPA==",
+      "dev": true,
+      "dependencies": {
+        "@webassemblyjs/ast": "1.11.6",
+        "@webassemblyjs/helper-wasm-bytecode": "1.11.6",
+        "@webassemblyjs/ieee754": "1.11.6",
+        "@webassemblyjs/leb128": "1.11.6",
+        "@webassemblyjs/utf8": "1.11.6"
+      }
+    },
+    "node_modules/@webassemblyjs/wasm-opt": {
+      "version": "1.11.6",
+      "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-opt/-/wasm-opt-1.11.6.tgz",
+      "integrity": "sha512-cOrKuLRE7PCe6AsOVl7WasYf3wbSo4CeOk6PkrjS7g57MFfVUF9u6ysQBBODX0LdgSvQqRiGz3CXvIDKcPNy4g==",
+      "dev": true,
+      "dependencies": {
+        "@webassemblyjs/ast": "1.11.6",
+        "@webassemblyjs/helper-buffer": "1.11.6",
+        "@webassemblyjs/wasm-gen": "1.11.6",
+        "@webassemblyjs/wasm-parser": "1.11.6"
+      }
+    },
+    "node_modules/@webassemblyjs/wasm-parser": {
+      "version": "1.11.6",
+      "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-parser/-/wasm-parser-1.11.6.tgz",
+      "integrity": "sha512-6ZwPeGzMJM3Dqp3hCsLgESxBGtT/OeCvCZ4TA1JUPYgmhAx38tTPR9JaKy0S5H3evQpO/h2uWs2j6Yc/fjkpTQ==",
+      "dev": true,
+      "dependencies": {
+        "@webassemblyjs/ast": "1.11.6",
+        "@webassemblyjs/helper-api-error": "1.11.6",
+        "@webassemblyjs/helper-wasm-bytecode": "1.11.6",
+        "@webassemblyjs/ieee754": "1.11.6",
+        "@webassemblyjs/leb128": "1.11.6",
+        "@webassemblyjs/utf8": "1.11.6"
+      }
+    },
+    "node_modules/@webassemblyjs/wast-printer": {
+      "version": "1.11.6",
+      "resolved": "https://registry.npmjs.org/@webassemblyjs/wast-printer/-/wast-printer-1.11.6.tgz",
+      "integrity": "sha512-JM7AhRcE+yW2GWYaKeHL5vt4xqee5N2WcezptmgyhNS+ScggqcT1OtXykhAb13Sn5Yas0j2uv9tHgrjwvzAP4A==",
+      "dev": true,
+      "dependencies": {
+        "@webassemblyjs/ast": "1.11.6",
+        "@xtuc/long": "4.2.2"
+      }
+    },
+    "node_modules/@webpack-cli/configtest": {
+      "version": "2.1.1",
+      "resolved": "https://registry.npmjs.org/@webpack-cli/configtest/-/configtest-2.1.1.tgz",
+      "integrity": "sha512-wy0mglZpDSiSS0XHrVR+BAdId2+yxPSoJW8fsna3ZpYSlufjvxnP4YbKTCBZnNIcGN4r6ZPXV55X4mYExOfLmw==",
+      "dev": true,
+      "engines": {
+        "node": ">=14.15.0"
+      },
+      "peerDependencies": {
+        "webpack": "5.x.x",
+        "webpack-cli": "5.x.x"
+      }
+    },
+    "node_modules/@webpack-cli/info": {
+      "version": "2.0.2",
+      "resolved": "https://registry.npmjs.org/@webpack-cli/info/-/info-2.0.2.tgz",
+      "integrity": "sha512-zLHQdI/Qs1UyT5UBdWNqsARasIA+AaF8t+4u2aS2nEpBQh2mWIVb8qAklq0eUENnC5mOItrIB4LiS9xMtph18A==",
+      "dev": true,
+      "engines": {
+        "node": ">=14.15.0"
+      },
+      "peerDependencies": {
+        "webpack": "5.x.x",
+        "webpack-cli": "5.x.x"
+      }
+    },
+    "node_modules/@webpack-cli/serve": {
+      "version": "2.0.5",
+      "resolved": "https://registry.npmjs.org/@webpack-cli/serve/-/serve-2.0.5.tgz",
+      "integrity": "sha512-lqaoKnRYBdo1UgDX8uF24AfGMifWK19TxPmM5FHc2vAGxrJ/qtyUyFBWoY1tISZdelsQ5fBcOusifo5o5wSJxQ==",
+      "dev": true,
+      "engines": {
+        "node": ">=14.15.0"
+      },
+      "peerDependencies": {
+        "webpack": "5.x.x",
+        "webpack-cli": "5.x.x"
+      },
+      "peerDependenciesMeta": {
+        "webpack-dev-server": {
+          "optional": true
+        }
+      }
+    },
+    "node_modules/@xtuc/ieee754": {
+      "version": "1.2.0",
+      "resolved": "https://registry.npmjs.org/@xtuc/ieee754/-/ieee754-1.2.0.tgz",
+      "integrity": "sha512-DX8nKgqcGwsc0eJSqYt5lwP4DH5FlHnmuWWBRy7X0NcaGR0ZtuyeESgMwTYVEtxmsNGY+qit4QYT/MIYTOTPeA==",
+      "dev": true
+    },
+    "node_modules/@xtuc/long": {
+      "version": "4.2.2",
+      "resolved": "https://registry.npmjs.org/@xtuc/long/-/long-4.2.2.tgz",
+      "integrity": "sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==",
+      "dev": true
+    },
+    "node_modules/abbrev": {
+      "version": "1.1.1",
+      "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
+      "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
+      "dev": true
+    },
+    "node_modules/accepts": {
+      "version": "1.3.8",
+      "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
+      "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==",
+      "dev": true,
+      "dependencies": {
+        "mime-types": "~2.1.34",
+        "negotiator": "0.6.3"
+      },
+      "engines": {
+        "node": ">= 0.6"
+      }
+    },
+    "node_modules/acorn": {
+      "version": "8.11.3",
+      "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz",
+      "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==",
+      "dev": true,
+      "bin": {
+        "acorn": "bin/acorn"
+      },
+      "engines": {
+        "node": ">=0.4.0"
+      }
+    },
+    "node_modules/acorn-import-assertions": {
+      "version": "1.9.0",
+      "resolved": "https://registry.npmjs.org/acorn-import-assertions/-/acorn-import-assertions-1.9.0.tgz",
+      "integrity": "sha512-cmMwop9x+8KFhxvKrKfPYmN6/pKTYYHBqLa0DfvVZcKMJWNyWLnaqND7dx/qn66R7ewM1UX5XMaDVP5wlVTaVA==",
+      "dev": true,
+      "peerDependencies": {
+        "acorn": "^8"
+      }
+    },
+    "node_modules/ajv": {
+      "version": "6.12.6",
+      "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
+      "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==",
+      "dev": true,
+      "dependencies": {
+        "fast-deep-equal": "^3.1.1",
+        "fast-json-stable-stringify": "^2.0.0",
+        "json-schema-traverse": "^0.4.1",
+        "uri-js": "^4.2.2"
+      },
+      "funding": {
+        "type": "github",
+        "url": "https://github.com/sponsors/epoberezkin"
+      }
+    },
+    "node_modules/ajv-keywords": {
+      "version": "3.5.2",
+      "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz",
+      "integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==",
+      "dev": true,
+      "peerDependencies": {
+        "ajv": "^6.9.1"
+      }
+    },
+    "node_modules/ansi-styles": {
+      "version": "4.3.0",
+      "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
+      "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
+      "dev": true,
+      "dependencies": {
+        "color-convert": "^2.0.1"
+      },
+      "engines": {
+        "node": ">=8"
+      },
+      "funding": {
+        "url": "https://github.com/chalk/ansi-styles?sponsor=1"
+      }
+    },
+    "node_modules/anymatch": {
+      "version": "3.1.3",
+      "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz",
+      "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==",
+      "dev": true,
+      "dependencies": {
+        "normalize-path": "^3.0.0",
+        "picomatch": "^2.0.4"
+      },
+      "engines": {
+        "node": ">= 8"
+      }
+    },
+    "node_modules/array-flatten": {
+      "version": "1.1.1",
+      "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
+      "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==",
+      "dev": true
+    },
+    "node_modules/balanced-match": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
+      "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
+      "dev": true
+    },
+    "node_modules/binary-extensions": {
+      "version": "2.2.0",
+      "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz",
+      "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==",
+      "dev": true,
+      "engines": {
+        "node": ">=8"
+      }
+    },
+    "node_modules/body-parser": {
+      "version": "1.20.2",
+      "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz",
+      "integrity": "sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==",
+      "dev": true,
+      "dependencies": {
+        "bytes": "3.1.2",
+        "content-type": "~1.0.5",
+        "debug": "2.6.9",
+        "depd": "2.0.0",
+        "destroy": "1.2.0",
+        "http-errors": "2.0.0",
+        "iconv-lite": "0.4.24",
+        "on-finished": "2.4.1",
+        "qs": "6.11.0",
+        "raw-body": "2.5.2",
+        "type-is": "~1.6.18",
+        "unpipe": "1.0.0"
+      },
+      "engines": {
+        "node": ">= 0.8",
+        "npm": "1.2.8000 || >= 1.4.16"
+      }
+    },
+    "node_modules/brace-expansion": {
+      "version": "1.1.11",
+      "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
+      "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
+      "dev": true,
+      "dependencies": {
+        "balanced-match": "^1.0.0",
+        "concat-map": "0.0.1"
+      }
+    },
+    "node_modules/braces": {
+      "version": "3.0.2",
+      "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz",
+      "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==",
+      "dev": true,
+      "dependencies": {
+        "fill-range": "^7.0.1"
+      },
+      "engines": {
+        "node": ">=8"
+      }
+    },
+    "node_modules/browserslist": {
+      "version": "4.23.0",
+      "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.23.0.tgz",
+      "integrity": "sha512-QW8HiM1shhT2GuzkvklfjcKDiWFXHOeFCIA/huJPwHsslwcydgk7X+z2zXpEijP98UCY7HbubZt5J2Zgvf0CaQ==",
+      "dev": true,
+      "funding": [
+        {
+          "type": "opencollective",
+          "url": "https://opencollective.com/browserslist"
+        },
+        {
+          "type": "tidelift",
+          "url": "https://tidelift.com/funding/github/npm/browserslist"
+        },
+        {
+          "type": "github",
+          "url": "https://github.com/sponsors/ai"
+        }
+      ],
+      "dependencies": {
+        "caniuse-lite": "^1.0.30001587",
+        "electron-to-chromium": "^1.4.668",
+        "node-releases": "^2.0.14",
+        "update-browserslist-db": "^1.0.13"
+      },
+      "bin": {
+        "browserslist": "cli.js"
+      },
+      "engines": {
+        "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7"
+      }
+    },
+    "node_modules/buffer-from": {
+      "version": "1.1.2",
+      "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
+      "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==",
+      "dev": true
+    },
+    "node_modules/bytes": {
+      "version": "3.1.2",
+      "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
+      "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==",
+      "dev": true,
+      "engines": {
+        "node": ">= 0.8"
+      }
+    },
+    "node_modules/call-bind": {
+      "version": "1.0.7",
+      "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz",
+      "integrity": "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==",
+      "dev": true,
+      "dependencies": {
+        "es-define-property": "^1.0.0",
+        "es-errors": "^1.3.0",
+        "function-bind": "^1.1.2",
+        "get-intrinsic": "^1.2.4",
+        "set-function-length": "^1.2.1"
+      },
+      "engines": {
+        "node": ">= 0.4"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/ljharb"
+      }
+    },
+    "node_modules/caniuse-lite": {
+      "version": "1.0.30001591",
+      "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001591.tgz",
+      "integrity": "sha512-PCzRMei/vXjJyL5mJtzNiUCKP59dm8Apqc3PH8gJkMnMXZGox93RbE76jHsmLwmIo6/3nsYIpJtx0O7u5PqFuQ==",
+      "dev": true,
+      "funding": [
+        {
+          "type": "opencollective",
+          "url": "https://opencollective.com/browserslist"
+        },
+        {
+          "type": "tidelift",
+          "url": "https://tidelift.com/funding/github/npm/caniuse-lite"
+        },
+        {
+          "type": "github",
+          "url": "https://github.com/sponsors/ai"
+        }
+      ]
+    },
+    "node_modules/chalk": {
+      "version": "4.1.2",
+      "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
+      "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
+      "dev": true,
+      "dependencies": {
+        "ansi-styles": "^4.1.0",
+        "supports-color": "^7.1.0"
+      },
+      "engines": {
+        "node": ">=10"
+      },
+      "funding": {
+        "url": "https://github.com/chalk/chalk?sponsor=1"
+      }
+    },
+    "node_modules/chokidar": {
+      "version": "3.6.0",
+      "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz",
+      "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==",
+      "dev": true,
+      "dependencies": {
+        "anymatch": "~3.1.2",
+        "braces": "~3.0.2",
+        "glob-parent": "~5.1.2",
+        "is-binary-path": "~2.1.0",
+        "is-glob": "~4.0.1",
+        "normalize-path": "~3.0.0",
+        "readdirp": "~3.6.0"
+      },
+      "engines": {
+        "node": ">= 8.10.0"
+      },
+      "funding": {
+        "url": "https://paulmillr.com/funding/"
+      },
+      "optionalDependencies": {
+        "fsevents": "~2.3.2"
+      }
+    },
+    "node_modules/chrome-trace-event": {
+      "version": "1.0.3",
+      "resolved": "https://registry.npmjs.org/chrome-trace-event/-/chrome-trace-event-1.0.3.tgz",
+      "integrity": "sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg==",
+      "dev": true,
+      "engines": {
+        "node": ">=6.0"
+      }
+    },
+    "node_modules/clean-css": {
+      "version": "5.3.3",
+      "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-5.3.3.tgz",
+      "integrity": "sha512-D5J+kHaVb/wKSFcyyV75uCn8fiY4sV38XJoe4CUyGQ+mOU/fMVYUdH1hJC+CJQ5uY3EnW27SbJYS4X8BiLrAFg==",
+      "dev": true,
+      "dependencies": {
+        "source-map": "~0.6.0"
+      },
+      "engines": {
+        "node": ">= 10.0"
+      }
+    },
+    "node_modules/clone-deep": {
+      "version": "4.0.1",
+      "resolved": "https://registry.npmjs.org/clone-deep/-/clone-deep-4.0.1.tgz",
+      "integrity": "sha512-neHB9xuzh/wk0dIHweyAXv2aPGZIVk3pLMe+/RNzINf17fe0OG96QroktYAUm7SM1PBnzTabaLboqqxDyMU+SQ==",
+      "dev": true,
+      "dependencies": {
+        "is-plain-object": "^2.0.4",
+        "kind-of": "^6.0.2",
+        "shallow-clone": "^3.0.0"
+      },
+      "engines": {
+        "node": ">=6"
+      }
+    },
+    "node_modules/color-convert": {
+      "version": "2.0.1",
+      "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
+      "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
+      "dev": true,
+      "dependencies": {
+        "color-name": "~1.1.4"
+      },
+      "engines": {
+        "node": ">=7.0.0"
+      }
+    },
+    "node_modules/color-name": {
+      "version": "1.1.4",
+      "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
+      "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
+      "dev": true
+    },
+    "node_modules/colorette": {
+      "version": "2.0.20",
+      "resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.20.tgz",
+      "integrity": "sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==",
+      "dev": true
+    },
+    "node_modules/commander": {
+      "version": "2.20.3",
+      "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz",
+      "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==",
+      "dev": true
+    },
+    "node_modules/concat-map": {
+      "version": "0.0.1",
+      "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
+      "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
+      "dev": true
+    },
+    "node_modules/content-disposition": {
+      "version": "0.5.4",
+      "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
+      "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==",
+      "dev": true,
+      "dependencies": {
+        "safe-buffer": "5.2.1"
+      },
+      "engines": {
+        "node": ">= 0.6"
+      }
+    },
+    "node_modules/content-type": {
+      "version": "1.0.5",
+      "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz",
+      "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==",
+      "dev": true,
+      "engines": {
+        "node": ">= 0.6"
+      }
+    },
+    "node_modules/cookie": {
+      "version": "0.5.0",
+      "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz",
+      "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==",
+      "dev": true,
+      "engines": {
+        "node": ">= 0.6"
+      }
+    },
+    "node_modules/cookie-signature": {
+      "version": "1.0.6",
+      "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
+      "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==",
+      "dev": true
+    },
+    "node_modules/cross-spawn": {
+      "version": "7.0.3",
+      "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
+      "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==",
+      "dev": true,
+      "dependencies": {
+        "path-key": "^3.1.0",
+        "shebang-command": "^2.0.0",
+        "which": "^2.0.1"
+      },
+      "engines": {
+        "node": ">= 8"
+      }
+    },
+    "node_modules/debug": {
+      "version": "2.6.9",
+      "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
+      "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
+      "dev": true,
+      "dependencies": {
+        "ms": "2.0.0"
+      }
+    },
+    "node_modules/define-data-property": {
+      "version": "1.1.4",
+      "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz",
+      "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==",
+      "dev": true,
+      "dependencies": {
+        "es-define-property": "^1.0.0",
+        "es-errors": "^1.3.0",
+        "gopd": "^1.0.1"
+      },
+      "engines": {
+        "node": ">= 0.4"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/ljharb"
+      }
+    },
+    "node_modules/depd": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
+      "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==",
+      "dev": true,
+      "engines": {
+        "node": ">= 0.8"
+      }
+    },
+    "node_modules/destroy": {
+      "version": "1.2.0",
+      "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz",
+      "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==",
+      "dev": true,
+      "engines": {
+        "node": ">= 0.8",
+        "npm": "1.2.8000 || >= 1.4.16"
+      }
+    },
+    "node_modules/ee-first": {
+      "version": "1.1.1",
+      "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
+      "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==",
+      "dev": true
+    },
+    "node_modules/electron-to-chromium": {
+      "version": "1.4.690",
+      "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.690.tgz",
+      "integrity": "sha512-+2OAGjUx68xElQhydpcbqH50hE8Vs2K6TkAeLhICYfndb67CVH0UsZaijmRUE3rHlIxU1u0jxwhgVe6fK3YANA==",
+      "dev": true
+    },
+    "node_modules/encodeurl": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
+      "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==",
+      "dev": true,
+      "engines": {
+        "node": ">= 0.8"
+      }
+    },
+    "node_modules/enhanced-resolve": {
+      "version": "5.15.1",
+      "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.15.1.tgz",
+      "integrity": "sha512-3d3JRbwsCLJsYgvb6NuWEG44jjPSOMuS73L/6+7BZuoKm3W+qXnSoIYVHi8dG7Qcg4inAY4jbzkZ7MnskePeDg==",
+      "dev": true,
+      "dependencies": {
+        "graceful-fs": "^4.2.4",
+        "tapable": "^2.2.0"
+      },
+      "engines": {
+        "node": ">=10.13.0"
+      }
+    },
+    "node_modules/envinfo": {
+      "version": "7.11.1",
+      "resolved": "https://registry.npmjs.org/envinfo/-/envinfo-7.11.1.tgz",
+      "integrity": "sha512-8PiZgZNIB4q/Lw4AhOvAfB/ityHAd2bli3lESSWmWSzSsl5dKpy5N1d1Rfkd2teq/g9xN90lc6o98DOjMeYHpg==",
+      "dev": true,
+      "bin": {
+        "envinfo": "dist/cli.js"
+      },
+      "engines": {
+        "node": ">=4"
+      }
+    },
+    "node_modules/es-define-property": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz",
+      "integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==",
+      "dev": true,
+      "dependencies": {
+        "get-intrinsic": "^1.2.4"
+      },
+      "engines": {
+        "node": ">= 0.4"
+      }
+    },
+    "node_modules/es-errors": {
+      "version": "1.3.0",
+      "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
+      "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
+      "dev": true,
+      "engines": {
+        "node": ">= 0.4"
+      }
+    },
+    "node_modules/es-module-lexer": {
+      "version": "1.4.1",
+      "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.4.1.tgz",
+      "integrity": "sha512-cXLGjP0c4T3flZJKQSuziYoq7MlT+rnvfZjfp7h+I7K9BNX54kP9nyWvdbwjQ4u1iWbOL4u96fgeZLToQlZC7w==",
+      "dev": true
+    },
+    "node_modules/escalade": {
+      "version": "3.1.2",
+      "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.2.tgz",
+      "integrity": "sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==",
+      "dev": true,
+      "engines": {
+        "node": ">=6"
+      }
+    },
+    "node_modules/escape-html": {
+      "version": "1.0.3",
+      "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
+      "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==",
+      "dev": true
+    },
+    "node_modules/eslint-scope": {
+      "version": "5.1.1",
+      "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz",
+      "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==",
+      "dev": true,
+      "dependencies": {
+        "esrecurse": "^4.3.0",
+        "estraverse": "^4.1.1"
+      },
+      "engines": {
+        "node": ">=8.0.0"
+      }
+    },
+    "node_modules/esrecurse": {
+      "version": "4.3.0",
+      "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz",
+      "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==",
+      "dev": true,
+      "dependencies": {
+        "estraverse": "^5.2.0"
+      },
+      "engines": {
+        "node": ">=4.0"
+      }
+    },
+    "node_modules/esrecurse/node_modules/estraverse": {
+      "version": "5.3.0",
+      "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz",
+      "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==",
+      "dev": true,
+      "engines": {
+        "node": ">=4.0"
+      }
+    },
+    "node_modules/estraverse": {
+      "version": "4.3.0",
+      "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz",
+      "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==",
+      "dev": true,
+      "engines": {
+        "node": ">=4.0"
+      }
+    },
+    "node_modules/etag": {
+      "version": "1.8.1",
+      "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
+      "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==",
+      "dev": true,
+      "engines": {
+        "node": ">= 0.6"
+      }
+    },
+    "node_modules/events": {
+      "version": "3.3.0",
+      "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz",
+      "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.8.x"
+      }
+    },
+    "node_modules/express": {
+      "version": "4.18.3",
+      "resolved": "https://registry.npmjs.org/express/-/express-4.18.3.tgz",
+      "integrity": "sha512-6VyCijWQ+9O7WuVMTRBTl+cjNNIzD5cY5mQ1WM8r/LEkI2u8EYpOotESNwzNlyCn3g+dmjKYI6BmNneSr/FSRw==",
+      "dev": true,
+      "dependencies": {
+        "accepts": "~1.3.8",
+        "array-flatten": "1.1.1",
+        "body-parser": "1.20.2",
+        "content-disposition": "0.5.4",
+        "content-type": "~1.0.4",
+        "cookie": "0.5.0",
+        "cookie-signature": "1.0.6",
+        "debug": "2.6.9",
+        "depd": "2.0.0",
+        "encodeurl": "~1.0.2",
+        "escape-html": "~1.0.3",
+        "etag": "~1.8.1",
+        "finalhandler": "1.2.0",
+        "fresh": "0.5.2",
+        "http-errors": "2.0.0",
+        "merge-descriptors": "1.0.1",
+        "methods": "~1.1.2",
+        "on-finished": "2.4.1",
+        "parseurl": "~1.3.3",
+        "path-to-regexp": "0.1.7",
+        "proxy-addr": "~2.0.7",
+        "qs": "6.11.0",
+        "range-parser": "~1.2.1",
+        "safe-buffer": "5.2.1",
+        "send": "0.18.0",
+        "serve-static": "1.15.0",
+        "setprototypeof": "1.2.0",
+        "statuses": "2.0.1",
+        "type-is": "~1.6.18",
+        "utils-merge": "1.0.1",
+        "vary": "~1.1.2"
+      },
+      "engines": {
+        "node": ">= 0.10.0"
+      }
+    },
+    "node_modules/fast-deep-equal": {
+      "version": "3.1.3",
+      "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
+      "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
+      "dev": true
+    },
+    "node_modules/fast-json-stable-stringify": {
+      "version": "2.1.0",
+      "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz",
+      "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==",
+      "dev": true
+    },
+    "node_modules/fastest-levenshtein": {
+      "version": "1.0.16",
+      "resolved": "https://registry.npmjs.org/fastest-levenshtein/-/fastest-levenshtein-1.0.16.tgz",
+      "integrity": "sha512-eRnCtTTtGZFpQCwhJiUOuxPQWRXVKYDn0b2PeHfXL6/Zi53SLAzAHfVhVWK2AryC/WH05kGfxhFIPvTF0SXQzg==",
+      "dev": true,
+      "engines": {
+        "node": ">= 4.9.1"
+      }
+    },
+    "node_modules/fill-range": {
+      "version": "7.0.1",
+      "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
+      "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==",
+      "dev": true,
+      "dependencies": {
+        "to-regex-range": "^5.0.1"
+      },
+      "engines": {
+        "node": ">=8"
+      }
+    },
+    "node_modules/finalhandler": {
+      "version": "1.2.0",
+      "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz",
+      "integrity": "sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==",
+      "dev": true,
+      "dependencies": {
+        "debug": "2.6.9",
+        "encodeurl": "~1.0.2",
+        "escape-html": "~1.0.3",
+        "on-finished": "2.4.1",
+        "parseurl": "~1.3.3",
+        "statuses": "2.0.1",
+        "unpipe": "~1.0.0"
+      },
+      "engines": {
+        "node": ">= 0.8"
+      }
+    },
+    "node_modules/find-up": {
+      "version": "4.1.0",
+      "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz",
+      "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==",
+      "dev": true,
+      "dependencies": {
+        "locate-path": "^5.0.0",
+        "path-exists": "^4.0.0"
+      },
+      "engines": {
+        "node": ">=8"
+      }
+    },
+    "node_modules/flat": {
+      "version": "5.0.2",
+      "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz",
+      "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==",
+      "dev": true,
+      "bin": {
+        "flat": "cli.js"
+      }
+    },
+    "node_modules/forwarded": {
+      "version": "0.2.0",
+      "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
+      "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==",
+      "dev": true,
+      "engines": {
+        "node": ">= 0.6"
+      }
+    },
+    "node_modules/fresh": {
+      "version": "0.5.2",
+      "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
+      "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==",
+      "dev": true,
+      "engines": {
+        "node": ">= 0.6"
+      }
+    },
+    "node_modules/fsevents": {
+      "version": "2.3.3",
+      "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
+      "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
+      "dev": true,
+      "hasInstallScript": true,
+      "optional": true,
+      "os": [
+        "darwin"
+      ],
+      "engines": {
+        "node": "^8.16.0 || ^10.6.0 || >=11.0.0"
+      }
+    },
+    "node_modules/function-bind": {
+      "version": "1.1.2",
+      "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
+      "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
+      "dev": true,
+      "funding": {
+        "url": "https://github.com/sponsors/ljharb"
+      }
+    },
+    "node_modules/get-intrinsic": {
+      "version": "1.2.4",
+      "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz",
+      "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==",
+      "dev": true,
+      "dependencies": {
+        "es-errors": "^1.3.0",
+        "function-bind": "^1.1.2",
+        "has-proto": "^1.0.1",
+        "has-symbols": "^1.0.3",
+        "hasown": "^2.0.0"
+      },
+      "engines": {
+        "node": ">= 0.4"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/ljharb"
+      }
+    },
+    "node_modules/glob-parent": {
+      "version": "5.1.2",
+      "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz",
+      "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==",
+      "dev": true,
+      "dependencies": {
+        "is-glob": "^4.0.1"
+      },
+      "engines": {
+        "node": ">= 6"
+      }
+    },
+    "node_modules/glob-to-regexp": {
+      "version": "0.4.1",
+      "resolved": "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz",
+      "integrity": "sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==",
+      "dev": true
+    },
+    "node_modules/gopd": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz",
+      "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==",
+      "dev": true,
+      "dependencies": {
+        "get-intrinsic": "^1.1.3"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/ljharb"
+      }
+    },
+    "node_modules/graceful-fs": {
+      "version": "4.2.11",
+      "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
+      "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==",
+      "dev": true
+    },
+    "node_modules/has-flag": {
+      "version": "4.0.0",
+      "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
+      "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
+      "dev": true,
+      "engines": {
+        "node": ">=8"
+      }
+    },
+    "node_modules/has-property-descriptors": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz",
+      "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==",
+      "dev": true,
+      "dependencies": {
+        "es-define-property": "^1.0.0"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/ljharb"
+      }
+    },
+    "node_modules/has-proto": {
+      "version": "1.0.3",
+      "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.3.tgz",
+      "integrity": "sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==",
+      "dev": true,
+      "engines": {
+        "node": ">= 0.4"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/ljharb"
+      }
+    },
+    "node_modules/has-symbols": {
+      "version": "1.0.3",
+      "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz",
+      "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==",
+      "dev": true,
+      "engines": {
+        "node": ">= 0.4"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/ljharb"
+      }
+    },
+    "node_modules/hasown": {
+      "version": "2.0.1",
+      "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.1.tgz",
+      "integrity": "sha512-1/th4MHjnwncwXsIW6QMzlvYL9kG5e/CpVvLRZe4XPa8TOUNbCELqmvhDmnkNsAjwaG4+I8gJJL0JBvTTLO9qA==",
+      "dev": true,
+      "dependencies": {
+        "function-bind": "^1.1.2"
+      },
+      "engines": {
+        "node": ">= 0.4"
+      }
+    },
+    "node_modules/html-entities": {
+      "version": "2.4.0",
+      "resolved": "https://registry.npmjs.org/html-entities/-/html-entities-2.4.0.tgz",
+      "integrity": "sha512-igBTJcNNNhvZFRtm8uA6xMY6xYleeDwn3PeBCkDz7tHttv4F2hsDI2aPgNERWzvRcNYHNT3ymRaQzllmXj4YsQ==",
+      "dev": true,
+      "funding": [
+        {
+          "type": "github",
+          "url": "https://github.com/sponsors/mdevils"
+        },
+        {
+          "type": "patreon",
+          "url": "https://patreon.com/mdevils"
+        }
+      ]
+    },
+    "node_modules/http-errors": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz",
+      "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==",
+      "dev": true,
+      "dependencies": {
+        "depd": "2.0.0",
+        "inherits": "2.0.4",
+        "setprototypeof": "1.2.0",
+        "statuses": "2.0.1",
+        "toidentifier": "1.0.1"
+      },
+      "engines": {
+        "node": ">= 0.8"
+      }
+    },
+    "node_modules/iconv-lite": {
+      "version": "0.4.24",
+      "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
+      "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
+      "dev": true,
+      "dependencies": {
+        "safer-buffer": ">= 2.1.2 < 3"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/ignore-by-default": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz",
+      "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==",
+      "dev": true
+    },
+    "node_modules/import-local": {
+      "version": "3.1.0",
+      "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.1.0.tgz",
+      "integrity": "sha512-ASB07uLtnDs1o6EHjKpX34BKYDSqnFerfTOJL2HvMqF70LnxpjkzDB8J44oT9pu4AMPkQwf8jl6szgvNd2tRIg==",
+      "dev": true,
+      "dependencies": {
+        "pkg-dir": "^4.2.0",
+        "resolve-cwd": "^3.0.0"
+      },
+      "bin": {
+        "import-local-fixture": "fixtures/cli.js"
+      },
+      "engines": {
+        "node": ">=8"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/sindresorhus"
+      }
+    },
+    "node_modules/inherits": {
+      "version": "2.0.4",
+      "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
+      "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
+      "dev": true
+    },
+    "node_modules/interpret": {
+      "version": "3.1.1",
+      "resolved": "https://registry.npmjs.org/interpret/-/interpret-3.1.1.tgz",
+      "integrity": "sha512-6xwYfHbajpoF0xLW+iwLkhwgvLoZDfjYfoFNu8ftMoXINzwuymNLd9u/KmwtdT2GbR+/Cz66otEGEVVUHX9QLQ==",
+      "dev": true,
+      "engines": {
+        "node": ">=10.13.0"
+      }
+    },
+    "node_modules/ipaddr.js": {
+      "version": "1.9.1",
+      "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
+      "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==",
+      "dev": true,
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/is-binary-path": {
+      "version": "2.1.0",
+      "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz",
+      "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==",
+      "dev": true,
+      "dependencies": {
+        "binary-extensions": "^2.0.0"
+      },
+      "engines": {
+        "node": ">=8"
+      }
+    },
+    "node_modules/is-core-module": {
+      "version": "2.13.1",
+      "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.13.1.tgz",
+      "integrity": "sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw==",
+      "dev": true,
+      "dependencies": {
+        "hasown": "^2.0.0"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/ljharb"
+      }
+    },
+    "node_modules/is-extglob": {
+      "version": "2.1.1",
+      "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
+      "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/is-glob": {
+      "version": "4.0.3",
+      "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz",
+      "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==",
+      "dev": true,
+      "dependencies": {
+        "is-extglob": "^2.1.1"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/is-number": {
+      "version": "7.0.0",
+      "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
+      "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.12.0"
+      }
+    },
+    "node_modules/is-plain-object": {
+      "version": "2.0.4",
+      "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
+      "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
+      "dev": true,
+      "dependencies": {
+        "isobject": "^3.0.1"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/isexe": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
+      "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==",
+      "dev": true
+    },
+    "node_modules/isobject": {
+      "version": "3.0.1",
+      "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz",
+      "integrity": "sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/jest-worker": {
+      "version": "27.5.1",
+      "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-27.5.1.tgz",
+      "integrity": "sha512-7vuh85V5cdDofPyxn58nrPjBktZo0u9x1g8WtjQol+jZDaE+fhN+cIvTj11GndBnMnyfrUOG1sZQxCdjKh+DKg==",
+      "dev": true,
+      "dependencies": {
+        "@types/node": "*",
+        "merge-stream": "^2.0.0",
+        "supports-color": "^8.0.0"
+      },
+      "engines": {
+        "node": ">= 10.13.0"
+      }
+    },
+    "node_modules/jest-worker/node_modules/supports-color": {
+      "version": "8.1.1",
+      "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz",
+      "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==",
+      "dev": true,
+      "dependencies": {
+        "has-flag": "^4.0.0"
+      },
+      "engines": {
+        "node": ">=10"
+      },
+      "funding": {
+        "url": "https://github.com/chalk/supports-color?sponsor=1"
+      }
+    },
+    "node_modules/json-parse-even-better-errors": {
+      "version": "2.3.1",
+      "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz",
+      "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==",
+      "dev": true
+    },
+    "node_modules/json-schema-traverse": {
+      "version": "0.4.1",
+      "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
+      "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==",
+      "dev": true
+    },
+    "node_modules/kind-of": {
+      "version": "6.0.3",
+      "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz",
+      "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/loader-runner": {
+      "version": "4.3.0",
+      "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-4.3.0.tgz",
+      "integrity": "sha512-3R/1M+yS3j5ou80Me59j7F9IMs4PXs3VqRrm0TU3AbKPxlmpoY1TNscJV/oGJXo8qCatFGTfDbY6W6ipGOYXfg==",
+      "dev": true,
+      "engines": {
+        "node": ">=6.11.5"
+      }
+    },
+    "node_modules/locate-path": {
+      "version": "5.0.0",
+      "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz",
+      "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==",
+      "dev": true,
+      "dependencies": {
+        "p-locate": "^4.1.0"
+      },
+      "engines": {
+        "node": ">=8"
+      }
+    },
+    "node_modules/media-typer": {
+      "version": "0.3.0",
+      "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
+      "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==",
+      "dev": true,
+      "engines": {
+        "node": ">= 0.6"
+      }
+    },
+    "node_modules/merge-descriptors": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz",
+      "integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==",
+      "dev": true
+    },
+    "node_modules/merge-stream": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz",
+      "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==",
+      "dev": true
+    },
+    "node_modules/methods": {
+      "version": "1.1.2",
+      "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
+      "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==",
+      "dev": true,
+      "engines": {
+        "node": ">= 0.6"
+      }
+    },
+    "node_modules/mime": {
+      "version": "1.6.0",
+      "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
+      "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
+      "dev": true,
+      "bin": {
+        "mime": "cli.js"
+      },
+      "engines": {
+        "node": ">=4"
+      }
+    },
+    "node_modules/mime-db": {
+      "version": "1.52.0",
+      "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
+      "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
+      "dev": true,
+      "engines": {
+        "node": ">= 0.6"
+      }
+    },
+    "node_modules/mime-types": {
+      "version": "2.1.35",
+      "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
+      "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
+      "dev": true,
+      "dependencies": {
+        "mime-db": "1.52.0"
+      },
+      "engines": {
+        "node": ">= 0.6"
+      }
+    },
+    "node_modules/minimatch": {
+      "version": "3.1.2",
+      "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
+      "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
+      "dev": true,
+      "dependencies": {
+        "brace-expansion": "^1.1.7"
+      },
+      "engines": {
+        "node": "*"
+      }
+    },
+    "node_modules/ms": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
+      "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
+      "dev": true
+    },
+    "node_modules/negotiator": {
+      "version": "0.6.3",
+      "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz",
+      "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==",
+      "dev": true,
+      "engines": {
+        "node": ">= 0.6"
+      }
+    },
+    "node_modules/neo-async": {
+      "version": "2.6.2",
+      "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz",
+      "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==",
+      "dev": true
+    },
+    "node_modules/node-releases": {
+      "version": "2.0.14",
+      "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.14.tgz",
+      "integrity": "sha512-y10wOWt8yZpqXmOgRo77WaHEmhYQYGNA6y421PKsKYWEK8aW+cqAphborZDhqfyKrbZEN92CN1X2KbafY2s7Yw==",
+      "dev": true
+    },
+    "node_modules/nodemon": {
+      "version": "2.0.22",
+      "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.22.tgz",
+      "integrity": "sha512-B8YqaKMmyuCO7BowF1Z1/mkPqLk6cs/l63Ojtd6otKjMx47Dq1utxfRxcavH1I7VSaL8n5BUaoutadnsX3AAVQ==",
+      "dev": true,
+      "dependencies": {
+        "chokidar": "^3.5.2",
+        "debug": "^3.2.7",
+        "ignore-by-default": "^1.0.1",
+        "minimatch": "^3.1.2",
+        "pstree.remy": "^1.1.8",
+        "semver": "^5.7.1",
+        "simple-update-notifier": "^1.0.7",
+        "supports-color": "^5.5.0",
+        "touch": "^3.1.0",
+        "undefsafe": "^2.0.5"
+      },
+      "bin": {
+        "nodemon": "bin/nodemon.js"
+      },
+      "engines": {
+        "node": ">=8.10.0"
+      },
+      "funding": {
+        "type": "opencollective",
+        "url": "https://opencollective.com/nodemon"
+      }
+    },
+    "node_modules/nodemon/node_modules/debug": {
+      "version": "3.2.7",
+      "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz",
+      "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==",
+      "dev": true,
+      "dependencies": {
+        "ms": "^2.1.1"
+      }
+    },
+    "node_modules/nodemon/node_modules/has-flag": {
+      "version": "3.0.0",
+      "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
+      "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==",
+      "dev": true,
+      "engines": {
+        "node": ">=4"
+      }
+    },
+    "node_modules/nodemon/node_modules/ms": {
+      "version": "2.1.3",
+      "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
+      "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
+      "dev": true
+    },
+    "node_modules/nodemon/node_modules/supports-color": {
+      "version": "5.5.0",
+      "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
+      "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
+      "dev": true,
+      "dependencies": {
+        "has-flag": "^3.0.0"
+      },
+      "engines": {
+        "node": ">=4"
+      }
+    },
+    "node_modules/nopt": {
+      "version": "1.0.10",
+      "resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz",
+      "integrity": "sha512-NWmpvLSqUrgrAC9HCuxEvb+PSloHpqVu+FqcO4eeF2h5qYRhA7ev6KvelyQAKtegUbC6RypJnlEOhd8vloNKYg==",
+      "dev": true,
+      "dependencies": {
+        "abbrev": "1"
+      },
+      "bin": {
+        "nopt": "bin/nopt.js"
+      },
+      "engines": {
+        "node": "*"
+      }
+    },
+    "node_modules/normalize-path": {
+      "version": "3.0.0",
+      "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
+      "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/object-inspect": {
+      "version": "1.13.1",
+      "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.1.tgz",
+      "integrity": "sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ==",
+      "dev": true,
+      "funding": {
+        "url": "https://github.com/sponsors/ljharb"
+      }
+    },
+    "node_modules/on-finished": {
+      "version": "2.4.1",
+      "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz",
+      "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==",
+      "dev": true,
+      "dependencies": {
+        "ee-first": "1.1.1"
+      },
+      "engines": {
+        "node": ">= 0.8"
+      }
+    },
+    "node_modules/p-limit": {
+      "version": "2.3.0",
+      "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz",
+      "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==",
+      "dev": true,
+      "dependencies": {
+        "p-try": "^2.0.0"
+      },
+      "engines": {
+        "node": ">=6"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/sindresorhus"
+      }
+    },
+    "node_modules/p-locate": {
+      "version": "4.1.0",
+      "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz",
+      "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==",
+      "dev": true,
+      "dependencies": {
+        "p-limit": "^2.2.0"
+      },
+      "engines": {
+        "node": ">=8"
+      }
+    },
+    "node_modules/p-try": {
+      "version": "2.2.0",
+      "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz",
+      "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==",
+      "dev": true,
+      "engines": {
+        "node": ">=6"
+      }
+    },
+    "node_modules/parseurl": {
+      "version": "1.3.3",
+      "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
+      "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==",
+      "dev": true,
+      "engines": {
+        "node": ">= 0.8"
+      }
+    },
+    "node_modules/path-exists": {
+      "version": "4.0.0",
+      "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
+      "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==",
+      "dev": true,
+      "engines": {
+        "node": ">=8"
+      }
+    },
+    "node_modules/path-key": {
+      "version": "3.1.1",
+      "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
+      "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==",
+      "dev": true,
+      "engines": {
+        "node": ">=8"
+      }
+    },
+    "node_modules/path-parse": {
+      "version": "1.0.7",
+      "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz",
+      "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==",
+      "dev": true
+    },
+    "node_modules/path-to-regexp": {
+      "version": "0.1.7",
+      "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
+      "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==",
+      "dev": true
+    },
+    "node_modules/picocolors": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz",
+      "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==",
+      "dev": true
+    },
+    "node_modules/picomatch": {
+      "version": "2.3.1",
+      "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
+      "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
+      "dev": true,
+      "engines": {
+        "node": ">=8.6"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/jonschlinkert"
+      }
+    },
+    "node_modules/pkg-dir": {
+      "version": "4.2.0",
+      "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz",
+      "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==",
+      "dev": true,
+      "dependencies": {
+        "find-up": "^4.0.0"
+      },
+      "engines": {
+        "node": ">=8"
+      }
+    },
+    "node_modules/proxy-addr": {
+      "version": "2.0.7",
+      "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
+      "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==",
+      "dev": true,
+      "dependencies": {
+        "forwarded": "0.2.0",
+        "ipaddr.js": "1.9.1"
+      },
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/pstree.remy": {
+      "version": "1.1.8",
+      "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz",
+      "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==",
+      "dev": true
+    },
+    "node_modules/punycode": {
+      "version": "2.3.1",
+      "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
+      "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==",
+      "dev": true,
+      "engines": {
+        "node": ">=6"
+      }
+    },
+    "node_modules/qs": {
+      "version": "6.11.0",
+      "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz",
+      "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==",
+      "dev": true,
+      "dependencies": {
+        "side-channel": "^1.0.4"
+      },
+      "engines": {
+        "node": ">=0.6"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/ljharb"
+      }
+    },
+    "node_modules/randombytes": {
+      "version": "2.1.0",
+      "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz",
+      "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==",
+      "dev": true,
+      "dependencies": {
+        "safe-buffer": "^5.1.0"
+      }
+    },
+    "node_modules/range-parser": {
+      "version": "1.2.1",
+      "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
+      "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==",
+      "dev": true,
+      "engines": {
+        "node": ">= 0.6"
+      }
+    },
+    "node_modules/raw-body": {
+      "version": "2.5.2",
+      "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz",
+      "integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==",
+      "dev": true,
+      "dependencies": {
+        "bytes": "3.1.2",
+        "http-errors": "2.0.0",
+        "iconv-lite": "0.4.24",
+        "unpipe": "1.0.0"
+      },
+      "engines": {
+        "node": ">= 0.8"
+      }
+    },
+    "node_modules/readdirp": {
+      "version": "3.6.0",
+      "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz",
+      "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==",
+      "dev": true,
+      "dependencies": {
+        "picomatch": "^2.2.1"
+      },
+      "engines": {
+        "node": ">=8.10.0"
+      }
+    },
+    "node_modules/rechoir": {
+      "version": "0.8.0",
+      "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.8.0.tgz",
+      "integrity": "sha512-/vxpCXddiX8NGfGO/mTafwjq4aFa/71pvamip0++IQk3zG8cbCj0fifNPrjjF1XMXUne91jL9OoxmdykoEtifQ==",
+      "dev": true,
+      "dependencies": {
+        "resolve": "^1.20.0"
+      },
+      "engines": {
+        "node": ">= 10.13.0"
+      }
+    },
+    "node_modules/resolve": {
+      "version": "1.22.8",
+      "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz",
+      "integrity": "sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==",
+      "dev": true,
+      "dependencies": {
+        "is-core-module": "^2.13.0",
+        "path-parse": "^1.0.7",
+        "supports-preserve-symlinks-flag": "^1.0.0"
+      },
+      "bin": {
+        "resolve": "bin/resolve"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/ljharb"
+      }
+    },
+    "node_modules/resolve-cwd": {
+      "version": "3.0.0",
+      "resolved": "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-3.0.0.tgz",
+      "integrity": "sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg==",
+      "dev": true,
+      "dependencies": {
+        "resolve-from": "^5.0.0"
+      },
+      "engines": {
+        "node": ">=8"
+      }
+    },
+    "node_modules/resolve-from": {
+      "version": "5.0.0",
+      "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz",
+      "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==",
+      "dev": true,
+      "engines": {
+        "node": ">=8"
+      }
+    },
+    "node_modules/safe-buffer": {
+      "version": "5.2.1",
+      "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
+      "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
+      "dev": true,
+      "funding": [
+        {
+          "type": "github",
+          "url": "https://github.com/sponsors/feross"
+        },
+        {
+          "type": "patreon",
+          "url": "https://www.patreon.com/feross"
+        },
+        {
+          "type": "consulting",
+          "url": "https://feross.org/support"
+        }
+      ]
+    },
+    "node_modules/safer-buffer": {
+      "version": "2.1.2",
+      "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
+      "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
+      "dev": true
+    },
+    "node_modules/schema-utils": {
+      "version": "3.3.0",
+      "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.3.0.tgz",
+      "integrity": "sha512-pN/yOAvcC+5rQ5nERGuwrjLlYvLTbCibnZ1I7B1LaiAz9BRBlE9GMgE/eqV30P7aJQUf7Ddimy/RsbYO/GrVGg==",
+      "dev": true,
+      "dependencies": {
+        "@types/json-schema": "^7.0.8",
+        "ajv": "^6.12.5",
+        "ajv-keywords": "^3.5.2"
+      },
+      "engines": {
+        "node": ">= 10.13.0"
+      },
+      "funding": {
+        "type": "opencollective",
+        "url": "https://opencollective.com/webpack"
+      }
+    },
+    "node_modules/semver": {
+      "version": "5.7.2",
+      "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz",
+      "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==",
+      "dev": true,
+      "bin": {
+        "semver": "bin/semver"
+      }
+    },
+    "node_modules/send": {
+      "version": "0.18.0",
+      "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz",
+      "integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==",
+      "dev": true,
+      "dependencies": {
+        "debug": "2.6.9",
+        "depd": "2.0.0",
+        "destroy": "1.2.0",
+        "encodeurl": "~1.0.2",
+        "escape-html": "~1.0.3",
+        "etag": "~1.8.1",
+        "fresh": "0.5.2",
+        "http-errors": "2.0.0",
+        "mime": "1.6.0",
+        "ms": "2.1.3",
+        "on-finished": "2.4.1",
+        "range-parser": "~1.2.1",
+        "statuses": "2.0.1"
+      },
+      "engines": {
+        "node": ">= 0.8.0"
+      }
+    },
+    "node_modules/send/node_modules/ms": {
+      "version": "2.1.3",
+      "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
+      "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
+      "dev": true
+    },
+    "node_modules/serialize-javascript": {
+      "version": "6.0.2",
+      "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.2.tgz",
+      "integrity": "sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==",
+      "dev": true,
+      "dependencies": {
+        "randombytes": "^2.1.0"
+      }
+    },
+    "node_modules/serve-static": {
+      "version": "1.15.0",
+      "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz",
+      "integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==",
+      "dev": true,
+      "dependencies": {
+        "encodeurl": "~1.0.2",
+        "escape-html": "~1.0.3",
+        "parseurl": "~1.3.3",
+        "send": "0.18.0"
+      },
+      "engines": {
+        "node": ">= 0.8.0"
+      }
+    },
+    "node_modules/set-function-length": {
+      "version": "1.2.1",
+      "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.1.tgz",
+      "integrity": "sha512-j4t6ccc+VsKwYHso+kElc5neZpjtq9EnRICFZtWyBsLojhmeF/ZBd/elqm22WJh/BziDe/SBiOeAt0m2mfLD0g==",
+      "dev": true,
+      "dependencies": {
+        "define-data-property": "^1.1.2",
+        "es-errors": "^1.3.0",
+        "function-bind": "^1.1.2",
+        "get-intrinsic": "^1.2.3",
+        "gopd": "^1.0.1",
+        "has-property-descriptors": "^1.0.1"
+      },
+      "engines": {
+        "node": ">= 0.4"
+      }
+    },
+    "node_modules/setprototypeof": {
+      "version": "1.2.0",
+      "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
+      "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==",
+      "dev": true
+    },
+    "node_modules/shallow-clone": {
+      "version": "3.0.1",
+      "resolved": "https://registry.npmjs.org/shallow-clone/-/shallow-clone-3.0.1.tgz",
+      "integrity": "sha512-/6KqX+GVUdqPuPPd2LxDDxzX6CAbjJehAAOKlNpqqUpAqPM6HeL8f+o3a+JsyGjn2lv0WY8UsTgUJjU9Ok55NA==",
+      "dev": true,
+      "dependencies": {
+        "kind-of": "^6.0.2"
+      },
+      "engines": {
+        "node": ">=8"
+      }
+    },
+    "node_modules/shebang-command": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
+      "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==",
+      "dev": true,
+      "dependencies": {
+        "shebang-regex": "^3.0.0"
+      },
+      "engines": {
+        "node": ">=8"
+      }
+    },
+    "node_modules/shebang-regex": {
+      "version": "3.0.0",
+      "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz",
+      "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==",
+      "dev": true,
+      "engines": {
+        "node": ">=8"
+      }
+    },
+    "node_modules/side-channel": {
+      "version": "1.0.6",
+      "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.6.tgz",
+      "integrity": "sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA==",
+      "dev": true,
+      "dependencies": {
+        "call-bind": "^1.0.7",
+        "es-errors": "^1.3.0",
+        "get-intrinsic": "^1.2.4",
+        "object-inspect": "^1.13.1"
+      },
+      "engines": {
+        "node": ">= 0.4"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/ljharb"
+      }
+    },
+    "node_modules/simple-update-notifier": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-1.1.0.tgz",
+      "integrity": "sha512-VpsrsJSUcJEseSbMHkrsrAVSdvVS5I96Qo1QAQ4FxQ9wXFcB+pjj7FB7/us9+GcgfW4ziHtYMc1J0PLczb55mg==",
+      "dev": true,
+      "dependencies": {
+        "semver": "~7.0.0"
+      },
+      "engines": {
+        "node": ">=8.10.0"
+      }
+    },
+    "node_modules/simple-update-notifier/node_modules/semver": {
+      "version": "7.0.0",
+      "resolved": "https://registry.npmjs.org/semver/-/semver-7.0.0.tgz",
+      "integrity": "sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A==",
+      "dev": true,
+      "bin": {
+        "semver": "bin/semver.js"
+      }
+    },
+    "node_modules/source-map": {
+      "version": "0.6.1",
+      "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
+      "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/source-map-support": {
+      "version": "0.5.21",
+      "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz",
+      "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==",
+      "dev": true,
+      "dependencies": {
+        "buffer-from": "^1.0.0",
+        "source-map": "^0.6.0"
+      }
+    },
+    "node_modules/statuses": {
+      "version": "2.0.1",
+      "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz",
+      "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==",
+      "dev": true,
+      "engines": {
+        "node": ">= 0.8"
+      }
+    },
+    "node_modules/supports-color": {
+      "version": "7.2.0",
+      "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
+      "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
+      "dev": true,
+      "dependencies": {
+        "has-flag": "^4.0.0"
+      },
+      "engines": {
+        "node": ">=8"
+      }
+    },
+    "node_modules/supports-preserve-symlinks-flag": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz",
+      "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==",
+      "dev": true,
+      "engines": {
+        "node": ">= 0.4"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/ljharb"
+      }
+    },
+    "node_modules/tapable": {
+      "version": "2.2.1",
+      "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz",
+      "integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==",
+      "dev": true,
+      "engines": {
+        "node": ">=6"
+      }
+    },
+    "node_modules/terser": {
+      "version": "5.28.1",
+      "resolved": "https://registry.npmjs.org/terser/-/terser-5.28.1.tgz",
+      "integrity": "sha512-wM+bZp54v/E9eRRGXb5ZFDvinrJIOaTapx3WUokyVGZu5ucVCK55zEgGd5Dl2fSr3jUo5sDiERErUWLY6QPFyA==",
+      "dev": true,
+      "dependencies": {
+        "@jridgewell/source-map": "^0.3.3",
+        "acorn": "^8.8.2",
+        "commander": "^2.20.0",
+        "source-map-support": "~0.5.20"
+      },
+      "bin": {
+        "terser": "bin/terser"
+      },
+      "engines": {
+        "node": ">=10"
+      }
+    },
+    "node_modules/terser-webpack-plugin": {
+      "version": "5.3.10",
+      "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-5.3.10.tgz",
+      "integrity": "sha512-BKFPWlPDndPs+NGGCr1U59t0XScL5317Y0UReNrHaw9/FwhPENlq6bfgs+4yPfyP51vqC1bQ4rp1EfXW5ZSH9w==",
+      "dev": true,
+      "dependencies": {
+        "@jridgewell/trace-mapping": "^0.3.20",
+        "jest-worker": "^27.4.5",
+        "schema-utils": "^3.1.1",
+        "serialize-javascript": "^6.0.1",
+        "terser": "^5.26.0"
+      },
+      "engines": {
+        "node": ">= 10.13.0"
+      },
+      "funding": {
+        "type": "opencollective",
+        "url": "https://opencollective.com/webpack"
+      },
+      "peerDependencies": {
+        "webpack": "^5.1.0"
+      },
+      "peerDependenciesMeta": {
+        "@swc/core": {
+          "optional": true
+        },
+        "esbuild": {
+          "optional": true
+        },
+        "uglify-js": {
+          "optional": true
+        }
+      }
+    },
+    "node_modules/to-regex-range": {
+      "version": "5.0.1",
+      "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
+      "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
+      "dev": true,
+      "dependencies": {
+        "is-number": "^7.0.0"
+      },
+      "engines": {
+        "node": ">=8.0"
+      }
+    },
+    "node_modules/toidentifier": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
+      "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.6"
+      }
+    },
+    "node_modules/touch": {
+      "version": "3.1.0",
+      "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.0.tgz",
+      "integrity": "sha512-WBx8Uy5TLtOSRtIq+M03/sKDrXCLHxwDcquSP2c43Le03/9serjQBIztjRz6FkJez9D/hleyAXTBGLwwZUw9lA==",
+      "dev": true,
+      "dependencies": {
+        "nopt": "~1.0.10"
+      },
+      "bin": {
+        "nodetouch": "bin/nodetouch.js"
+      }
+    },
+    "node_modules/type-is": {
+      "version": "1.6.18",
+      "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
+      "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==",
+      "dev": true,
+      "dependencies": {
+        "media-typer": "0.3.0",
+        "mime-types": "~2.1.24"
+      },
+      "engines": {
+        "node": ">= 0.6"
+      }
+    },
+    "node_modules/uglify-js": {
+      "version": "3.17.4",
+      "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.17.4.tgz",
+      "integrity": "sha512-T9q82TJI9e/C1TAxYvfb16xO120tMVFZrGA3f9/P4424DNu6ypK103y0GPFVa17yotwSyZW5iYXgjYHkGrJW/g==",
+      "dev": true,
+      "bin": {
+        "uglifyjs": "bin/uglifyjs"
+      },
+      "engines": {
+        "node": ">=0.8.0"
+      }
+    },
+    "node_modules/undefsafe": {
+      "version": "2.0.5",
+      "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz",
+      "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==",
+      "dev": true
+    },
+    "node_modules/undici-types": {
+      "version": "5.26.5",
+      "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
+      "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==",
+      "dev": true
+    },
+    "node_modules/unpipe": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
+      "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==",
+      "dev": true,
+      "engines": {
+        "node": ">= 0.8"
+      }
+    },
+    "node_modules/update-browserslist-db": {
+      "version": "1.0.13",
+      "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz",
+      "integrity": "sha512-xebP81SNcPuNpPP3uzeW1NYXxI3rxyJzF3pD6sH4jE7o/IX+WtSpwnVU+qIsDPyk0d3hmFQ7mjqc6AtV604hbg==",
+      "dev": true,
+      "funding": [
+        {
+          "type": "opencollective",
+          "url": "https://opencollective.com/browserslist"
+        },
+        {
+          "type": "tidelift",
+          "url": "https://tidelift.com/funding/github/npm/browserslist"
+        },
+        {
+          "type": "github",
+          "url": "https://github.com/sponsors/ai"
+        }
+      ],
+      "dependencies": {
+        "escalade": "^3.1.1",
+        "picocolors": "^1.0.0"
+      },
+      "bin": {
+        "update-browserslist-db": "cli.js"
+      },
+      "peerDependencies": {
+        "browserslist": ">= 4.21.0"
+      }
+    },
+    "node_modules/uri-js": {
+      "version": "4.4.1",
+      "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
+      "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==",
+      "dev": true,
+      "dependencies": {
+        "punycode": "^2.1.0"
+      }
+    },
+    "node_modules/utils-merge": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
+      "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==",
+      "dev": true,
+      "engines": {
+        "node": ">= 0.4.0"
+      }
+    },
+    "node_modules/vary": {
+      "version": "1.1.2",
+      "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
+      "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==",
+      "dev": true,
+      "engines": {
+        "node": ">= 0.8"
+      }
+    },
+    "node_modules/watchpack": {
+      "version": "2.4.0",
+      "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.0.tgz",
+      "integrity": "sha512-Lcvm7MGST/4fup+ifyKi2hjyIAwcdI4HRgtvTpIUxBRhB+RFtUh8XtDOxUfctVCnhVi+QQj49i91OyvzkJl6cg==",
+      "dev": true,
+      "dependencies": {
+        "glob-to-regexp": "^0.4.1",
+        "graceful-fs": "^4.1.2"
+      },
+      "engines": {
+        "node": ">=10.13.0"
+      }
+    },
+    "node_modules/webpack": {
+      "version": "5.90.3",
+      "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.90.3.tgz",
+      "integrity": "sha512-h6uDYlWCctQRuXBs1oYpVe6sFcWedl0dpcVaTf/YF67J9bKvwJajFulMVSYKHrksMB3I/pIagRzDxwxkebuzKA==",
+      "dev": true,
+      "dependencies": {
+        "@types/eslint-scope": "^3.7.3",
+        "@types/estree": "^1.0.5",
+        "@webassemblyjs/ast": "^1.11.5",
+        "@webassemblyjs/wasm-edit": "^1.11.5",
+        "@webassemblyjs/wasm-parser": "^1.11.5",
+        "acorn": "^8.7.1",
+        "acorn-import-assertions": "^1.9.0",
+        "browserslist": "^4.21.10",
+        "chrome-trace-event": "^1.0.2",
+        "enhanced-resolve": "^5.15.0",
+        "es-module-lexer": "^1.2.1",
+        "eslint-scope": "5.1.1",
+        "events": "^3.2.0",
+        "glob-to-regexp": "^0.4.1",
+        "graceful-fs": "^4.2.9",
+        "json-parse-even-better-errors": "^2.3.1",
+        "loader-runner": "^4.2.0",
+        "mime-types": "^2.1.27",
+        "neo-async": "^2.6.2",
+        "schema-utils": "^3.2.0",
+        "tapable": "^2.1.1",
+        "terser-webpack-plugin": "^5.3.10",
+        "watchpack": "^2.4.0",
+        "webpack-sources": "^3.2.3"
+      },
+      "bin": {
+        "webpack": "bin/webpack.js"
+      },
+      "engines": {
+        "node": ">=10.13.0"
+      },
+      "funding": {
+        "type": "opencollective",
+        "url": "https://opencollective.com/webpack"
+      },
+      "peerDependenciesMeta": {
+        "webpack-cli": {
+          "optional": true
+        }
+      }
+    },
+    "node_modules/webpack-cli": {
+      "version": "5.1.4",
+      "resolved": "https://registry.npmjs.org/webpack-cli/-/webpack-cli-5.1.4.tgz",
+      "integrity": "sha512-pIDJHIEI9LR0yxHXQ+Qh95k2EvXpWzZ5l+d+jIo+RdSm9MiHfzazIxwwni/p7+x4eJZuvG1AJwgC4TNQ7NRgsg==",
+      "dev": true,
+      "dependencies": {
+        "@discoveryjs/json-ext": "^0.5.0",
+        "@webpack-cli/configtest": "^2.1.1",
+        "@webpack-cli/info": "^2.0.2",
+        "@webpack-cli/serve": "^2.0.5",
+        "colorette": "^2.0.14",
+        "commander": "^10.0.1",
+        "cross-spawn": "^7.0.3",
+        "envinfo": "^7.7.3",
+        "fastest-levenshtein": "^1.0.12",
+        "import-local": "^3.0.2",
+        "interpret": "^3.1.1",
+        "rechoir": "^0.8.0",
+        "webpack-merge": "^5.7.3"
+      },
+      "bin": {
+        "webpack-cli": "bin/cli.js"
+      },
+      "engines": {
+        "node": ">=14.15.0"
+      },
+      "funding": {
+        "type": "opencollective",
+        "url": "https://opencollective.com/webpack"
+      },
+      "peerDependencies": {
+        "webpack": "5.x.x"
+      },
+      "peerDependenciesMeta": {
+        "@webpack-cli/generators": {
+          "optional": true
+        },
+        "webpack-bundle-analyzer": {
+          "optional": true
+        },
+        "webpack-dev-server": {
+          "optional": true
+        }
+      }
+    },
+    "node_modules/webpack-cli/node_modules/commander": {
+      "version": "10.0.1",
+      "resolved": "https://registry.npmjs.org/commander/-/commander-10.0.1.tgz",
+      "integrity": "sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==",
+      "dev": true,
+      "engines": {
+        "node": ">=14"
+      }
+    },
+    "node_modules/webpack-merge": {
+      "version": "5.10.0",
+      "resolved": "https://registry.npmjs.org/webpack-merge/-/webpack-merge-5.10.0.tgz",
+      "integrity": "sha512-+4zXKdx7UnO+1jaN4l2lHVD+mFvnlZQP/6ljaJVb4SZiwIKeUnrT5l0gkT8z+n4hKpC+jpOv6O9R+gLtag7pSA==",
+      "dev": true,
+      "dependencies": {
+        "clone-deep": "^4.0.1",
+        "flat": "^5.0.2",
+        "wildcard": "^2.0.0"
+      },
+      "engines": {
+        "node": ">=10.0.0"
+      }
+    },
+    "node_modules/webpack-sources": {
+      "version": "3.2.3",
+      "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-3.2.3.tgz",
+      "integrity": "sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w==",
+      "dev": true,
+      "engines": {
+        "node": ">=10.13.0"
+      }
+    },
+    "node_modules/which": {
+      "version": "2.0.2",
+      "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
+      "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
+      "dev": true,
+      "dependencies": {
+        "isexe": "^2.0.0"
+      },
+      "bin": {
+        "node-which": "bin/node-which"
+      },
+      "engines": {
+        "node": ">= 8"
+      }
+    },
+    "node_modules/wildcard": {
+      "version": "2.0.1",
+      "resolved": "https://registry.npmjs.org/wildcard/-/wildcard-2.0.1.tgz",
+      "integrity": "sha512-CC1bOL87PIWSBhDcTrdeLo6eGT7mCFtrg0uIJtqJUFyK+eJnzl8A1niH56uu7KMa5XFrtiV+AQuHO3n7DsHnLQ==",
+      "dev": true
+    }
+  }
+}

+ 33 - 0
package.json

@@ -0,0 +1,33 @@
+{
+  "name": "puter.com",
+  "version": "1.0.0",
+  "author": "Puter Technologies Inc.",
+  "license": "AGPL-3.0-only",
+  "description": "Desktop environment in the browser!",
+  "homepage": "https://puter.com",
+  "directories": {
+    "lib": "lib"
+  },
+  "devDependencies": {
+    "chalk": "^4.1.0",
+    "clean-css": "^5.3.2",
+    "html-entities": "^2.3.3",
+    "webpack": "^5.88.2",
+    "express": "^4.18.2",
+    "nodemon": "^2.0.22",
+    "uglify-js": "^3.17.4",
+    "webpack-cli": "^5.1.1"
+  },
+  "scripts": {
+    "test": "echo \"Error: no test specified\" && exit 1",
+    "start": "nodemon --exec \"node dev-server.js\" ",
+    "build": "node ./build.js"
+  },
+  "nodemonConfig": {
+    "ext": "js, json, mjs, jsx, svg, css",
+    "ignore": [
+      "./dist/",
+      "./node_modules/"
+    ]
+  }
+}

+ 953 - 0
src/IPC.js

@@ -0,0 +1,953 @@
+import UIAlert from './UI/UIAlert.js';
+import UIWindow from './UI/UIWindow.js';
+import UIWindowSignup from './UI/UIWindowSignup.js';
+import UIWindowRequestPermission from './UI/UIWindowRequestPermission.js';
+import UIItem from './UI/UIItem.js'
+import UIWindowFontPicker from './UI/UIWindowFontPicker.js';
+import UIWindowColorPicker from './UI/UIWindowColorPicker.js';
+import UIPrompt from './UI/UIPrompt.js';
+import download from './helpers/download.js';
+import path from "./lib/path.js";
+
+/**
+ * In Puter, apps are loaded in iframes and communicate with the graphical user interface (GUI) aand each other using the postMessage API.
+ * The following sets up an Inter-Process Messaging System between apps and the GUI that enables communication
+ * for various tasks such as displaying alerts, prompts, managing windows, handling file operations, and more.
+ * 
+ * The system listens for 'message' events on the window object, handling different types of messages from the app (which is loaded in an iframe),
+ * such as ALERT, createWindow, showOpenFilePicker, ... 
+ * Each message handler performs specific actions, including creating UI windows, handling file saves and reads, and responding to user interactions.
+ * 
+ * Precautions are taken to ensure proper usage of appInstanceIDs and other sensitive information.
+ */
+window.addEventListener('message', async (event) => {
+    const app_env = event.data?.env ?? 'app';
+    
+    // Only process messages from apps
+    if(app_env !== 'app')
+        return;
+
+    // --------------------------------------------------------
+    // A response to a GUI message received from the app.
+    // --------------------------------------------------------
+    if (typeof event.data.original_msg_id !== "undefined" && typeof appCallbackFunctions[event.data.original_msg_id] !== "undefined") {
+        // Execute callback
+        appCallbackFunctions[event.data.original_msg_id](event.data);
+        // Remove this callback function since it won't be needed again
+        delete appCallbackFunctions[event.data.original_msg_id];
+
+        // Done
+        return;
+    }
+
+    // --------------------------------------------------------
+    // Message from apps
+    // --------------------------------------------------------
+
+    // `data` and `msg` are required
+    if(!event.data || !event.data.msg){
+        return;
+    }
+
+    // `appInstanceID` is required
+    if(!event.data.appInstanceID){
+        console.log(`appInstanceID is needed`);
+        return;
+    }
+
+    const $el_parent_window = $(`.window[data-element_uuid="${event.data.appInstanceID}"]`);
+    const parent_window_id = $el_parent_window.attr('data-id');
+    const $el_parent_disable_mask = $el_parent_window.find('.window-disable-mask');
+    const target_iframe = $(`.window[data-element_uuid="${event.data.appInstanceID}"]`).find('.window-app-iframe').get(0);
+    const msg_id = event.data.uuid;
+    const app_name = $(target_iframe).attr('data-app');
+    const app_uuid = $el_parent_window.attr('data-app_uuid');
+
+    // todo validate all event.data stuff coming from the client (e.g. event.data.message, .msg, ...)
+    //-------------------------------------------------
+    // READY
+    //-------------------------------------------------
+    if(event.data.msg === 'READY'){
+        $(target_iframe).attr('data-appUsesSDK', 'true');
+    }
+    //-------------------------------------------------
+    // windowFocused
+    //-------------------------------------------------
+    else if(event.data.msg === 'windowFocused'){
+        console.log('windowFocused');
+    }
+    //--------------------------------------------------------
+    // ALERT
+    //--------------------------------------------------------
+    else if(event.data.msg === 'ALERT' && event.data.message !== undefined){
+        const alert_resp = await UIAlert({
+            message: html_encode(event.data.message),
+            buttons: event.data.buttons,
+            type: event.data.options?.type,
+            window_options: {
+                parent_uuid: event.data.appInstanceID,
+                disable_parent_window: true,
+            }
+        })
+
+        target_iframe.contentWindow.postMessage({
+            original_msg_id: msg_id,
+            msg: 'alertResponded',
+            response: alert_resp,
+        }, '*');
+    }
+    //--------------------------------------------------------
+    // PROMPT
+    //--------------------------------------------------------
+    else if(event.data.msg === 'PROMPT' && event.data.message !== undefined){
+        const prompt_resp = await UIPrompt({
+            message: html_encode(event.data.message),
+            placeholder: html_encode(event.data.placeholder),
+            window_options: {
+                parent_uuid: event.data.appInstanceID,
+                disable_parent_window: true,
+            }
+        })
+
+        target_iframe.contentWindow.postMessage({
+            original_msg_id: msg_id,
+            msg: 'promptResponded',
+            response: prompt_resp,
+        }, '*');
+    }
+    //--------------------------------------------------------
+    // env
+    //--------------------------------------------------------
+    else if(event.data.msg === 'env'){
+        target_iframe.contentWindow.postMessage({
+            original_msg_id: msg_id,
+        }, '*');
+    }
+    //--------------------------------------------------------
+    // createWindow
+    //--------------------------------------------------------
+    else if(event.data.msg === 'createWindow'){
+        // todo: validate as many of these as possible
+        if(event.data.options){
+            UIWindow({
+                title: event.data.options.title,
+                disable_parent_window: event.data.options.disable_parent_window,
+                width: event.data.options.width,
+                height: event.data.options.height,
+                is_resizable: event.data.options.is_resizable,
+                has_head: event.data.options.has_head,
+                center: event.data.options.center,
+                show_in_taskbar: event.data.options.show_in_taskbar,                    
+                iframe_srcdoc: event.data.options.content,
+                iframe_url: event.data.options.url,
+                parent_uuid: event.data.appInstanceID,
+            })
+        }
+    }
+    //--------------------------------------------------------
+    // setItem
+    //--------------------------------------------------------
+    else if(event.data.msg === 'setItem' && event.data.key && event.data.value){
+        // todo: validate key and value to avoid unnecessary api calls
+        return await $.ajax({
+            url: api_origin + "/setItem",
+            type: 'POST',
+            data: JSON.stringify({ 
+                app: app_uuid,
+                key: event.data.key,
+                value: event.data.value,
+            }),
+            async: true,
+            contentType: "application/json",
+            headers: {
+                "Authorization": "Bearer "+auth_token
+            },
+            statusCode: {
+                401: function () {
+                    logout();
+                },
+            },        
+            success: function (fsentry){
+            }  
+        })
+    }
+    //--------------------------------------------------------
+    // getItem
+    //--------------------------------------------------------
+    else if(event.data.msg === 'getItem' && event.data.key){
+        // todo: validate key to avoid unnecessary api calls
+        $.ajax({
+            url: api_origin + "/getItem",
+            type: 'POST',
+            data: JSON.stringify({ 
+                key: event.data.key,
+                app: app_uuid,
+            }),
+            async: true,
+            contentType: "application/json",
+            headers: {
+                "Authorization": "Bearer "+auth_token
+            },
+            statusCode: {
+                401: function () {
+                    logout();
+                },
+            },        
+            success: function (result){
+                // send confirmation to requester window
+                target_iframe.contentWindow.postMessage({
+                    original_msg_id: msg_id,
+                    msg: 'getItemSucceeded',
+                    value: result ? result.value : null,
+                }, '*');
+            }  
+        })
+    }
+    //--------------------------------------------------------
+    // removeItem
+    //--------------------------------------------------------
+    else if(event.data.msg === 'removeItem' && event.data.key){
+        // todo: validate key to avoid unnecessary api calls
+        $.ajax({
+            url: api_origin + "/removeItem",
+            type: 'POST',
+            data: JSON.stringify({ 
+                key: event.data.key,
+                app: app_uuid,
+            }),
+            async: true,
+            contentType: "application/json",
+            headers: {
+                "Authorization": "Bearer "+auth_token
+            },
+            statusCode: {
+                401: function () {
+                    logout();
+                },
+            },        
+            success: function (result){
+                // send confirmation to requester window
+                target_iframe.contentWindow.postMessage({
+                    original_msg_id: msg_id,
+                }, '*');
+            }  
+        })
+    }
+    //--------------------------------------------------------
+    // showOpenFilePicker
+    //--------------------------------------------------------
+    else if(event.data.msg === 'showOpenFilePicker'){
+        // Auth
+        if(!is_auth() && !(await UIWindowSignup({referrer: app_name})))
+            return;
+
+        // Disable parent window
+        $el_parent_window.addClass('window-disabled')
+        $el_parent_disable_mask.show();
+        $el_parent_disable_mask.css('z-index', parseInt($el_parent_window.css('z-index')) + 1);
+        $(target_iframe).blur();
+
+        // Allowed_file_types
+        let allowed_file_types = "";
+        if(event.data.options && event.data.options.accept)
+            allowed_file_types = event.data.options.accept;
+
+        // selectable_body
+        let is_selectable_body = false;
+        if(event.data.options && event.data.options.multiple && event.data.options.multiple === true)
+            is_selectable_body = true;
+
+        // Open dialog
+        UIWindow({
+            allowed_file_types: allowed_file_types,
+            path: '/' + window.user.username + '/Desktop',
+            // this is the uuid of the window to which this dialog will return
+            parent_uuid: event.data.appInstanceID,
+            show_maximize_button: false,
+            show_minimize_button: false,
+            title: 'Open',
+            is_dir: true,
+            is_openFileDialog: true,
+            selectable_body: is_selectable_body,
+            iframe_msg_uid: msg_id,
+            initiating_app_uuid: app_uuid,
+            center: true,
+        });
+    }
+    //--------------------------------------------------------
+    // showDirectoryPicker
+    //--------------------------------------------------------
+    else if(event.data.msg === 'showDirectoryPicker'){
+        // Auth
+        if(!is_auth() && !(await UIWindowSignup({referrer: app_name})))
+            return;
+
+        // Disable parent window
+        $el_parent_window.addClass('window-disabled')
+        $el_parent_disable_mask.show();
+        $el_parent_disable_mask.css('z-index', parseInt($el_parent_window.css('z-index')) + 1);
+        $(target_iframe).blur();
+
+        // allowed_file_types
+        let allowed_file_types = "";
+        if(event.data.options && event.data.options.accept)
+            allowed_file_types = event.data.options.accept;
+
+        // selectable_body
+        let is_selectable_body = false;
+        if(event.data.options && event.data.options.multiple && event.data.options.multiple === true)
+            is_selectable_body = true;
+
+        // open dialog
+        UIWindow({
+            path: '/' + window.user.username + '/Desktop',
+            // this is the uuid of the window to which this dialog will return
+            parent_uuid: event.data.appInstanceID,
+            show_maximize_button: false,
+            show_minimize_button: false,
+            title: 'Open',
+            is_dir: true,
+            is_directoryPicker: true,
+            selectable_body: is_selectable_body,
+            iframe_msg_uid: msg_id,
+            center: true,
+            initiating_app_uuid: app_uuid,
+        });
+    }
+
+    //--------------------------------------------------------
+    // setWindowTitle
+    //--------------------------------------------------------
+    else if(event.data.msg === 'setWindowTitle' && event.data.new_title !== undefined){
+        const el_window = $(`.window[data-element_uuid="${event.data.appInstanceID}"]`).get(0);
+        // set window title
+        $(el_window).find(`.window-head-title`).html(html_encode(event.data.new_title));
+        // send confirmation to requester window
+        target_iframe.contentWindow.postMessage({
+            original_msg_id: msg_id, 
+        }, '*');
+    }
+    //--------------------------------------------------------
+    // watchItem
+    //--------------------------------------------------------
+    else if(event.data.msg === 'watchItem' && event.data.item_uid !== undefined){
+        if(!window.watchItems[event.data.item_uid])
+            window.watchItems[event.data.item_uid] = [];
+
+        window.watchItems[event.data.item_uid].push(event.data.appInstanceID);
+    }
+    //--------------------------------------------------------
+    // openItem
+    //--------------------------------------------------------
+    else if(event.data.msg === 'openItem'){
+        // check if readURL returns 200
+        $.ajax({
+            url: event.data.metadataURL + '&return_suggested_apps=true&return_path=true',
+            type: 'GET',
+            headers: {
+                "Authorization": "Bearer "+auth_token
+            },
+            success: async function(metadata){
+                $.ajax({
+                    url: api_origin + "/open_item",
+                    type: 'POST',
+                    contentType: "application/json",
+                    data: JSON.stringify({
+                        uid: metadata.uid ?? undefined,
+                        path: metadata.path ?? undefined,
+                    }),
+                    headers: {
+                        "Authorization": "Bearer "+auth_token
+                    },
+                    statusCode: {
+                        401: function () {
+                            logout();
+                        },
+                    },
+                    success: function(open_item_meta){
+                        setTimeout(function(){
+                            launch_app({ 
+                                name: metadata.name, 
+                                file_path: metadata.path,
+                                app_obj: open_item_meta.suggested_apps[0],
+                                window_title: metadata.name,
+                                file_uid: metadata.uid,
+                                file_signature: open_item_meta.signature,
+                            });
+                        // todo: this is done because sometimes other windows such as openFileDialog
+                        // bring focus to their apps and steal the focus from the newly-opened app
+                        }, 800);
+                    },
+                });            
+            }
+        })
+    }
+    //--------------------------------------------------------
+    // launchApp
+    //--------------------------------------------------------
+    else if(event.data.msg === 'launchApp'){
+        // launch app
+        launch_app({
+            name: event.data.app_name ?? app_name,
+            args: event.data.args ?? {},
+        });
+
+        // send confirmation to requester window
+        target_iframe.contentWindow.postMessage({
+            original_msg_id: msg_id, 
+        }, '*');
+    }
+    //--------------------------------------------------------
+    // readAppDataFile
+    //--------------------------------------------------------
+    else if(event.data.msg === 'readAppDataFile' && event.data.path !== undefined){
+        // resolve path to absolute
+        event.data.path = path.resolve(event.data.path);
+        
+        // join with appdata dir
+        const file_path = path.join(appdata_path, app_uuid, event.data.path);
+
+        puter.fs.sign(app_uuid, {
+                path: file_path, 
+                action: 'write',
+            }, 
+            function(signature){
+                signature = signature.items;
+                signature.signatures = signature.signatures ?? [signature];
+                if(signature.signatures.length > 0 && signature.signatures[0].path){
+                    signature.signatures[0].path = `~/` + signature.signatures[0].path.split('/').slice(2).join('/')
+                    // send confirmation to requester window
+                    target_iframe.contentWindow.postMessage({
+                        msg: "readAppDataFileSucceeded",
+                        original_msg_id: msg_id, 
+                        item: signature.signatures[0],
+                    }, '*');
+                }else{
+                    // send error to requester window
+                    target_iframe.contentWindow.postMessage({
+                        msg: "readAppDataFileFailed",
+                        original_msg_id: msg_id, 
+                    }, '*');
+                }
+            }
+        )
+    }
+    //--------------------------------------------------------
+    // getAppData
+    //--------------------------------------------------------
+    // todo appdata should be provided from the /open_item api call
+    else if(event.data.msg === 'getAppData'){
+        if(appdata_signatures[app_uuid]){
+            target_iframe.contentWindow.postMessage({
+                msg: "getAppDataSucceeded",
+                original_msg_id: msg_id, 
+                item: appdata_signatures[app_uuid],
+            }, '*');    
+        }
+        // make app directory if it doesn't exist
+        puter.fs.mkdir({
+            path: path.join( appdata_path, app_uuid),
+            rename: false,
+            overwrite: false,
+            success: function(dir){
+                puter.fs.sign(app_uuid, {
+                    uid: dir.uid, 
+                    action: 'write',
+                    success: function(signature){
+                        signature = signature.items;
+                        appdata_signatures[app_uuid] = signature;
+                        // send confirmation to requester window
+                        target_iframe.contentWindow.postMessage({
+                            msg: "getAppDataSucceeded",
+                            original_msg_id: msg_id, 
+                            item: signature,
+                        }, '*');
+                    }
+                })
+            },
+            error: function(err){
+                if(err.existing_fsentry || err.code === 'path_exists'){
+                    puter.fs.sign(app_uuid, {
+                        uid: err.existing_fsentry.uid, 
+                        action: 'write',
+                        success: function(signature){
+                            signature = signature.items;
+                            appdata_signatures[app_uuid] = signature;
+                            // send confirmation to requester window
+                            target_iframe.contentWindow.postMessage({
+                                msg: "getAppDataSucceeded",
+                                original_msg_id: msg_id, 
+                                item: signature,
+                            }, '*');
+                        }
+                    })    
+                }
+            }
+        });
+    }
+    //--------------------------------------------------------
+    // requestPermission
+    //--------------------------------------------------------
+    else if(event.data.msg === 'requestPermission'){
+        // auth
+        if(!is_auth() && !(await UIWindowSignup({referrer: app_name})))
+            return;
+
+        // options must be an object
+        if(event.data.options === undefined || typeof event.data.options !== 'object')
+            event.data.options = {};
+
+        // clear window_options for security reasons
+        event.data.options.window_options = {}
+
+        // Set app as parent window of font picker window
+        event.data.options.window_options.parent_uuid = event.data.appInstanceID;
+
+        // disable parent window
+        event.data.options.window_options.disable_parent_window = true;
+
+        let granted = await UIWindowRequestPermission({
+            origin: event.origin,
+            permission: event.data.options.permission,
+            window_options: event.data.options.window_options,
+        });
+
+        // send selected font to requester window
+        target_iframe.contentWindow.postMessage({
+            msg: "permissionGranted", 
+            granted: granted,
+            original_msg_id: msg_id, 
+        }, '*');
+        $(target_iframe).get(0).focus({preventScroll:true});
+    }
+    //--------------------------------------------------------
+    // showFontPicker
+    //--------------------------------------------------------
+    else if(event.data.msg === 'showFontPicker'){
+        // auth
+        if(!is_auth() && !(await UIWindowSignup({referrer: app_name})))
+            return;
+
+        // set options
+        event.data.options = event.data.options ?? {};
+
+        // clear window_options for security reasons
+        event.data.options.window_options = {}
+
+        // Set app as parent window of font picker window
+        event.data.options.window_options.parent_uuid = event.data.appInstanceID;
+
+        // Open font picker
+        let selected_font = await UIWindowFontPicker(event.data.options);
+
+        // send selected font to requester window
+        target_iframe.contentWindow.postMessage({
+            msg: "fontPicked", 
+            original_msg_id: msg_id, 
+            font: selected_font,
+        }, '*');
+        $(target_iframe).get(0).focus({preventScroll:true});
+    }
+    //--------------------------------------------------------
+    // showColorPicker
+    //--------------------------------------------------------
+    else if(event.data.msg === 'showColorPicker'){
+        // Auth
+        if(!is_auth() && !(await UIWindowSignup({referrer: app_name})))
+            return;
+
+        // set options
+        event.data.options = event.data.options ?? {};
+
+        // Clear window_options for security reasons
+        event.data.options.window_options = {}
+
+        // Set app as parent window of the font picker window
+        event.data.options.window_options.parent_uuid = event.data.appInstanceID;
+
+        // Open color picker
+        let selected_color = await UIWindowColorPicker(event.data.options);
+
+        // Send selected color to requester window
+        target_iframe.contentWindow.postMessage({
+            msg: "colorPicked", 
+            original_msg_id: msg_id, 
+            color: selected_color ? selected_color.color : undefined,
+        }, '*');
+        $(target_iframe).get(0).focus({preventScroll:true});
+    }        
+    //--------------------------------------------------------
+    // setWallpaper
+    //--------------------------------------------------------
+    else if(event.data.msg === 'setWallpaper'){
+        // Auth
+        if(!is_auth() && !(await UIWindowSignup({referrer: app_name})))
+            return;
+
+        // No options?
+        if(!event.data.options)
+            event.data.options = {};
+
+        // /set-desktop-bg
+        try{
+            await $.ajax({
+                url: api_origin + "/set-desktop-bg",
+                type: 'POST',
+                data: JSON.stringify({ 
+                    url: event.data.readURL,
+                    fit: event.data.options.fit ?? 'cover',
+                    color: event.data.options.color,
+                }),
+                async: true,
+                contentType: "application/json",
+                headers: {
+                    "Authorization": "Bearer "+auth_token
+                },
+                statusCode: {
+                    401: function () {
+                        logout();
+                    },
+                },    
+            });
+
+            // Set wallpaper
+            window.set_desktop_background({
+                url: event.data.readURL,
+                fit: event.data.options.fit ?? 'cover',
+                color: event.data.options.color,
+            })
+    
+            // Send success to app
+            target_iframe.contentWindow.postMessage({
+                msg: "wallpaperSet", 
+                original_msg_id: msg_id, 
+            }, '*');
+            $(target_iframe).get(0).focus({preventScroll:true});
+        }catch(err){
+            console.error(err);
+        }
+    }        
+
+    //--------------------------------------------------------
+    // showSaveFilePicker
+    //--------------------------------------------------------
+    else if(event.data.msg === 'showSaveFilePicker'){
+        //auth
+        if(!is_auth() && !(await UIWindowSignup({referrer: app_name})))
+            return;
+
+        //disable parent window
+        $el_parent_window.addClass('window-disabled')
+        $el_parent_disable_mask.show();
+        $el_parent_disable_mask.css('z-index', parseInt($el_parent_window.css('z-index')) + 1);
+        $(target_iframe).blur();
+
+        await UIWindow({
+            path: '/' + window.user.username + '/Desktop',
+            // this is the uuid of the window to which this dialog will return
+            parent_uuid: event.data.appInstanceID,
+            show_maximize_button: false,
+            show_minimize_button: false,
+            title: 'Save As…',
+            is_dir: true,
+            is_saveFileDialog: true,
+            saveFileDialog_default_filename: event.data.suggestedName ?? '',
+            selectable_body: false,
+            iframe_msg_uid: msg_id,
+            center: true,
+            initiating_app_uuid: app_uuid,
+            onSaveFileDialogSave: async function(target_path, el_filedialog_window){
+                $(el_filedialog_window).find('.window-disable-mask, .busy-indicator').show();
+                let busy_init_ts = Date.now();
+
+                // -------------------------------------
+                // URL
+                // -------------------------------------
+                if(event.data.url){
+                    // download progress tracker
+                    let dl_op_id = operation_id++;
+
+                    // upload progress tracker defaults
+                    window.progress_tracker[dl_op_id] = [];
+                    window.progress_tracker[dl_op_id][0] = {};
+                    window.progress_tracker[dl_op_id][0].total = 0;
+                    window.progress_tracker[dl_op_id][0].ajax_uploaded = 0;
+                    window.progress_tracker[dl_op_id][0].cloud_uploaded = 0;
+
+                    let item_with_same_name_already_exists = true;
+                    while(item_with_same_name_already_exists){
+                        await download({
+                            url: event.data.url, 
+                            name: path.basename(target_path),
+                            dest_path: path.dirname(target_path),
+                            auth_token: auth_token, 
+                            api_origin: api_origin,
+                            dedupe_name: false,
+                            overwrite: false,
+                            operation_id: dl_op_id,
+                            item_upload_id: 0,
+                            success: function(res){
+                            },
+                            error: function(err){
+                                UIAlert(err && err.message ? err.message : "Download failed.");
+                            }
+                        });
+                        item_with_same_name_already_exists = false;
+                    }
+                }
+                // -------------------------------------
+                // File
+                // -------------------------------------
+                else{
+                    let overwrite = false;
+                    let file_to_upload = new File([event.data.content], path.basename(target_path));
+                    let item_with_same_name_already_exists = true;
+                    while(item_with_same_name_already_exists){
+                        // overwrite?
+                        if(overwrite)
+                            item_with_same_name_already_exists = false;
+                        // upload
+                        try{
+                            const res = await puter.fs.write(
+                                target_path,
+                                file_to_upload, 
+                                { 
+                                    dedupeName: false,
+                                    overwrite: overwrite
+                                }
+                            );
+
+                            let file_signature = await puter.fs.sign(app_uuid, {uid: res.uid, action: 'write'});
+                            file_signature = file_signature.items;
+
+                            item_with_same_name_already_exists = false;
+                            target_iframe.contentWindow.postMessage({
+                                msg: "fileSaved", 
+                                original_msg_id: msg_id, 
+                                filename: res.name,
+                                saved_file: {
+                                    name: file_signature.fsentry_name,
+                                    readURL: file_signature.read_url,
+                                    writeURL: file_signature.write_url,
+                                    metadataURL: file_signature.metadata_url,
+                                    type: file_signature.type,
+                                    uid: file_signature.uid,
+                                    path: `~/` + res.path.split('/').slice(2).join('/'),
+                                },
+                            }, '*');
+
+                            $(target_iframe).get(0).focus({preventScroll:true});
+                            // Update matching items on open windows
+                            // todo don't blanket-update, mostly files with thumbnails really need to be updated
+                            // first remove overwritten items
+                            $(`.item[data-uid="${res.uid}"]`).removeItems();
+                            // now add new items
+                            UIItem({
+                                appendTo: $(`.item-container[data-path="${html_encode(path.dirname(target_path))}" i]`),
+                                immutable: res.immutable,
+                                associated_app_name: res.associated_app?.name,
+                                path: target_path,
+                                icon: await item_icon(res),
+                                name: path.basename(target_path),
+                                uid: res.uid,
+                                size: res.size,
+                                modified: res.modified,
+                                type: res.type,
+                                is_dir: false,
+                                is_shared: res.is_shared,
+                                suggested_apps: res.suggested_apps,
+                            });
+                            // sort each window
+                            $(`.item-container[data-path="${html_encode(path.dirname(target_path))}" i]`).each(function(){
+                                sort_items(this, $(this).attr('data-sort_by'), $(this).attr('data-sort_order'))
+                            });                            
+                            $(el_filedialog_window).close();
+                            show_save_account_notice_if_needed();
+                        }
+                        catch(err){
+                            // item with same name exists
+                            if(err.code === 'item_with_same_name_exists'){
+                                const alert_resp = await UIAlert({
+                                    message: `<strong>${html_encode(err.entry_name)}</strong> already exists.`,
+                                    buttons:[
+                                        {
+                                            label: 'Replace',
+                                            value: 'replace',
+                                            type: 'primary',
+                                        },
+                                        {
+                                            label: 'Cancel',
+                                            value: 'cancel',
+                                        },
+                                    ],
+                                    parent_uuid: $(el_filedialog_window).attr('data-element_uuid'),
+                                })
+                                if(alert_resp === 'replace'){
+                                    overwrite = true;
+                                }else if(alert_resp === 'cancel'){
+                                    // enable parent window
+                                    $(el_filedialog_window).find('.window-disable-mask, .busy-indicator').hide();
+                                    return;
+                                }
+                            }
+                            else{
+                                // show error
+                                await UIAlert({
+                                    message: err.message ?? "Upload failed.",
+                                    parent_uuid: $(el_filedialog_window).attr('data-element_uuid'),
+                                });
+                                // enable parent window
+                                $(el_filedialog_window).find('.window-disable-mask, .busy-indicator').hide();
+                                return;
+                            }
+                        }
+                    }
+                }
+
+                // done
+                let busy_duration = (Date.now() - busy_init_ts);
+                if( busy_duration >= busy_indicator_hide_delay){
+                    $(el_filedialog_window).close();   
+                }else{
+                    setTimeout(() => {
+                        // close this dialog
+                        $(el_filedialog_window).close();  
+                    }, Math.abs(busy_indicator_hide_delay - busy_duration));
+                }
+            }
+        });
+    }
+    //--------------------------------------------------------
+    // saveToPictures/Desktop/Documents/Videos/Audio/AppData
+    //--------------------------------------------------------
+    else if((event.data.msg === 'saveToPictures' || event.data.msg === 'saveToDesktop' || event.data.msg === 'saveToAppData' || 
+            event.data.msg === 'saveToDocuments' || event.data.msg === 'saveToVideos' || event.data.msg === 'saveToAudio')){
+        let target_path;
+        let create_missing_ancestors = false;
+
+        if(event.data.msg === 'saveToPictures')
+            target_path = path.join(pictures_path, event.data.filename);
+        else if(event.data.msg === 'saveToDesktop')
+            target_path = path.join(desktop_path, event.data.filename);
+        else if(event.data.msg === 'saveToDocuments')
+            target_path = path.join(documents_path, event.data.filename);
+        else if(event.data.msg === 'saveToVideos')
+            target_path = path.join(videos_path, event.data.filename);
+        else if(event.data.msg === 'saveToAudio')
+            target_path = path.join(audio_path, event.data.filename);
+        else if(event.data.msg === 'saveToAppData'){
+            target_path = path.join(appdata_path, app_uuid, event.data.filename);
+            create_missing_ancestors = true;
+        }
+        //auth
+        if(!is_auth() && !(await UIWindowSignup({referrer: app_name})))
+            return;
+
+        let item_with_same_name_already_exists = true;
+        let overwrite = false;
+
+        // -------------------------------------
+        // URL
+        // -------------------------------------
+        if(event.data.url){
+            let overwrite = false;
+            // download progress tracker
+            let dl_op_id = operation_id++;
+
+            // upload progress tracker defaults
+            window.progress_tracker[dl_op_id] = [];
+            window.progress_tracker[dl_op_id][0] = {};
+            window.progress_tracker[dl_op_id][0].total = 0;
+            window.progress_tracker[dl_op_id][0].ajax_uploaded = 0;
+            window.progress_tracker[dl_op_id][0].cloud_uploaded = 0;
+
+            let item_with_same_name_already_exists = true;
+            while(item_with_same_name_already_exists){
+                const res = await download({
+                    url: event.data.url, 
+                    name: path.basename(target_path),
+                    dest_path: path.dirname(target_path),
+                    auth_token: auth_token, 
+                    api_origin: api_origin,
+                    dedupe_name: true,
+                    overwrite: false,
+                    operation_id: dl_op_id,
+                    item_upload_id: 0,
+                    success: function(res){
+                    },
+                    error: function(err){
+                        UIAlert(err && err.message ? err.message : "Download failed.");
+                    }
+                });
+                item_with_same_name_already_exists = false;
+            }
+        }
+        // -------------------------------------
+        // File
+        // -------------------------------------
+        else{
+            let file_to_upload = new File([event.data.content], path.basename(target_path));
+            
+            while(item_with_same_name_already_exists){
+                if(overwrite)
+                    item_with_same_name_already_exists = false;
+                try{
+                    const res = await puter.fs.write(target_path, file_to_upload, {
+                        dedupeName: true,
+                        overwrite: false,
+                        createMissingAncestors: create_missing_ancestors,
+                    });
+                    item_with_same_name_already_exists = false;
+                    let file_signature = await puter.fs.sign(app_uuid, {uid: res.uid, action: 'write'});
+                    file_signature = file_signature.items;
+
+                    target_iframe.contentWindow.postMessage({
+                        msg: "fileSaved", 
+                        original_msg_id: msg_id, 
+                        filename: res.name,
+                        saved_file: {
+                            name: file_signature.fsentry_name,
+                            readURL: file_signature.read_url,
+                            writeURL: file_signature.write_url,
+                            metadataURL: file_signature.metadata_url,
+                            uid: file_signature.uid,
+                            path: `~/` + res.path.split('/').slice(2).join('/'),
+                        },
+                    }, '*');
+                    $(target_iframe).get(0).focus({preventScroll:true});
+                }
+                catch(err){
+                    if(err.code === 'item_with_same_name_exists'){
+                        const alert_resp = await UIAlert({
+                            message: `<strong>${html_encode(err.entry_name)}</strong> already exists.`,
+                            buttons:[
+                                {
+                                    label: 'Replace',
+                                    type: 'primary',
+                                },
+                                {
+                                    label: 'Cancel'
+                                },
+                            ],
+                            parent_uuid: event.data.appInstanceID,
+                        })
+                        if(alert_resp === 'Replace'){
+                            overwrite = true;
+                        }else if(alert_resp === 'Cancel'){
+                            item_with_same_name_already_exists = false;
+                        }
+                    }else{
+                        break;
+                    }
+                }
+            }
+        }
+    }
+
+    //--------------------------------------------------------
+    // exit
+    //--------------------------------------------------------
+    else if(event.data.msg === 'exit'){
+        $(`.window[data-element_uuid="${event.data.appInstanceID}"]`).close({bypass_iframe_messaging: true});
+    }
+});

File diff suppressed because it is too large
+ 8 - 0
src/UI/PuterDialog.js


+ 96 - 0
src/UI/UIAlert.js

@@ -0,0 +1,96 @@
+import UIWindow from './UIWindow.js'
+
+function UIAlert(options){
+    // set sensible defaults
+    if(arguments.length > 0){
+        // if first argument is a string, then assume it is the message
+        if(isString(arguments[0])){
+            options = {};
+            options.message = arguments[0];
+        }
+        // if second argument is an array, then assume it is the buttons
+        if(arguments[1] && Array.isArray(arguments[1])){
+            options.buttons = arguments[1];
+        }
+    }
+
+    return new Promise(async (resolve) => {
+        // provide an 'OK' button if no buttons are provided
+        if(!options.buttons || options.buttons.length === 0){
+            options.buttons = [
+                {label: 'OK', value: true, type: 'primary'}
+            ]
+        }
+
+        // set body icon
+        options.body_icon = options.body_icon ?? window.icons['warning-sign.svg'];
+        if(options.type === 'success')
+            options.body_icon = window.icons['c-check.svg'];
+
+        let h = '';
+        // icon
+        h += `<img class="window-alert-icon" src="${html_encode(options.body_icon)}">`;
+        // message
+        h += `<div class="window-alert-message">${options.message}</div>`;
+        // buttons
+        if(options.buttons && options.buttons.length > 0){
+            h += `<div style="overflow:hidden; margin-top:20px;">`;
+            for(let y=0; y<options.buttons.length; y++){
+                h += `<button class="button button-block button-${html_encode(options.buttons[y].type)} alert-resp-button" 
+                                data-label="${html_encode(options.buttons[y].label)}"
+                                data-value="${html_encode(options.buttons[y].value ?? options.buttons[y].label)}"
+                                ${options.buttons[y].type === 'primary' ? 'autofocus' : ''}
+                                >${html_encode(options.buttons[y].label)}</button>`;
+            }
+            h += `</div>`;
+        }
+
+        const el_window = await UIWindow({
+            title: null,
+            icon: null,
+            uid: null,
+            is_dir: false,
+            message: options.message,
+            body_icon: options.body_icon,
+            backdrop: options.backdrop ?? false,
+            is_resizable: false,
+            is_droppable: false,
+            has_head: false,
+            stay_on_top: options.stay_on_top ?? false,
+            selectable_body: false,
+            draggable_body: options.draggable_body ?? true,
+            allow_context_menu: false,
+            show_in_taskbar: false,
+            window_class: 'window-alert',
+            dominant: true,
+            body_content: h,
+            width: 350,
+            parent_uuid: options.parent_uuid,
+            ...options.window_options,
+            window_css:{
+                height: 'initial',
+            },
+            body_css: {
+                width: 'initial',
+                padding: '20px',
+                'background-color': 'rgba(231, 238, 245, .95)',
+                'backdrop-filter': 'blur(3px)',
+            }
+        });
+        // focus to primary btn
+        $(el_window).find('.button-primary').focus();
+
+        // --------------------------------------------------------
+        // Button pressed
+        // --------------------------------------------------------
+        $(el_window).find('.alert-resp-button').on('click',  async function(event){
+            event.preventDefault(); 
+            event.stopPropagation();
+            resolve($(this).attr('data-value'));
+            $(el_window).close();
+            return false;
+        })
+    })
+}
+
+export default UIAlert;

+ 211 - 0
src/UI/UIContextMenu.js

@@ -0,0 +1,211 @@
+function UIContextMenu(options){
+    $('.window-active .window-app-iframe').css('pointer-events', 'none');
+
+    const menu_id = global_element_id++;
+
+    let h = '';
+    h += `<div 
+                id="context-menu-${menu_id}" 
+                data-is-submenu="${options.is_submenu ? 'true' : 'false'}"
+                data-element-id="${menu_id}"
+                data-id="${options.id ?? ''}"
+                ${options.parent_id ? `data-parent-id="${options.parent_id}"` : ``}
+                ${!options.parent_id && options.parent_element ? `data-parent-id="${$(options.parent_element).attr('data-element-id')}"` : ``}
+                class="context-menu context-menu-active ${options.is_submenu ? 'context-menu-submenu-open' : ''}"
+            >`;
+            
+        for(let i=0; i < options.items.length; i++){
+            // item
+            if(!options.items[i].is_divider && options.items[i] !== '-'){
+                // single item
+                if(options.items[i].items === undefined){
+                    h += `<li data-action="${i}" 
+                            class="context-menu-item ${options.items[i].disabled ? ' context-menu-item-disabled' : ''}"
+                            >`;
+                        // icon
+                        h += `<span class="context-menu-item-icon">${options.items[i].icon ?? ''}</span>`;
+                        h += `<span class="context-menu-item-icon-active">${options.items[i].icon_active ?? (options.items[i].icon ?? '')}</span>`;
+                        // label
+                        h += `<span class="contextmenu-label">${options.items[i].html}</span>`;
+                        h += `<span class="contextmenu-label-active">${options.items[i].html_active ?? options.items[i].html}</span>`;
+
+                    h += `</li>`;
+                }
+                // submenu
+                else{
+                    h += `<li data-action="${i}" 
+                              data-menu-id="${menu_id}-${i}"
+                              data-has-submenu="true"
+                              data-parent-element-id="${menu_id}"
+                              class="context-menu-item-submenu context-menu-item${options.items[i].disabled ? ' context-menu-item-disabled' : ''}"
+                            >`;
+                        // icon
+                        h += `<span class="context-menu-item-icon">${options.items[i].icon ?? ''}</span>`;
+                        h += `<span class="context-menu-item-icon-active">${options.items[i].icon_active ?? (options.items[i].icon ?? '')}</span>`;
+                        // label
+                        h += `${html_encode(options.items[i].html)}`;
+                        // arrow
+                        h += `<img class="submenu-arrow" src="${html_encode(window.icons['chevron-right.svg'])}"><img class="submenu-arrow submenu-arrow-active" src="${html_encode(window.icons['chevron-right-active.svg'])}">`;
+                    h += `</li>`;
+                }
+            }
+            // divider
+            else if(options.items[i].is_divider || options.items[i] === '-')
+                h += `<li class="context-menu-divider"><hr></li>`;
+        }
+    h += `</div>`
+    $('body').append(h)
+
+    const contextMenu = document.getElementById(`context-menu-${menu_id}`);
+    const menu_width = $(contextMenu).width();
+    const menu_height = $(contextMenu).outerHeight();
+    let start_x, start_y;
+    //--------------------------------
+    // Auto position
+    //--------------------------------
+    if(!options.position){
+        if(isMobile.phone || isMobile.tablet){
+            start_x = window.last_touch_x;
+            start_y = window.last_touch_y;
+
+        }else{
+            start_x = window.mouseX;
+            start_y = window.mouseY;
+        }
+    }
+    //--------------------------------
+    // custom position
+    //--------------------------------
+    else{
+        start_x = options.position.left;
+        start_y = options.position.top;
+    }
+
+    // X position
+    let x_pos;
+    if( start_x + menu_width > window.innerWidth){
+        x_pos = start_x - menu_width;
+        // if this is a child menu, the width of parent must be also considered
+        if(options.parent_id){
+            x_pos -= $(`.context-menu[data-element-id="${options.parent_id}"]`).width() + 30;
+        }
+    }else
+        x_pos = start_x
+
+    // Y position
+    let y_pos;
+    // is the menu going to go out of the window from the bottom?
+    if( (start_y + menu_height) > (window.innerHeight - taskbar_height - 10))
+        y_pos = window.innerHeight - menu_height - taskbar_height - 10;
+    else
+        y_pos = start_y;
+
+    // Show ContextMenu
+    $(contextMenu).delay(100).show(0)
+    // In the right position (the mouse)
+    .css({
+        top: y_pos + "px",
+        left: x_pos + "px"
+    });
+
+    // mark other context menus as inactive
+    $('.context-menu').not(contextMenu).removeClass('context-menu-active');
+
+    // An item is clicked
+    $(`#context-menu-${menu_id} > li:not(.context-menu-item-disabled)`).on('click', function (e) {
+        
+        // onClick
+        if(options.items[$(this).attr("data-action")].onClick && typeof options.items[$(this).attr("data-action")].onClick === 'function'){
+            let event = e;
+            event.value = options.items[$(this).attr("data-action")]['val'] ?? undefined;
+            options.items[$(this).attr("data-action")].onClick(event);
+        }
+        // close menu and, if exists, its parent
+        if(!$(this).hasClass('context-menu-item-submenu')){
+            $(`#context-menu-${menu_id}, .context-menu[data-element-id="${$(this).closest('.context-menu').attr('data-parent-id')}"]`).fadeOut(200, function(){
+                $(contextMenu).remove();
+            });
+        }
+
+        return false;
+    });
+
+    // when mouse is over an item    
+    $(contextMenu).find('.context-menu-item').on('mouseover', function (e) {
+        // mark other items as inactive
+        $(contextMenu).find('.context-menu-item').removeClass('context-menu-item-active');
+        // mark this item as active
+        $(this).addClass('context-menu-item-active');
+        // close any submenu that doesn't belong to this item
+        $(`.context-menu[data-parent-id="${menu_id}"]`).remove();
+        // mark this context menu as active
+        $(contextMenu).addClass('context-menu-active');
+    })
+
+    // open submenu if applicable
+    $(`#context-menu-${menu_id} > li.context-menu-item-submenu`).on('mouseover', function (e) {
+        
+        // open submenu only if it's not already open
+        if($(`.context-menu[data-id="${menu_id}-${$(this).attr('data-action')}"]`).length === 0){
+            let item_rect_box = this.getBoundingClientRect();
+            
+            // close other submenus
+            $(`.context-menu[parent-element-id="${menu_id}"]`).remove();
+
+            // open the new submenu
+            UIContextMenu({ 
+                items: options.items[parseInt($(this).attr('data-action'))].items,
+                parent_id: menu_id,
+                is_submenu: true,
+                id: menu_id + '-' + $(this).attr('data-action'),
+                position:{
+                    top: item_rect_box.top - 5,
+                    left: x_pos + item_rect_box.width + 15,
+                } 
+            })
+        }
+        return false;    
+    });
+
+    // useful in cases such as where a menue item is over a window, this prevents from the mousedown event
+    // reaching the window underneath
+    $(`#context-menu-${menu_id} > li:not(.context-menu-item-disabled)`).on('mousedown', function (e) {
+        e.preventDefault();
+        e.stopPropagation();
+        return false;
+    })
+
+    //disable parent scroll
+    if(options.parent_element){
+        $(options.parent_element).css('overflow', 'hidden');
+        $(options.parent_element).parent().addClass('children-have-open-contextmenu');
+        $(options.parent_element).addClass('has-open-contextmenu');
+    }
+
+    $(contextMenu).on("remove", function () {
+        // when removing, make parent scrollable again
+        if(options.parent_element){
+            $(options.parent_element).parent().removeClass('children-have-open-contextmenu');
+
+            $(options.parent_element).css('overflow', 'scroll');
+            $(options.parent_element).removeClass('has-open-contextmenu');
+            if($(options.parent_element).hasClass('taskbar-item')){
+                make_taskbar_sortable()
+            }
+        }
+    })
+    $(contextMenu).on("contextmenu", function (e) {
+        e.preventDefault();
+        e.stopPropagation();
+        return false;
+    })    
+}
+
+window.select_ctxmenu_item = function ($ctxmenu_item){
+    // remove active class from other items
+    $($ctxmenu_item).siblings('.context-menu-item').removeClass('context-menu-item-active');
+    // add active class to the selected item
+    $($ctxmenu_item).addClass('context-menu-item-active');
+}
+
+export default UIContextMenu;

+ 1428 - 0
src/UI/UIDesktop.js

@@ -0,0 +1,1428 @@
+import path from "../lib/path.js"
+import UIWindowClaimReferral from "./UIWindowClaimReferral.js"
+import UIContextMenu from './UIContextMenu.js'
+import UIItem from './UIItem.js'
+import UIAlert from './UIAlert.js'
+import UIWindow from './UIWindow.js'
+import UIWindowSaveAccount from './UIWindowSaveAccount.js';
+import UIWindowDesktopBGSettings from "./UIWindowDesktopBGSettings.js"
+import UIWindowMyWebsites from "./UIWindowMyWebsites.js"
+import UIWindowChangePassword from "./UIWindowChangePassword.js"
+import UIWindowChangeUsername from "./UIWindowChangeUsername.js"
+import UIWindowFeedback from "./UIWindowFeedback.js"
+import UIWindowLogin from "./UIWindowLogin.js"
+import UIWindowQR from "./UIWindowQR.js"
+import UIWindowRefer from "./UIWindowRefer.js"
+import UITaskbar from "./UITaskbar.js"
+
+async function UIDesktop(options){
+    let h = '';
+
+    // connect socket.
+    window.socket = io(gui_origin + '/', {
+        query: {
+            auth_token: auth_token
+        }
+    });
+
+    window.socket.on('error', (error) => {
+        console.error('GUI Socket Error:', error);
+    });
+      
+    window.socket.on('connect', function(){
+        console.log('GUI Socket: Connected', window.socket.id);
+    });
+
+    window.socket.on('reconnect', function(){
+        console.log('GUI Socket: Reconnected', window.socket.id);
+    });
+
+    window.socket.on('disconnect', () => {
+        console.log('GUI Socket: Disconnected');
+    });
+
+    window.socket.on('reconnect', (attempt) => {
+        console.log('GUI Socket: Reconnection', attempt);
+    });
+
+    window.socket.on('reconnect_attempt', (attempt) => {
+        console.log('GUI Socket: Reconnection Attemps', attempt);
+    });
+
+    window.socket.on('reconnect_error', (error) => {
+        console.log('GUI Socket: Reconnection Error', error);
+    });
+
+    window.socket.on('reconnect_failed', () => {
+        console.log('GUI Socket: Reconnection Failed');
+    });
+
+    window.socket.on('error', (error) => {
+        console.error('GUI Socket Error:', error);
+    });
+
+    socket.on('upload.progress', (msg) => {
+        if(window.progress_tracker[msg.operation_id]){
+            window.progress_tracker[msg.operation_id].cloud_uploaded += msg.loaded_diff
+            if(window.progress_tracker[msg.operation_id][msg.item_upload_id]){
+                window.progress_tracker[msg.operation_id][msg.item_upload_id].cloud_uploaded = msg.loaded;
+            }
+        }
+    });
+
+    socket.on('download.progress', (msg) => {
+        if(window.progress_tracker[msg.operation_id]){
+            if(window.progress_tracker[msg.operation_id][msg.item_upload_id]){
+                window.progress_tracker[msg.operation_id][msg.item_upload_id].downloaded = msg.loaded;
+                window.progress_tracker[msg.operation_id][msg.item_upload_id].total = msg.total;
+            }
+        }
+    });
+
+    socket.on('trash.is_empty', async (msg) => {
+        $(`.item[data-path="${html_encode(trash_path)}" i]`).find('.item-icon > img').attr('src', msg.is_empty ? window.icons['trash.svg'] : window.icons['trash-full.svg']);
+        $(`.window[data-path="${html_encode(trash_path)}" i]`).find('.window-head-icon').attr('src', msg.is_empty ? window.icons['trash.svg'] : window.icons['trash-full.svg']);
+        // empty trash windows if needed
+        if(msg.is_empty)
+            $(`.window[data-path="${html_encode(trash_path)}" i]`).find('.item-container').empty();
+    })
+
+    socket.on('app.opened', async (app) => {
+        // don't update if this is the original client that initiated the action
+        if(app.original_client_socket_id === window.socket.id)
+            return;
+        
+        // add the app to the beginning of the array
+        launch_apps.recent.unshift(app);
+
+        // dedupe the array by uuid, uid, and id
+        launch_apps.recent = _.uniqBy(launch_apps.recent, 'name');
+
+        // limit to 5
+        launch_apps.recent = launch_apps.recent.slice(0, window.launch_recent_apps_count);  
+    })
+
+    socket.on('item.removed', async (item) => {
+        // don't update if this is the original client that initiated the action
+        if(item.original_client_socket_id === window.socket.id)
+            return;
+
+        // don't remove items if this was a descendants_only operation
+        if(item.descendants_only)
+            return;
+
+        // hide all UIItems with matching uids 
+        $(`.item[data-path='${item.path}']`).fadeOut(150, function(){
+            // close all windows with matching uids
+            // $('.window-' + item.uid).close();
+            // close all windows that belong to a descendant of this item
+            // todo this has to be case-insensitive but the `i` selector doesn't work on ^=
+            $(`.window[data-path^="${item.path}/"]`).close();
+        });
+    })
+
+    socket.on('item.updated', async (item) => {
+        // Don't update if this is the original client that initiated the action
+        if(item.original_client_socket_id === window.socket.id)
+            return;
+
+        // Update matching items
+        // set new item name
+        $(`.item[data-uid='${html_encode(item.uid)}'] .item-name`).html(html_encode(truncate_filename(item.name, TRUNCATE_LENGTH)).replaceAll(' ', '&nbsp;'));
+
+        // Set new icon
+        const new_icon = (item.is_dir ? window.icons['folder.svg'] : (await item_icon(item)).image);
+        $(`.item[data-uid='${item.uid}']`).find('.item-icon-thumb').attr('src', new_icon);
+        $(`.item[data-uid='${item.uid}']`).find('.item-icon-icon').attr('src', new_icon);
+
+        // Set new data-name
+        $(`.item[data-uid='${item.uid}']`).attr('data-name', html_encode(item.name));
+        $(`.window-${item.uid}`).attr('data-name', html_encode(item.name));
+
+        // Set new title attribute
+        $(`.item[data-uid='${item.uid}']`).attr('title', html_encode(item.name));
+        $(`.window-${options.uid}`).attr('title', html_encode(item.name));
+
+        // Set new value for item-name-editor
+        $(`.item[data-uid='${item.uid}'] .item-name-editor`).val(html_encode(item.name));
+        $(`.item[data-uid='${item.uid}'] .item-name`).attr('title', html_encode(item.name));
+
+        // Set new data-path
+        const new_path = item.path;
+        $(`.item[data-uid='${item.uid}']`).attr('data-path', new_path);
+        $(`.window-${item.uid}`).attr('data-path', new_path);
+
+        // Update all elements that have matching paths
+        $(`[data-path="${html_encode(item.old_path)}" i]`).each(function(){            
+            $(this).attr('data-path', new_path)
+            if($(this).hasClass('window-navbar-path-dirname'))
+                $(this).text(item.name);
+        });
+
+        // Update all elements whose paths start with old_path
+        $(`[data-path^="${html_encode(item.old_path) + '/'}"]`).each(function(){    
+            const new_el_path = _.replace($(this).attr('data-path'), item.old_path + '/', new_path+'/');
+            $(this).attr('data-path', new_el_path);
+        });
+
+        // Update all exact-matching windows
+        $(`.window-${item.uid}`).each(function(){
+            update_window_path(this, new_path);
+        })
+        // Set new name for matching open windows
+        $(`.window-${item.uid} .window-head-title`).text(item.name);
+
+        // Re-sort all matching item containers
+        $(`.item[data-uid='${item.uid}']`).parent('.item-container').each(function(){
+            sort_items(this, $(this).closest('.item-container').attr('data-sort_by'), $(this).closest('.item-container').attr('data-sort_order'));
+        })
+    })
+    
+    socket.on('item.moved', async (resp) => {
+        let fsentry = resp;
+        // Notify all apps that are watching this item
+        sendItemChangeEventToWatchingApps(fsentry.uid, {
+            event: 'moved',
+            uid: fsentry.uid,
+            name: fsentry.name,
+        })
+
+        // don't update if this is the original client that initiated the action
+        if(resp.original_client_socket_id === window.socket.id)
+            return;
+
+        let dest_path = path.dirname(fsentry.path);
+        let metadata = fsentry.metadata;
+
+        // path must use the real name from DB
+        fsentry.path =  fsentry.path;
+
+        // update all shortcut_to_path
+        $(`.item[data-shortcut_to_path="${html_encode(resp.old_path)}" i]`).attr(`data-shortcut_to_path`, html_encode(fsentry.path));
+        
+        // remove all items with matching uids
+        $(`.item[data-uid='${fsentry.uid}']`).fadeOut(150, function(){
+            // find all parent windows that contain this item
+            let parent_windows = $(`.item[data-uid='${fsentry.uid}']`).closest('.window');
+            // remove this item
+            $(this).removeItems();
+            // update parent windows' item counts
+            $(parent_windows).each(function(index){
+                update_explorer_footer_item_count(this);
+                update_explorer_footer_selected_items_count(this)
+            });
+        })
+
+        // if trashing, close windows of trashed items and its descendants
+        if(dest_path === trash_path){
+            $(`.window[data-path="${html_encode(resp.old_path)}" i]`).close();
+            // todo this has to be case-insensitive but the `i` selector doesn't work on ^=
+            $(`.window[data-path^="${html_encode(resp.old_path)}/"]`).close();
+        }
+
+        // update all paths of its and its descendants' open windows
+        else{
+            // todo this has to be case-insensitive but the `i` selector doesn't work on ^=
+            $(`.window[data-path^="${html_encode(resp.old_path)}/"], .window[data-path="${html_encode(resp.old_path)}" i]`).each(function(){
+                update_window_path(this, $(this).attr('data-path').replace(resp.old_path, fsentry.path));
+            })
+        }
+
+        if(dest_path === trash_path){
+            $(`.item[data-uid="${fsentry.uid}"]`).find('.item-is-shared').fadeOut(300);
+
+            // if trashing dir... 
+            if(fsentry.is_dir){
+                // remove website badge
+                $(`.mywebsites-dir-path[data-uuid="${fsentry.uid}"]`).remove();
+                // remove the website badge from all instances of the dir
+                $(`.item[data-uid="${fsentry.uid}"]`).find('.item-has-website-badge').fadeOut(300);
+
+                // remove File Rrequest Token
+                // todo, some client-side check to see if this dir has an FR associated with it before sending a whole ajax req
+            }
+        }
+        // if replacing an existing item, remove the old item that was just replaced
+        if(fsentry.overwritten_uid !== undefined)
+            $(`.item[data-uid=${fsentry.overwritten_uid}]`).removeItems();
+
+        // if this is trash, get original name from item metadata
+        fsentry.name = (metadata && metadata.original_name) ? metadata.original_name : fsentry.name;
+
+        // create new item on matching containers
+        UIItem({
+            appendTo: $(`.item-container[data-path='${html_encode(dest_path)}' i]`),
+            immutable: fsentry.immutable,
+            uid: fsentry.uid,
+            path: fsentry.path,
+            icon: await item_icon(fsentry),
+            name: (dest_path === trash_path) ? metadata.original_name : fsentry.name,
+            is_dir: fsentry.is_dir,
+            size: fsentry.size,
+            type: fsentry.type,
+            modified: fsentry.modified,
+            is_selected: false,
+            is_shared: (dest_path === trash_path) ? false : fsentry.is_shared,
+            is_shortcut: fsentry.is_shortcut,
+            shortcut_to: fsentry.shortcut_to,
+            shortcut_to_path: fsentry.shortcut_to_path,
+            // has_website: $(el_item).attr('data-has_website') === '1',
+            metadata: JSON.stringify(fsentry.metadata) ?? '',
+        });
+
+        if(fsentry.parent_dirs_created && fsentry.parent_dirs_created.length > 0){
+            // this operation may have created some missing directories, 
+            // see if any of the directories in the path of this file is new AND
+            // if these new path have any open parents that need to be updated
+                
+            fsentry.parent_dirs_created.forEach(async dir => {
+                let item_container = $(`.item-container[data-path='${html_encode(path.dirname(dir.path))}' i]`);
+                if(item_container.length > 0 && $(`.item[data-path="${html_encode(dir.path)}" i]`).length === 0){
+                    UIItem({
+                        appendTo: item_container,
+                        immutable: false,
+                        uid: dir.uid,
+                        path: dir.path,
+                        icon: await item_icon(dir),
+                        name: dir.name,
+                        size: dir.size,
+                        type: dir.type,
+                        modified: dir.modified,
+                        is_dir: true,
+                        is_selected: false,
+                        is_shared: dir.is_shared,
+                        has_website: false,
+                    });                                                    
+                }                                    
+                sort_items(item_container, $(item_container).attr('data-sort_by'), $(item_container).attr('data-sort_order'));
+            }); 
+        }
+        //sort each container
+        $(`.item-container[data-path='${html_encode(dest_path)}' i]`).each(function(){
+            sort_items(this, $(this).attr('data-sort_by'), $(this).attr('data-sort_order'))
+        })
+    });
+    
+    socket.on('user.email_confirmed', (msg) => {
+        // don't update if this is the original client that initiated the action
+        if(msg.original_client_socket_id === window.socket.id)
+            return;
+
+        refresh_user_data(window.auth_token);
+    });
+
+    socket.on('item.renamed', async (item) => {
+        // Notify all apps that are watching this item
+        sendItemChangeEventToWatchingApps(item.uid, {
+            event: 'rename',
+            uid: item.uid,
+            // path: item.path,
+            new_name: item.name,
+            // old_path: item.old_path,
+        })
+
+        // Don't update if this is the original client that initiated the action
+        if(item.original_client_socket_id === window.socket.id)
+            return;
+
+        // Update matching items
+        // Set new item name
+        $(`.item[data-uid='${html_encode(item.uid)}'] .item-name`).html(html_encode(truncate_filename(item.name, TRUNCATE_LENGTH)).replaceAll(' ', '&nbsp;'));
+
+        // Set new icon
+        const new_icon = (item.is_dir ? window.icons['folder.svg'] : (await item_icon(item)).image);
+        $(`.item[data-uid='${item.uid}']`).find('.item-icon-icon').attr('src', new_icon);
+
+        // Set new data-name
+        $(`.item[data-uid='${item.uid}']`).attr('data-name', html_encode(item.name));
+        $(`.window-${item.uid}`).attr('data-name', html_encode(item.name));
+
+        // Set new title attribute
+        $(`.item[data-uid='${item.uid}']`).attr('title', html_encode(item.name));
+        $(`.window-${options.uid}`).attr('title', html_encode(item.name));
+
+        // Set new value for item-name-editor
+        $(`.item[data-uid='${item.uid}'] .item-name-editor`).val(html_encode(item.name));
+        $(`.item[data-uid='${item.uid}'] .item-name`).attr('title', html_encode(item.name));
+
+        // Set new data-path
+        const new_path = item.path;
+        $(`.item[data-uid='${item.uid}']`).attr('data-path', new_path);
+        $(`.window-${item.uid}`).attr('data-path', new_path);
+
+        // Update all elements that have matching paths
+        $(`[data-path="${html_encode(item.old_path)}" i]`).each(function(){            
+            $(this).attr('data-path', new_path)
+            if($(this).hasClass('window-navbar-path-dirname'))
+                $(this).text(item.name);
+        });
+
+        // Update all elements whose paths start with old_path
+        $(`[data-path^="${html_encode(item.old_path) + '/'}"]`).each(function(){    
+            const new_el_path = _.replace($(this).attr('data-path'), item.old_path + '/', new_path+'/');
+            $(this).attr('data-path', new_el_path);
+        });
+
+        // Update all exact-matching windows
+        $(`.window-${item.uid}`).each(function(){
+            update_window_path(this, new_path);
+        })
+        // Set new name for matching open windows
+        $(`.window-${item.uid} .window-head-title`).text(item.name);
+
+        // Re-sort all matching item containers
+        $(`.item[data-uid='${item.uid}']`).parent('.item-container').each(function(){
+            sort_items(this, $(this).closest('.item-container').attr('data-sort_by'), $(this).closest('.item-container').attr('data-sort_order'));
+        })
+    });
+
+    socket.on('item.added', async (item) => {
+        // if item is empty, don't proceed
+        if(_.isEmpty(item))
+            return;
+
+        // Notify all apps that are watching this item
+        sendItemChangeEventToWatchingApps(item.uid, {
+            event: 'write',
+            uid: item.uid,
+            // path: item.path,
+            new_size: item.size,
+            modified: item.modified,
+            // old_path: item.old_path,
+        });
+
+        // Don't update if this is the original client that initiated the action
+        if(item.original_client_socket_id === window.socket.id)
+            return;
+
+        // Update replaced items with matching uids
+        if(item.overwritten_uid){
+            $(`.item[data-uid='${item.overwritten_uid}']`).attr({
+                'data-immutable': item.immutable,
+                'data-path': item.path,
+                'data-name': item.name,
+                'data-size': item.size,
+                'data-modified': item.modified,
+                'data-is_shared': item.is_shared,
+                'data-type': item.type,
+            })
+            // set new icon
+            const new_icon = (item.is_dir ? window.icons['folder.svg'] : (await item_icon(item)).image);
+            $(`.item[data-uid="${item.overwritten_uid}"]`).find('.item-icon > img').attr('src', new_icon);
+            
+            //sort each window
+            $(`.item-container[data-path='${html_encode(item.dirpath)}' i]`).each(function(){
+                sort_items(this, $(this).attr('data-sort_by'), $(this).attr('data-sort_order'))
+            })            
+        }
+        else{
+            UIItem({
+                appendTo: $(`.item-container[data-path='${html_encode(item.dirpath)}' i]`),
+                uid: item.uid,
+                immutable: item.immutable,
+                associated_app_name: item.associated_app?.name,
+                path: item.path,
+                icon: await item_icon(item),
+                name: item.name,
+                size: item.size,
+                type: item.type,
+                modified: item.modified,
+                is_dir: item.is_dir,
+                is_shared: item.is_shared,
+                is_shortcut: item.is_shortcut,
+                associated_app_name: item.associated_app?.name,
+                shortcut_to: item.shortcut_to,
+                shortcut_to_path: item.shortcut_to_path,
+            });
+
+            //sort each window
+            $(`.item-container[data-path='${html_encode(item.dirpath)}' i]`).each(function(){
+                sort_items(this, $(this).attr('data-sort_by'), $(this).attr('data-sort_order'))
+            })
+        }
+    });
+
+    // Hidden file dialog
+    h += `<form name="upload-form" id="upload-form" style="display:hidden;">
+            <input type="hidden" name="name" id="upload-filename" value="">
+            <input type="hidden" name="path" id="upload-target-path" value="">
+            <input type="file" name="file" id="upload-file-dialog" style="display: none;" multiple="multiple">
+        </form>`;
+    
+    h += `<div class="window-container"></div>`;
+    
+    // Desktop
+    // If desktop is not in fullpage/embedded mode, we hide it until files and directories are loaded and then fade in the UI
+    // This gives a calm and smooth experience for the user
+    h += `<div class="desktop item-container disable-user-select" 
+                data-uid="${options.desktop_fsentry.uid}" 
+                data-sort_by="${!options.desktop_fsentry.sort_by ? 'name' : options.desktop_fsentry.sort_by}" 
+                data-sort_order="${!options.desktop_fsentry.sort_order ? 'asc' : options.desktop_fsentry.sort_order}" 
+                data-path="${html_encode(desktop_path)}"
+            >`;
+    h += `</div>`;
+
+    // Get window sidebar width
+    getItem({
+        key: "window_sidebar_width",
+        success: async function(res){
+            let value = parseInt(res.value);
+            // if value is a valid number
+            if(!isNaN(value) && value > 0){
+                window.window_sidebar_width = value;
+            }
+        }
+    })
+
+    // Remove `?ref=...` from navbar URL
+    if(url_query_params.has('ref')){
+        window.history.pushState(null, document.title, '/');    
+    }
+
+    // Append to <body>
+    $('body').append(h);
+
+    // Set desktop height based on taskbar height
+    $('.desktop').css('height', `calc(100vh - ${window.taskbar_height + window.toolbar_height}px)`)
+
+    // ---------------------------------------------------------------
+    // Taskbar
+    // ---------------------------------------------------------------
+    UITaskbar();
+
+    const el_desktop = document.querySelector('.desktop');
+
+    window.active_element = el_desktop;
+    window.active_item_container = el_desktop;
+    // --------------------------------------------------------
+    // Dragster
+    // Allow dragging of local files onto desktop.
+    // --------------------------------------------------------
+    $(el_desktop).dragster({
+        enter: function (dragsterEvent, event) {
+            $('.context-menu').remove();
+        },
+        leave: function (dragsterEvent, event) {
+        },
+        drop: async function (dragsterEvent, event) {
+            const e = event.originalEvent;
+            // no drop on item
+            if($(event.target).hasClass('item') || $(event.target).parent('.item').length > 0)
+                return false;
+            // recursively create directories and upload files
+            if(e.dataTransfer?.items?.length>0){
+                upload_items(e.dataTransfer.items, desktop_path);
+            }
+
+            e.stopPropagation();
+            e.preventDefault();
+            return false;
+        }
+    });
+
+    // --------------------------------------------------------
+    // Droppable
+    // --------------------------------------------------------
+    $(el_desktop).droppable({
+        accept: '.item',
+        tolerance: "intersect",
+        drop: function( event, ui ) {
+            // Check if item was actually dropped on desktop and not a window
+            if(mouseover_window !== undefined)
+                return;
+    
+            // Can't drop anything but UIItems on desktop
+            if(!$(ui.draggable).hasClass('item'))
+                return;
+    
+            // Don't move an item to its current directory
+            if( path.dirname($(ui.draggable).attr('data-path')) === desktop_path && !event.ctrlKey)
+                return;
+            
+            // If ctrl is pressed and source is Trashed, cancel whole operation
+            if(event.ctrlKey && path.dirname($(ui.draggable).attr('data-path')) === window.trash_path)
+                return;
+
+            // Unselect previously selected items
+            $(el_desktop).children('.item-selected').removeClass('item-selected');
+
+            const items_to_move = []
+            // first item
+            items_to_move.push(ui.draggable);
+
+            // all subsequent items
+            const cloned_items = document.getElementsByClassName('item-selected-clone');
+            for(let i =0; i<cloned_items.length; i++){
+                const source_item = document.getElementById('item-' + $(cloned_items[i]).attr('data-id'));
+                if(source_item !== null)
+                    items_to_move.push(source_item);
+            }
+
+            // if ctrl key is down, copy items
+            if(event.ctrlKey){
+                // unless source is Trash
+                if(path.dirname($(ui.draggable).attr('data-path')) === window.trash_path)
+                    return;
+
+                copy_items(items_to_move, desktop_path)
+            }
+            // otherwise, move items
+            else{
+                move_items(items_to_move, desktop_path);
+            }
+        }
+    });
+
+    //--------------------------------------------------
+    // ContextMenu
+    //--------------------------------------------------
+    $(el_desktop).bind("contextmenu taphold", function (event) {
+        // dismiss taphold on regular devices
+        if(event.type==='taphold' && !isMobile.phone && !isMobile.tablet)
+            return;
+
+        const $target = $(event.target);
+
+        // elements that should retain native ctxmenu
+        if($target.is('input') || $target.is('textarea'))
+            return true
+
+        // custom ctxmenu for all other elements
+        if(event.target === el_desktop){
+            event.preventDefault();
+            UIContextMenu({
+                items: [
+                    // -------------------------------------------
+                    // Sort by
+                    // -------------------------------------------
+                    {
+                        html: "Sort by",
+                        items: [
+                            {
+                                html: `Name`,
+                                icon: $(el_desktop).attr('data-sort_by') === 'name' ? '✓' : '',
+                                onClick: async function(){
+                                    sort_items(el_desktop, 'name', $(el_desktop).attr('data-sort_order'));
+                                    set_sort_by(options.desktop_fsentry.uid, 'name', $(el_desktop).attr('data-sort_order'))
+                                }
+                            },
+                            {
+                                html: `Date modified`,
+                                icon: $(el_desktop).attr('data-sort_by') === 'modified' ? '✓' : '',
+                                onClick: async function(){
+                                    sort_items(el_desktop, 'modified', $(el_desktop).attr('data-sort_order'));
+                                    set_sort_by(options.desktop_fsentry.uid, 'modified', $(el_desktop).attr('data-sort_order'))
+                                }
+                            },
+                            {
+                                html: `Type`,
+                                icon: $(el_desktop).attr('data-sort_by') === 'type' ? '✓' : '',
+                                onClick: async function(){
+                                    sort_items(el_desktop, 'type', $(el_desktop).attr('data-sort_order'));
+                                    set_sort_by(options.desktop_fsentry.uid, 'type', $(el_desktop).attr('data-sort_order'))
+                                }
+                            },
+                            {
+                                html: `Size`,
+                                icon: $(el_desktop).attr('data-sort_by') === 'size' ? '✓' : '',
+                                onClick: async function(){
+                                    sort_items(el_desktop, 'size', $(el_desktop).attr('data-sort_order'));
+                                    set_sort_by(options.desktop_fsentry.uid, 'size', $(el_desktop).attr('data-sort_order'))
+                                }
+                            },
+                            // -------------------------------------------
+                            // -
+                            // -------------------------------------------
+                            '-',
+                            {
+                                html: `Ascending`,
+                                icon: $(el_desktop).attr('data-sort_order') === 'asc' ? '✓' : '',
+                                onClick: async function(){
+                                    const sort_by = $(el_desktop).attr('data-sort_by')
+                                    sort_items(el_desktop, sort_by, 'asc');
+                                    set_sort_by(options.desktop_fsentry.uid, sort_by, 'asc')
+                                }
+                            },
+                            {
+                                html: `Descending`,
+                                icon: $(el_desktop).attr('data-sort_order') === 'desc' ? '✓' : '',
+                                onClick: async function(){
+                                    const sort_by = $(el_desktop).attr('data-sort_by')
+                                    sort_items(el_desktop, sort_by, 'desc');
+                                    set_sort_by(options.desktop_fsentry.uid, sort_by, 'desc')
+                                }
+                            },
+                        ]
+                    },
+                    // -------------------------------------------
+                    // Refresh
+                    // -------------------------------------------
+                    {
+                        html: "Refresh",
+                        onClick: function(){
+                            refresh_item_container(el_desktop);
+                        }
+                    },
+                    // -------------------------------------------
+                    // -
+                    // -------------------------------------------
+                    '-',
+                    // -------------------------------------------
+                    // New File
+                    // -------------------------------------------
+                    window.new_context_menu_item(desktop_path, el_desktop),
+                    // -------------------------------------------
+                    // -
+                    // -------------------------------------------
+                    '-',
+                    // -------------------------------------------
+                    // Paste
+                    // -------------------------------------------
+                    {
+                        html: "Paste",
+                        disabled: clipboard.length > 0 ? false : true,
+                        onClick: function(){
+                            if(clipboard_op === 'copy')
+                                copy_clipboard_items(desktop_path, el_desktop);
+                            else if(clipboard_op === 'move')
+                                move_clipboard_items(el_desktop)
+                        }
+                    },
+                    // -------------------------------------------
+                    // Upload Here
+                    // -------------------------------------------
+                    {
+                        html: "Upload Here",
+                        onClick: function(){
+                            init_upload_using_dialog(el_desktop);
+                        }
+                    },
+                    // -------------------------------------------
+                    // Request Files
+                    // -------------------------------------------
+                    // {
+                    //     html: "Request Files",
+                    //     onClick: function(){
+                    //         UIWindowRequestFiles({dir_path: desktop_path})                       
+                    //     }
+                    // },
+                    // -------------------------------------------
+                    // -
+                    // -------------------------------------------
+                    '-',
+                    // -------------------------------------------
+                    // Change Desktop Background…
+                    // -------------------------------------------
+                    {
+                        html: "Change Desktop Background…",
+                        onClick: function(){
+                            UIWindowDesktopBGSettings();
+                        }
+                    },
+
+                ]
+            });
+        }
+    });
+
+    //-------------------------------------------
+    // Desktop Files/Folders
+    // we don't need to get the desktop items if we're in embedded or fullpage mode
+    // because the items aren't visible anyway and we don't need to waste bandwidth/server resources
+    //-------------------------------------------
+    if(!is_embedded && !window.is_fullpage_mode){
+        refresh_item_container(el_desktop, {fadeInItems: true})
+        window.launch_download_from_url();
+    }
+
+    // -------------------------------------------
+    // Selectable
+    // Only for desktop
+    // -------------------------------------------
+    if(!isMobile.phone && !isMobile.tablet){
+        let selected_ctrl_items = [];
+        const selection = new SelectionArea({
+            selectionContainerClass: '.selection-area-container',
+            container: '.desktop',
+            selectables: ['.desktop.item-container > .item'],
+            startareas: ['.desktop'],
+            boundaries: ['.desktop'],
+            behaviour: {
+                overlap: 'drop',
+                intersect: 'touch',
+                startThreshold: 10,
+                scrolling: {
+                    speedDivider: 10,
+                    manualSpeed: 750,
+                    startScrollMargins: {x: 0, y: 0}
+                }
+            },
+            features: {
+                touch: true,
+                range: true,
+                singleTap: {
+                    allow: true,
+                    intersect: 'native'
+                }
+            }
+        });
+    
+        selection.on('beforestart', ({event}) => {
+            selected_ctrl_items = [];
+            // Returning false prevents a selection
+            return $(event.target).hasClass('item-container');
+        })
+        .on('beforedrag', evt => {
+        })
+        .on('start', ({store, event}) => {
+            if (!event.ctrlKey && !event.metaKey) {
+                for (const el of store.stored) {
+                    el.classList.remove('item-selected');
+                }
+        
+                selection.clearSelection();
+            }
+        })
+        .on('move', ({store: {changed: {added, removed}}, event}) => {
+            for (const el of added) {
+                // if ctrl or meta key is pressed and the item is already selected, then unselect it
+                if((event.ctrlKey || event.metaKey) && $(el).hasClass('item-selected')){
+                    el.classList.remove('item-selected');
+                    selected_ctrl_items.push(el);
+                }
+                // otherwise select it
+                else{
+                    el.classList.add('item-selected');
+                }
+            }
+        
+            for (const el of removed) {
+                el.classList.remove('item-selected');
+                // in case this item was selected by ctrl+click before, then reselect it again
+                if(selected_ctrl_items.includes(el))
+                    $(el).not('.item-disabled').addClass('item-selected');
+            }
+        })
+        .on('stop', evt => {
+        });
+    }
+    // ----------------------------------------------------
+    // User options
+    // ----------------------------------------------------
+    let ht = '';
+    ht += `<div class="toolbar"  style="height:${window.toolbar_height}px;">`;
+        // logo
+        ht += `<div class="toolbar-btn toolbar-puter-logo" title="Puter" style="margin-left: 10px; margin-right: auto;"><img src="${window.icons['logo-white.svg']}" draggable="false" style="display:block; width:17px; height:17px"></div>`;
+        // create account button
+        ht += `<div class="toolbar-btn user-options-create-account-btn ${window.user.is_temp ? '' : 'hidden' }" style="padding:0; opacity:1;" title="Save Account">`;
+            ht += `<svg style="width: 17px; height: 17px;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="48px" height="48px" viewBox="0 0 48 48"><g transform="translate(0, 0)"><path d="M45.521,39.04L27.527,5.134c-1.021-1.948-3.427-2.699-5.375-1.679-.717,.376-1.303,.961-1.679,1.679L2.479,39.04c-.676,1.264-.635,2.791,.108,4.017,.716,1.207,2.017,1.946,3.42,1.943H41.993c1.403,.003,2.704-.736,3.42-1.943,.743-1.226,.784-2.753,.108-4.017ZM23.032,15h1.937c.565,0,1.017,.467,1,1.031l-.438,14c-.017,.54-.459,.969-1,.969h-1.062c-.54,0-.983-.429-1-.969l-.438-14c-.018-.564,.435-1.031,1-1.031Zm.968,25c-1.657,0-3-1.343-3-3s1.343-3,3-3,3,1.343,3,3-1.343,3-3,3Z" fill="#ffbb00"></path></g></svg>`;
+        ht += `</div>`;
+
+        // 'show desktop'
+        if(window.is_fullpage_mode){
+            ht += `<a href="/" class="show-desktop-btn toolbar-btn antialiased" target="_blank" title="Open Desktop">Open Desktop</a>`;
+        }
+
+        // refer
+        if(user.referral_code){
+            ht += `<div class="toolbar-btn refer-btn" title="Refer" style="background-image:url(${window.icons['gift.svg']});"></div>`;
+        }
+
+        // do not show the fullscreen button on mobile devices since it's broken
+        if(!isMobile.phone){
+            // fullscreen button
+            ht += `<div class="toolbar-btn fullscreen-btn" title="Enter Full Screen" style="background-image:url(${window.icons['fullscreen.svg']})"></div>`;
+        }
+
+        // qr code button -- only show if not embedded
+        if(!is_embedded)
+            ht += `<div class="toolbar-btn qr-btn" title="QR code" style="background-image:url(${window.icons['qr.svg']})"></div>`;
+        
+        // user options menu
+        ht += `<div class="toolbar-btn user-options-menu-btn" style="background-image:url(${window.icons['profile.svg']})">`;
+            h += `<span class="user-options-menu-username">${window.user.username}</span>`;
+        ht += `</div>`;
+    ht += `</div>`;
+
+    // prepend toolbar to desktop
+    $(ht).insertBefore(el_desktop);
+
+    // adjust window container to take into account the toolbar height
+    $('.window-container').css('top', window.toolbar_height);
+
+    // ---------------------------------------------
+    // Run apps from insta-login URL
+    // ---------------------------------------------
+    if(url_query_params.has('app')){
+        let url_app_name = url_query_params.get('app');
+        if(url_app_name === 'explorer'){
+            let predefined_path = home_path;
+            if(url_query_params.has('path'))
+                predefined_path =url_query_params.get('path') 
+            // launch explorer
+            UIWindow({
+                path: predefined_path,
+                title: path.basename(predefined_path),
+                icon: await item_icon({is_dir: true, path: predefined_path}),
+                // todo
+                // uid: $(el_item).attr('data-uid'),
+                is_dir: true,
+                // todo
+                // sort_by: $(el_item).attr('data-sort_by'),
+                app: 'explorer',
+            });
+        }
+    }
+    // ---------------------------------------------
+    // load from direct app URLs: /app/app-name
+    // ---------------------------------------------
+    else if(window.app_launched_from_url){
+        let qparams = new URLSearchParams(window.location.search);      
+        if(!qparams.has('c')){
+            launch_app({ 
+                name: app_launched_from_url,
+                readURL: qparams.get('readURL'),
+                maximized: qparams.get('maximized'),
+                is_fullpage: window.is_fullpage_mode,
+                window_options: {
+                    stay_on_top: false,
+                }
+            });
+        }
+    }
+
+    $(el_desktop).on('mousedown touchstart', function(e){
+        // dimiss touchstart on regular devices
+        if(e.type==='taphold' && !isMobile.phone && !isMobile.tablet)
+            return;
+
+        // disable pointer-events for all app iframes, this is to make sure selectable works
+        $('.window-app-iframe').css('pointer-events', 'none');
+        $('.window').find('.item-selected').addClass('item-blurred');
+        $('.desktop').find('.item-blurred').removeClass('item-blurred');
+    })
+
+    $(el_desktop).on('click', function(e){
+        // blur all windows
+        $('.window-active').removeClass('window-active');
+    })  
+
+    function display_ct() {
+        var x = new Date()
+        var ampm = x.getHours( ) >= 12 ? ' PM' : ' AM';
+        let hours = x.getHours( ) % 12;
+        hours = hours ? hours : 12;
+        hours=hours.toString().length==1? 0+hours.toString() : hours;
+        
+        var minutes=x.getMinutes().toString()
+        minutes=minutes.length==1 ? 0+minutes : minutes;
+        
+        var seconds=x.getSeconds().toString()
+        seconds=seconds.length==1 ? 0+seconds : seconds;
+        
+        var month=(x.getMonth() +1).toString();
+        month=month.length==1 ? 0+month : month;
+        
+        var dt=x.getDate().toString();
+        dt=dt.length==1 ? 0+dt : dt;
+        
+        var x1=month + "/" + dt + "/" + x.getFullYear(); 
+        x1 = x1 + " - " +  hours + ":" +  minutes + ":" +  seconds + " " + ampm;
+        $('#clock').html(x1);
+        $('#clock').css('line-height', taskbar_height + 'px');
+    }
+
+    setInterval(display_ct, 1000);
+
+    // show referral notice window
+    if(window.show_referral_notice && !user.email_confirmed){
+        getItem({
+            key: "shown_referral_notice",
+            success: async function(res){
+                if(!res){
+                    setTimeout(() => {
+                        UIWindowClaimReferral();
+                    }, 1000);
+                    setItem({
+                        key: "shown_referral_notice",
+                        value: true,
+                    })
+                }
+            }
+        })
+    }
+
+}
+
+$(document).on('contextmenu taphold', '.taskbar', function(event){
+    // dismiss taphold on regular devices
+    if(event.type==='taphold' && !isMobile.phone && !isMobile.tablet)
+        return;
+
+    event.preventDefault();
+    event.stopPropagation();
+    UIContextMenu({
+        parent_element: $('.taskbar'),
+        items: [
+            //--------------------------------------------------
+            // Show open windows
+            //--------------------------------------------------
+            {
+                html: "Show open windows",
+                onClick: function(){
+                    $(`.window`).showWindow();
+                }
+            },
+            //--------------------------------------------------
+            // Show the desktop
+            //--------------------------------------------------
+            {
+                html: "Show the desktop",
+                onClick: function(){
+                    $(`.window`).hideWindow();
+                }
+            }
+        ]
+    });
+    return false;
+})
+
+$(document).on('click', '.qr-btn', async function (e) {
+    UIWindowQR();
+})
+
+$(document).on('click', '.user-options-menu-btn', async function(e){
+    const pos = this.getBoundingClientRect();
+    if($('.context-menu[data-id="user-options-menu"]').length > 0)
+        return;
+
+    let items = [];
+    let parent_element = this;
+    //--------------------------------------------------
+    // Save Session
+    //--------------------------------------------------
+    if(window.user.is_temp){
+        items.push(            
+            {
+                html: `Save Session`,
+                icon: `<svg style="margin-bottom: -4px; width: 16px; height: 16px;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="48px" height="48px" viewBox="0 0 48 48"><g transform="translate(0, 0)"><path d="M45.521,39.04L27.527,5.134c-1.021-1.948-3.427-2.699-5.375-1.679-.717,.376-1.303,.961-1.679,1.679L2.479,39.04c-.676,1.264-.635,2.791,.108,4.017,.716,1.207,2.017,1.946,3.42,1.943H41.993c1.403,.003,2.704-.736,3.42-1.943,.743-1.226,.784-2.753,.108-4.017ZM23.032,15h1.937c.565,0,1.017,.467,1,1.031l-.438,14c-.017,.54-.459,.969-1,.969h-1.062c-.54,0-.983-.429-1-.969l-.438-14c-.018-.564,.435-1.031,1-1.031Zm.968,25c-1.657,0-3-1.343-3-3s1.343-3,3-3,3,1.343,3,3-1.343,3-3,3Z" fill="#ffbb00"></path></g></svg>`,
+                icon_active: `<svg style="margin-bottom: -4px; width: 16px; height: 16px;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="48px" height="48px" viewBox="0 0 48 48"><g transform="translate(0, 0)"><path d="M45.521,39.04L27.527,5.134c-1.021-1.948-3.427-2.699-5.375-1.679-.717,.376-1.303,.961-1.679,1.679L2.479,39.04c-.676,1.264-.635,2.791,.108,4.017,.716,1.207,2.017,1.946,3.42,1.943H41.993c1.403,.003,2.704-.736,3.42-1.943,.743-1.226,.784-2.753,.108-4.017ZM23.032,15h1.937c.565,0,1.017,.467,1,1.031l-.438,14c-.017,.54-.459,.969-1,.969h-1.062c-.54,0-.983-.429-1-.969l-.438-14c-.018-.564,.435-1.031,1-1.031Zm.968,25c-1.657,0-3-1.343-3-3s1.343-3,3-3,3,1.343,3,3-1.343,3-3,3Z" fill="#ffbb00"></path></g></svg>`,
+                onClick: async function(){
+                    UIWindowSaveAccount({
+                        send_confirmation_code: false,
+                        default_username: window.user.username
+                    });
+                }
+            },
+        )
+        // -------------------------------------------
+        // -
+        // -------------------------------------------
+        items.push('-')
+    }
+
+    // -------------------------------------------
+    // Logged in users
+    // -------------------------------------------
+    if(window.logged_in_users.length > 0){
+        let users_arr = window.logged_in_users;
+
+        // bring logged in user's item to top
+        users_arr.sort(function(x,y){ return x.uuid === window.user.uuid ? -1 : y.uuid == window.user.uuid ? 1 : 0; });
+
+        // create menu items
+        users_arr.forEach(l_user => {
+            items.push(            
+                {
+                    html: l_user.username,
+                    icon: l_user.username === user.username ? '✓' : '',
+                    onClick: async function(val){
+                        // don't reload everything if clicked on already-logged-in user
+                        if(l_user.username === user.username)
+                            return;
+                        // update auth data
+                        update_auth_data(l_user.auth_token, l_user);
+                        // refresh
+                        location.reload();
+                    }
+    
+                },
+            )
+        });
+        // -------------------------------------------
+        // -
+        // -------------------------------------------
+        items.push('-')
+
+        items.push(            
+            {
+                html: 'Add existing account',
+                // icon: l_user.username === user.username ? '✓' : '',
+                onClick: async function(val){
+                    await UIWindowLogin({
+                        reload_on_success: true,
+                        send_confirmation_code: false,
+                        window_options:{
+                            has_head: true
+                        }
+                    });
+                }
+            },
+        )                
+
+        // -------------------------------------------
+        // -
+        // -------------------------------------------
+        items.push('-')
+
+    }
+
+    UIContextMenu({
+        id: 'user-options-menu',
+        parent_element: parent_element,
+        position: {top: pos.top + 28, left: pos.left + pos.width - 15},
+        items: [
+            ...items,
+            //--------------------------------------------------
+            // My Websites
+            //--------------------------------------------------
+            {
+                html: "My Websites",
+                onClick: async function(){
+                    UIWindowMyWebsites();
+                }
+            },
+            //--------------------------------------------------
+            // Change Username
+            //--------------------------------------------------
+            {
+                html: "Change Username",
+                onClick: async function(){
+                    UIWindowChangeUsername();
+                }
+            },
+
+            //--------------------------------------------------
+            // Change Password
+            //--------------------------------------------------
+            {
+                html: "Change Password",
+                onClick: async function(){
+                    UIWindowChangePassword();
+                }
+            },
+            //--------------------------------------------------
+            // Contact Us
+            //--------------------------------------------------
+            {
+                html: "Contact Us",
+                onClick: async function(){
+                    UIWindowFeedback();
+                }
+            },
+            // -------------------------------------------
+            // -
+            // -------------------------------------------
+            '-',
+
+            //--------------------------------------------------
+            // Log Out
+            //--------------------------------------------------
+            {
+                html: "Log Out",
+                onClick: async function(){
+                    // see if there are any open windows, if yes notify user
+                    if($('.window-app').length > 0){
+                        const alert_resp = await UIAlert({
+                            message: `<p>You have open apps. Are you sure you want to log out?</p>`,
+                            buttons:[
+                                {
+                                    label: 'Close Windows and Log Out',
+                                    type: 'primary',
+                                },
+                                {
+                                    label: 'Cancel'
+                                },
+                            ]
+                        })
+                        if(alert_resp === 'Close Windows and Log Out')
+                            logout();
+                    }
+                    // no open windows
+                    else
+                        logout();
+                }
+            },
+        ]
+    });    
+})
+
+$(document).on('click', '.fullscreen-btn', async function (e) {
+    if(!is_fullscreen()) {
+        var elem = document.documentElement;
+        if (elem.requestFullscreen) {
+            elem.requestFullscreen();
+        } else if (elem.webkitRequestFullscreen) { /* Safari */
+            elem.webkitRequestFullscreen();
+        } else if (elem.mozRequestFullScreen) { /* moz */
+            elem.mozRequestFullScreen();
+        } else if (elem.msRequestFullscreen) { /* IE11 */
+            elem.msRequestFullscreen();
+        }
+    }
+    else{
+        if (document.exitFullscreen) {
+            document.exitFullscreen();
+        } else if (document.webkitExitFullscreen) {
+            document.webkitExitFullscreen();
+        } else if (document.mozCancelFullScreen) {
+            document.mozCancelFullScreen();
+        } else if (document.msExitFullscreen) {
+            document.msExitFullscreen();
+        }  
+    }    
+})
+
+$(document).on('click', '.close-launch-popover', function(){
+    $(".launch-popover").closest('.popover').fadeOut(200, function(){
+        $(".launch-popover").closest('.popover').remove();
+    });
+});
+
+$(document).on('click', '.toolbar-puter-logo', function(){
+    // launch the about app
+    launch_app({name: 'about', window_options:{
+        single_instance: true,
+    }});
+})
+
+$(document).on('click', '.user-options-create-account-btn', async function(e){
+    UIWindowSaveAccount({
+        send_confirmation_code: false,
+        default_username: window.user.username,
+    });
+})
+
+$(document).on('click', '.refer-btn', async function(e){
+    UIWindowRefer();
+})
+
+$(document).on('click', '.start-app', async function(e){
+    launch_app({
+        name: $(this).attr('data-app-name')
+    })
+    // close popovers
+    $(".popover").fadeOut(200, function(){
+        $(".popover").remove();
+    });
+})
+
+$(document).on('click', '.user-options-login-btn', async function(e){
+    const alert_resp = await UIAlert({
+        message: `<strong>Save session before exiting!</strong><p>You are in a temporary session and logging into another account will erase all data in your current session.</p>`,
+        buttons:[
+            {
+                label: 'Save session',
+                value: 'save-session',
+                type: 'primary',
+            },
+            {
+                label: 'Log into another account anyway',
+                value: 'login',
+            },
+            {
+                label: 'Cancel'
+            },
+        ]
+    })
+    
+    if(alert_resp === 'save-session'){
+        let saved = await UIWindowSaveAccount({
+            send_confirmation_code: false,
+        });
+        if(saved)
+            UIWindowLogin({show_signup_button: false, reload_on_success: true});
+    }else if (alert_resp === 'login'){
+        UIWindowLogin({
+            show_signup_button: false, 
+            reload_on_success: true,
+            window_options: {
+                backdrop: true,
+                close_on_backdrop_click: false,
+            }
+        });
+    }
+})
+
+$(document).on('click mousedown', '.launch-search, .launch-popover', function(e){
+    $(this).focus();
+    e.stopPropagation();
+    e.preventDefault();
+    // don't let click bubble up to window
+    e.stopImmediatePropagation();
+})
+
+$(document).on('focus', '.launch-search', function(e){
+    // remove all selected items in start menu
+    $('.launch-app-selected').removeClass('launch-app-selected');
+    // scroll popover to top
+    $('.launch-popover').scrollTop(0);
+})
+
+$(document).on('change keyup keypress keydown paste', '.launch-search', function(e){
+    // search launch_apps.recommended for query
+    const query = $(this).val().toLowerCase();
+    if(query === ''){
+        $('.launch-search-clear').hide();
+        $(`.start-app-card`).show();
+        $('.launch-apps-recent').show();
+        $('.start-section-heading').show();
+    }else{
+        $('.launch-apps-recent').hide();
+        $('.start-section-heading').hide();
+        $('.launch-search-clear').show();
+        launch_apps.recommended.forEach((app)=>{
+            if(app.title.toLowerCase().includes(query.toLowerCase())){
+                $(`.start-app-card[data-name="${app.name}"]`).show();
+            }else{
+                $(`.start-app-card[data-name="${app.name}"]`).hide();
+            }
+        })
+    }
+})
+
+$(document).on('click', '.launch-search-clear', function(e){
+    $('.launch-search').val('');
+    $('.launch-search').trigger('change');
+    $('.launch-search').focus();
+})
+
+document.addEventListener('fullscreenchange', (event) => {
+    // document.fullscreenElement will point to the element that
+    // is in fullscreen mode if there is one. If there isn't one,
+    // the value of the property is null.
+    if (document.fullscreenElement) {
+        $('.fullscreen-btn').css('background-image', `url(${window.icons['shrink.svg']})`);
+        $('.fullscreen-btn').attr('title', 'Exit Full Screen');
+        $('#clock').show();
+    } else {
+        $('.fullscreen-btn').css('background-image', `url(${window.icons['fullscreen.svg']})`);
+        $('.fullscreen-btn').attr('title', 'Enter Full Screen');
+        $('#clock').hide();
+    }
+})
+
+window.set_desktop_background = function(options){
+    if(options.fit){
+        let fit = options.fit;
+        if(fit === 'cover' || fit === 'contain'){
+            $('body').css('background-size', fit);
+            $('body').css('background-repeat', `no-repeat`);
+            $('body').css('background-position', `center center`);
+        }
+        else if(fit === 'center'){
+            $('body').css('background-size', 'auto');
+            $('body').css('background-repeat', `no-repeat`);
+            $('body').css('background-position', `center center`);
+        }
+
+        else if( fit === 'repeat'){
+            $('body').css('background-size', `auto`);
+            $('body').css('background-repeat', `repeat`);
+        }
+        window.desktop_bg_fit = fit;
+    }
+
+    if(options.url){
+        $('body').css('background-image', `url(${options.url})`);
+        window.desktop_bg_url = options.url;
+        window.desktop_bg_color = undefined;
+    }
+    else if(options.color){
+        $('body').css({
+            'background-image': `none`,
+            'background-color': options.color,
+        });
+        window.desktop_bg_color = options.color;
+        window.desktop_bg_url = undefined;
+    }
+}
+
+window.update_taskbar = function(){
+    let items = []
+    $('.taskbar-item-sortable[data-keep-in-taskbar="true"]').each(function(index){
+        items.push({
+            name: $( this ).attr('data-app'),
+            type: 'app',
+        })
+    })
+
+    // update taskbar in the server-side
+    $.ajax({
+        url: api_origin + "/update-taskbar-items",
+        type: 'POST',
+        data: JSON.stringify({
+            items: items,
+        }),
+        async: true,
+        contentType: "application/json",
+        headers: {
+            "Authorization": "Bearer "+auth_token
+        },
+    })
+}
+
+window.remove_taskbar_item = function(item){
+    $(item).find('*').fadeOut(100, function(){});
+
+    $(item).animate({width: 0}, 200, function(){
+        $(item).remove();
+    })
+}
+
+window.enter_fullpage_mode = (el_window)=>{
+    $('.taskbar').hide();
+    $(el_window).find('.window-head').hide();
+    $('body').addClass('fullpage-mode');
+    $(el_window).css({
+        width: '100%',
+        height: '100%',
+        top: toolbar_height + 'px',
+        left: 0,
+        'border-radius': 0,
+    });
+}
+
+window.exit_fullpage_mode = (el_window)=>{
+    $('body').removeClass('fullpage-mode');
+    window.taskbar_height = window.default_taskbar_height;
+    $('.taskbar').css('height', window.taskbar_height);
+    $('.taskbar').show();
+    refresh_item_container($('.desktop.item-container'), {fadeInItems: true});
+    $(el_window).removeAttr('data-is_fullpage');
+    if(el_window){
+        reset_window_size_and_position(el_window)
+        $(el_window).find('.window-head').show();
+    }
+
+    // reset dektop height to take into account the taskbar height
+    $('.desktop').css('height', `calc(100vh - ${window.taskbar_height + window.toolbar_height}px)`);
+
+    // hide the 'Show Desktop' button in toolbar
+    $('.show-desktop-btn').hide();
+
+    // refresh desktop background
+    refresh_desktop_background();
+}
+
+window.reset_window_size_and_position = (el_window)=>{
+    $(el_window).css({
+        width: 680,
+        height: 380,
+        'border-radius': window_border_radius,
+        top: 'calc(50% - 190px)',
+        left: 'calc(50% - 340px)',
+    });
+}
+
+export default UIDesktop;

+ 1602 - 0
src/UI/UIItem.js

@@ -0,0 +1,1602 @@
+import UIWindowPublishWebsite from './UIWindowPublishWebsite.js';
+import UIWindowItemProperties from './UIWindowItemProperties.js';
+import UIWindowGetCopyLink from './UIWindowGetCopyLink.js';
+import UIWindowSaveAccount from './UIWindowSaveAccount.js';
+import UIPopover from './UIPopover.js';
+import UIWindowEmailConfirmationRequired from './UIWindowEmailConfirmationRequired.js';
+import UIContextMenu from './UIContextMenu.js'
+import UIAlert from './UIAlert.js'
+import path from "../lib/path.js"
+
+function UIItem(options){
+    const matching_appendto_count = $(options.appendTo).length;
+    if(matching_appendto_count > 1){
+        $(options.appendTo).each(function(){
+            const opts = options;
+            opts.appendTo = this;
+            UIItem(opts);
+        })
+        return;
+    }else if(matching_appendto_count === 0){
+        return;
+    }
+
+    const item_id = global_element_id++;
+    let last_mousedown_ts = 999999999999999;
+    let rename_cancelled = false;
+
+    // set options defaults
+    options.disabled = options.disabled ?? false;
+    options.is_dir = options.is_dir ?? false;
+    options.is_selected = options.is_selected ?? false;
+    options.is_shared = options.is_shared ?? false;
+    options.is_shortcut = options.is_shortcut ?? 0;
+    options.is_trash = options.is_trash ?? false;
+    options.metadata = options.metadata ?? '';
+    options.multiselectable = options.multiselectable ?? true;
+    options.shortcut_to = options.shortcut_to ?? '';
+    options.shortcut_to_path = options.shortcut_to_path ?? '';
+    options.immutable = (options.immutable === false || options.immutable === 0 || options.immutable === undefined ? 0 : 1);
+    options.sort_container_after_append = (options.sort_container_after_append !== undefined ? options.sort_container_after_append : false);
+    const is_shared_with_me = (options.path !== '/'+window.user.username && !options.path.startsWith('/'+window.user.username+'/'));
+
+    let website_url = determine_website_url(options.path);
+
+    // do a quick check to see if the target parent has any file type restrictions
+    const appendto_allowed_file_types = $(options.appendTo).attr('data-allowed_file_types')
+    if(!window.check_fsentry_against_allowed_file_types_string({is_dir: options.is_dir, name:options.name, type:options.type}, appendto_allowed_file_types))
+        options.disabled = true;
+
+    // --------------------------------------------------------
+    // HTML for Item
+    // --------------------------------------------------------
+    let h = '';
+    h += `<div  id="item-${item_id}" 
+                class="item${options.is_selected ? ' item-selected':''} ${options.disabled ? 'item-disabled':''}" 
+                data-id="${item_id}" 
+                data-name="${html_encode(options.name)}" 
+                data-metadata="${html_encode(options.metadata)}" 
+                data-uid="${options.uid}" 
+                data-is_dir="${options.is_dir ? 1 : 0}" 
+                data-is_trash="${options.is_trash ? 1 : 0}"
+                data-has_website="${options.has_website ? 1 : 0 }" 
+                data-website_url = "${website_url ? html_encode(website_url) : ''}"
+                data-immutable="${options.immutable}" 
+                data-is_shortcut = "${options.is_shortcut}"
+                data-shortcut_to = "${html_encode(options.shortcut_to)}"
+                data-shortcut_to_path = "${html_encode(options.shortcut_to_path)}"
+                data-sortable = "${options.sortable ?? 'true'}"
+                data-sort_by = "${html_encode(options.sort_by) ?? 'name'}"
+                data-size = "${options.size ?? ''}"
+                data-type = "${html_encode(options.type) ?? ''}"
+                data-modified = "${options.modified ?? ''}"
+                data-associated_app_name = "${html_encode(options.associated_app_name) ?? ''}"
+                data-path="${html_encode(options.path)}">`;
+
+        // spinner
+        h += `<div class="item-spinner">`;
+        h += `</div>`;
+        // modified
+        h += `<div class="item-attr item-attr--modified">`;
+            h += `<span>${options.modified === 0 ? '-' : timeago.format(options.modified*1000)}</span>`;
+        h += `</div>`;
+        // size
+        h += `<div class="item-attr item-attr--size">`;
+            h += `<span>${options.size ? byte_format(options.size) : '-'}</span>`;
+        h += `</div>`;
+        // type
+        h += `<div class="item-attr item-attr--type">`;
+            if(options.is_dir)
+                h += `<span>Folder</span>`;
+            else
+                h += `<span>${options.type ? html_encode(options.type) : '-'}</span>`;
+        h += `</div>`;
+
+
+        // icon
+        h += `<div class="item-icon">`;
+            h += `<img src="${html_encode(options.icon.image)}" class="item-icon-${options.icon.type}" data-item-id="${item_id}">`;
+        h += `</div>`;
+        // badges
+        h += `<div class="item-badges">`;
+            // website badge
+            h += `<img  class="item-badge item-has-website-badge long-hover" 
+                        style="${options.has_website ? 'display:block;' : ''}" 
+                        src="${html_encode(window.icons['world.svg'])}" 
+                        data-item-id="${item_id}"
+                    >`;
+            // link badge
+            h += `<img  class="item-badge item-has-website-url-badge" 
+                        style="${website_url ? 'display:block;' : ''}" 
+                        src="${html_encode(window.icons['link.svg'])}" 
+                        data-item-id="${item_id}"
+                    >`;
+
+            // shared badge
+            h += `<img  class="item-badge item-badge-has-permission" 
+                        style="display: ${ is_shared_with_me ? 'block' : 'none'};
+                            background-color: #ffffff;
+                            padding: 2px;" src="${html_encode(window.icons['shared.svg'])}" 
+                        data-item-id="${item_id}"
+                        title="A user has shared this item with you.">`;
+            // owner-shared badge
+            h += `<img  class="item-badge item-is-shared" 
+                        style="background-color: #ffffff; padding: 2px; ${!is_shared_with_me && options.is_shared ? 'display:block;' : ''}" 
+                        src="${html_encode(window.icons['owner-shared.svg'])}" 
+                        data-item-id="${item_id}"
+                        data-item-uid="${options.uid}"
+                        data-item-path="${html_encode(options.path)}"
+                        title="You have shared this item with at least one other user."
+                    >`;
+            // shortcut badge
+            h += `<img  class="item-badge item-shortcut" 
+                        style="background-color: #ffffff; padding: 2px; ${options.is_shortcut !== 0 ? 'display:block;' : ''}" 
+                        src="${html_encode(window.icons['shortcut.svg'])}" 
+                        data-item-id="${item_id}"
+                        title="Shortcut"
+                    >`;
+
+        h += `</div>`;
+
+        // name
+        h += `<span class="item-name" data-item-id="${item_id}" title="${html_encode(options.name)}">${html_encode(truncate_filename(options.name, TRUNCATE_LENGTH)).replaceAll(' ', '&nbsp;')}</span>`
+        // name editor
+        h += `<textarea class="item-name-editor hide-scrollbar" spellcheck="false" autocomplete="off" autocorrect="off" autocapitalize="off" data-gramm_editor="false">${html_encode(options.name)}</textarea>`
+    h += `</div>`;
+
+    // append to options.appendTo
+    $(options.appendTo).append(h);
+
+    // updte item_container
+    const item_container = $(options.appendTo).closest('.item-container');
+    show_or_hide_empty_folder_message(item_container);
+
+    // get all the elements needed
+    const el_item = document.getElementById(`item-${item_id}`);
+    const el_item_name = document.querySelector(`#item-${item_id} > .item-name`);
+    const el_item_icon = document.querySelector(`#item-${item_id} .item-icon`);
+    const el_item_name_editor = document.querySelector(`#item-${item_id} > .item-name-editor`);
+    const is_trashed = $(el_item).attr('data-path').startsWith(trash_path + '/');
+
+    // update parent window's explorer item count if applicable
+    if(options.appendTo !== undefined){
+        let el_window = options.appendTo;
+        if(!$(el_window).hasClass('.window'))
+            el_window = $(el_window).closest('.window');
+
+        update_explorer_footer_item_count(el_window);
+    }
+
+    // --------------------------------------------------------
+    // Dragster
+    // allow dragging of local files on this window, if it's is_dir
+    // --------------------------------------------------------
+    if(options.is_dir){
+        $(el_item).dragster({
+            enter: function () {
+                $(el_item).not('.item-disabled').addClass('item-selected');
+            },
+            leave: function () {
+                $(el_item).removeClass('item-selected');
+            },
+            drop: function (dragsterEvent, event) {
+                const e = event.originalEvent;        
+                $(el_item).removeClass('item-selected');
+                // if files were dropped...
+                if(e.dataTransfer?.items?.length > 0){
+                    upload_items( e.dataTransfer.items, $(el_item).attr('data-path'))
+                }
+
+                e.stopPropagation();
+                e.preventDefault();
+                return false;
+            }
+        });
+    }
+
+    // --------------------------------------------------------
+    // Draggable
+    // --------------------------------------------------------
+    let longer_hover_timeout;
+    let last_window_dragged_over;
+
+    $(el_item).draggable({
+        appendTo: "body",
+        helper: "clone",
+        revert: "invalid",
+        //containment: "document",
+        zIndex: 10000,
+        scroll:false,
+        distance: 5,
+        revertDuration: 100,
+        start: function(event, ui) {
+            // select this item and its helper
+            $(el_item).addClass('item-selected');
+            $('.ui-draggable-dragging').addClass('item-selected');
+            //clone other selected items
+            $(el_item)
+                .siblings('.item-selected')
+                .clone()
+                .addClass('item-selected-clone')
+                .css('position', 'absolute')
+                .appendTo('body')
+                .hide();
+
+            // Bring item and clones to front
+            $('.item-selected-clone, .ui-draggable-dragging').css('z-index', 99999);
+
+            // count badge
+            const item_count = $('.item-selected-clone').length;
+            if(item_count > 0){
+                $('body').append(`<span class="draggable-count-badge">${item_count + 1}</span>`);
+            }
+
+            // Disable all droppable UIItems that are not a dir/app to avoid accidental cancellation
+            // on Items that are not droppables. In general if an item is dropped on another, if the
+            // target is not a dir, the source needs to be dropped on the target's container.
+            $(`.item[data-is_dir="0"][data-associated_app_name=""]:not(.item-selected)`).droppable('disable');
+
+            // Disable pointer events on all app iframes. This is needed because as soon as
+            // a dragging event enters the iframe the event is delegated to iframe which makes the item
+            // stuck at the edge of the iframe not allowing us to move items freely across the screen
+            $('.window-app-iframe').css('pointer-events', 'none')
+
+            // reset longer hover timeout and last window dragged over
+            longer_hover_timeout = null;
+            last_window_dragged_over = null;
+        },
+        drag: function(event, ui) {     
+            // Only show drag helpers if the item has been moved more than 5px
+            if( Math.abs(ui.originalPosition.top - ui.offset.top) > 5
+            ||
+            Math.abs(ui.originalPosition.left - ui.offset.left) > 5 ){
+                $('.ui-draggable-dragging').show();
+                $('.item-selected-clone').show();
+                $('.draggable-count-badge').show();
+            }  
+      
+            const other_selected_items = $('.item-selected-clone');
+            const item_count = other_selected_items.length + 1;
+
+            // Move count badge with mouse
+            $('.draggable-count-badge').css({
+                top: event.pageY,
+                left: event.pageX + 10,
+            })
+
+            // Move other selected items
+            for(let i=0; i < item_count - 1; i++){
+                $(other_selected_items[i]).css({
+                    'left': ui.position.left + 3 * (i+1),
+                    'top': ui.position.top + 3 * (i+1),
+                    'z-index': 999 - (i),
+                    'opacity': 0.5 - i*0.1,
+                })
+            }
+
+            // remove all item-container active borders
+            $('.item-container').removeClass('item-container-active');
+
+            // if item has changed container, remove timeout for window focus and reset last target
+            if(longer_hover_timeout && last_window_dragged_over !== window.mouseover_window){
+                clearTimeout(longer_hover_timeout);
+                longer_hover_timeout = null;
+                last_window_dragged_over = window.mouseover_window;
+            }
+
+            // if item hover for more than 1.2s, focus the window
+            if(!longer_hover_timeout){
+                longer_hover_timeout = setTimeout(() => {
+                    $(last_window_dragged_over).focusWindow();
+                }, 1200);
+            }
+
+            // Highlight item container to help user see more clearly where the item is going to be dropped
+            if($(window.mouseover_item_container).closest('.window').is(window.mouseover_window) && 
+                // do not highlight if the target is the same as the item being moved
+                $(el_item).attr('data-path') !== $(window.mouseover_item_container).attr('data-path') &&
+                // do not highlight if item is being moved to where it already is
+                $(el_item).attr('data-path') !== $(window.mouseover_item_container).attr('data-path')){
+
+                // highlight item container
+                $(window.mouseover_item_container).addClass('item-container-active');
+            }
+
+            // send drag event to iframe if mouse is inside iframe
+            if(mouseover_window){
+                const $app_iframe = $(mouseover_window).find('.window-app-iframe');
+                if(!$(mouseover_window).hasClass('window-disabled') && $app_iframe.length > 0){
+                    var rect = $app_iframe.get(0).getBoundingClientRect();
+                    // if mouse is inside iframe, send drag message to iframe
+                    if(mouseX > rect.left && mouseX < rect.right && mouseY > rect.top && mouseY < rect.bottom){
+                        $app_iframe.get(0).contentWindow.postMessage({msg: "drag", x: (mouseX - rect.left), y: (mouseY - rect.top)}, '*');
+                    }
+                }
+            }
+        },
+        stop: function(event, ui){
+            $('.item-selected-clone').remove();
+            $('.draggable-count-badge').remove();
+            // re-enable all droppable UIItems that are not a dir
+            $(`.item[data-is_dir='0']:not(.item-selected)`).droppable('enable');
+            // remove active item-container border highlights
+            $('.item-container').removeClass('item-container-active');
+            // reset longer hover timeout and last window dragged over
+            clearTimeout(longer_hover_timeout);
+            last_window_dragged_over = null;
+        }
+    });
+
+    // --------------------------------------------------------
+    // Droppable
+    // --------------------------------------------------------
+    $(el_item).droppable({
+        accept: '.item',
+        // 'pointer' is very important because of active window tracking is based on the position of cursor.
+        tolerance: 'pointer',
+        drop: async function( event, ui ) {
+            // Check if hovering over an item that is VISIBILE
+            if($(event.target).closest('.window').attr('data-id') !== $(mouseover_window).attr('data-id'))
+                return;
+
+            // If ctrl is pressed and source is Trashed, cancel whole operation
+            if(event.ctrlKey && path.dirname($(ui.draggable).attr('data-path')) === window.trash_path)
+                return;
+
+            const items_to_move = []
+            
+            // First item
+            items_to_move.push(ui.draggable); 
+            
+            // All subsequent items
+            const cloned_items = document.getElementsByClassName('item-selected-clone');
+            for(let i =0; i<cloned_items.length; i++){
+                const source_item = document.getElementById('item-' + $(cloned_items[i]).attr('data-id'));
+                if(source_item !== null)
+                    items_to_move.push(source_item);
+            }
+
+            // --------------------------------------------------------
+            // If dropped on an app, open the app with the dropped 
+            // items as argument
+            //--------------------------------------------------------
+            if(options.associated_app_name){
+                // an array that hold the items to sign
+                const items_to_open = [];
+
+                // prepare items to sign
+                for(let i=0; i < items_to_move.length; i++){
+                    items_to_open.push({
+                        name: $(items_to_move[i]).attr('data-name'),
+                        uid: $(items_to_move[i]).attr('data-uid'), 
+                        action: 'write', 
+                        path: $(items_to_move[i]).attr('data-path')
+                    });
+                }
+
+                // open each item
+                for (let i = 0; i < items_to_open.length; i++) {
+                    const item = items_to_open[i];
+                    launch_app({ 
+                        name: options.associated_app_name, 
+                        file_path: item.path,
+                        // app_obj: open_item_meta.suggested_apps[0],
+                        window_title: item.name,
+                        file_uid: item.uid,
+                        file_signature: item,
+                    });
+                }
+
+                // deselect dragged item
+                for(let i=0; i < items_to_move.length; i++)
+                    $(items_to_move[i]).removeClass('item-selected');
+            }
+            //--------------------------------------------------------
+            // If dropped on a directory, move items to that directory
+            //--------------------------------------------------------
+            else{
+                // If ctrl key is down, copy items. Except if target or source is Trash
+                if(event.ctrlKey){
+                    if(options.is_dir && $(el_item).attr('data-path') !== window.trash_path )
+                        copy_items(items_to_move, $(el_item).attr('data-path'))
+                    else if(!options.is_dir)
+                        copy_items(items_to_move, path.dirname($(el_item).attr('data-path')));
+                }
+                // If alt key is down, create shortcut items
+                else if(event.altKey && window.feature_flags.create_shortcut){
+                    items_to_move.forEach((item_to_move) => {
+                        create_shortcut(
+                            path.basename($(item_to_move).attr('data-path')), 
+                            $(item_to_move).attr('data-is_dir') === '1', 
+                            options.is_dir ? $(el_item).attr('data-path') : path.dirname($(el_item).attr('data-path')), 
+                            null, 
+                            $(item_to_move).attr('data-shortcut_to') === '' ? $(item_to_move).attr('data-uid') : $(item_to_move).attr('data-shortcut_to'),
+                            $(item_to_move).attr('data-shortcut_to_path') === '' ? $(item_to_move).attr('data-path') : $(item_to_move).attr('data-shortcut_to_path'),
+                        );
+                    });
+                }
+                // Otherwise, move items
+                else if(options.is_dir){
+                    move_items(items_to_move, $(el_item).attr('data-shortcut_to_path') !== '' ? $(el_item).attr('data-shortcut_to_path') : $(el_item).attr('data-path'));
+                }
+            }
+
+            // Re-enable droppable on all 'item-container's
+            $('.item-container').droppable('enable')
+
+            return false;
+        },
+        over: function(event, ui){
+            // Check hovering over an item that is VISIBILE
+            const $event_parent_win = $(event.target).closest('.window')
+            if( $event_parent_win.length > 0 && $event_parent_win.attr('data-id') !== $(mouseover_window).attr('data-id'))
+                return;
+            // Don't do anything if the dragged item is NOT a UIItem
+            if(!$(ui.draggable).hasClass('item'))
+                return;
+            // If this is a directory or an app, and an item was dragged over it, highlight it.
+            if(options.is_dir || options.associated_app_name){
+                $(el_item).addClass('item-selected');
+                $('.ui-draggable-dragging .item-name, .item-selected-clone .item-name').css('opacity', 0.1)
+                // remove all item-container active borders
+                $('.item-container').addClass('item-container-transparent-border')
+            }
+            // Disable all window bodies 
+            $('.item-container').droppable( 'disable' )
+        },
+        out: function(event, ui){
+            // Don't do anything if the dragged item is NOT a UIItem
+            if(!$(ui.draggable).hasClass('item'))
+                return;
+
+            // Unselect directory/app if item is dragged out
+            if(options.is_dir || options.associated_app_name){
+                $(el_item).removeClass('item-selected');
+                $('.ui-draggable-dragging .item-name, .item-selected-clone .item-name').css('opacity', 'initial')
+                $('.item-container').removeClass('item-container-transparent-border')
+            }
+            $('.item-container').droppable( 'enable' )    
+        }
+    });
+
+    // --------------------------------------------------------
+    // Double Click/Single Tap on Item
+    // --------------------------------------------------------
+    if(isMobile.phone || isMobile.tablet){
+        $(el_item).on('click', async function (e) {
+            // if item is disabled, do not allow any action
+            if($(el_item).hasClass('item-disabled'))
+                return false;
+
+            if($(e.target).hasClass('item-name-editor'))
+                return false;
+    
+            open_item({
+                item: el_item, 
+                maximized: true,
+            });
+        });
+    
+    }else{
+        $(el_item).on('dblclick', async function (e) {
+            // if item is disabled, do not allow any action
+            if($(el_item).hasClass('item-disabled'))
+                return false;
+
+            if($(e.target).hasClass('item-name-editor'))
+                return false;
+    
+            open_item({
+                item: el_item, 
+                new_window: e.metaKey || e.ctrlKey,
+            });
+        });
+    }
+    
+    // --------------------------------------------------------
+    // Mousedown
+    // --------------------------------------------------------
+    $(el_item).on('mousedown', function (e) {
+        // if item is disabled, do not allow any action
+        if($(el_item).hasClass('item-disabled'))
+            return false;
+        
+        // if link badge is clicked, don't continue
+        if($(e.target).hasClass('item-has-website-url-badge'))
+            return false;
+
+        const $el_parent_window = $(el_item).closest('.window');
+
+        // first see if this is a ContextMenu call on multiple items
+        if(e.which === 3 && $(el_item).hasClass('item-selected') && $(el_item).siblings('.item-selected').length > 0){
+            $(".context-menu").remove();
+            return false;
+        }
+
+        // unselect other items if neither CTRL nor Command key are held
+        // or
+        // if parent is not multiselectable
+        if((!e.ctrlKey && !e.metaKey && !$(this).hasClass('item-selected')) || ($el_parent_window.length>0 && $el_parent_window.attr('data-multiselectable') !== 'true')){
+            $(this).closest('.item-container').find('.item-selected').removeClass('item-selected');
+        }
+        if((e.ctrlKey || e.metaKey) && $(this).hasClass('item-selected')){
+            $(this).removeClass('item-selected')
+        }
+        else{
+            $(this).addClass('item-selected')
+        }
+        update_explorer_footer_selected_items_count($el_parent_window)
+    });
+    // --------------------------------------------------------
+    // Click
+    // --------------------------------------------------------
+    $(el_item).on('click', function (e) {
+        // if item is disabled, do not allow any action
+        if($(el_item).hasClass('item-disabled'))
+            return false;
+
+        skip_a_rename_click = false;
+        const $el_parent_window = $(el_item).closest('.window');
+        
+        // do not unselect other items if:
+        // CTRL/Command key is pressed or clicking an item that is already selected
+        if(!e.ctrlKey && !e.metaKey){
+            $(this).closest('.item-container').find('.item-selected').not(this).removeClass('item-selected');
+            update_explorer_footer_selected_items_count($el_parent_window)
+        }
+        //----------------------------------------------------------------
+        // On an OpenFileDialog?
+        //----------------------------------------------------------------
+        if($el_parent_window.attr('data-is_openFileDialog') === 'true'){
+            if(!options.is_dir)
+                $el_parent_window.find('.openfiledialog-open-btn').removeClass('disabled');
+            else
+                $el_parent_window.find('.openfiledialog-open-btn').addClass('disabled');
+        }
+        //----------------------------------------------------------------
+        // On a SaveFileDialog?
+        //----------------------------------------------------------------
+        if($el_parent_window.attr('data-is_saveFileDialog') === 'true' && !options.is_dir){
+            $el_parent_window.find('.savefiledialog-filename').val($(el_item).attr('data-name'));
+            $el_parent_window.find('.savefiledialog-save-btn').removeClass('disabled');
+        }
+    });
+
+    $(document).on('click', function(e){
+        if(!$(e.target).hasClass('item') && !$(e.target).hasClass('item-name') && !$(e.target).hasClass('item-icon')){
+            skip_a_rename_click = true;
+        }
+
+        if($(e.target).parents('.item').data('id') !== item_id){
+            skip_a_rename_click = true;
+        }
+    })
+
+    // --------------------------------------------------------
+    // Rename
+    // --------------------------------------------------------
+    function rename(){
+        if(rename_cancelled){
+            rename_cancelled = false;
+            return;
+        }
+
+        const old_name = $(el_item).attr('data-name');
+        const old_path = $(el_item).attr('data-path');
+        const new_name = $(el_item_name_editor).val();
+
+        // Don't send a rename request if:
+        // the new name is the same as the old one, 
+        // or it's empty,
+        // or editable was not even active at all
+        if(old_name === new_name || !new_name || new_name === '.' || new_name === '..' || !$(el_item_name_editor).hasClass('item-name-editor-active')){
+            if(new_name === '.'){
+                UIAlert(`The name "." is not allowed, because it is a reserved name. Please choose another name.`);
+            }
+            else if(new_name === '..'){
+                UIAlert(`The name ".." is not allowed, because it is a reserved name. Please choose another name.`)
+            }
+
+            $(el_item_name).html(truncate_filename(options.name, TRUNCATE_LENGTH).replaceAll(' ', '&nbsp;'));
+            $(el_item_name).show();
+            $(el_item_name_editor).val($(el_item).attr('data-name'));
+            $(el_item_name_editor).hide();
+            return;
+        }
+        // deactivate item name editable
+        $(el_item_name_editor).removeClass('item-name-editor-active');
+
+        // Perform rename request
+        puter.fs.rename({
+            uid: options.uid === 'null' ? null : options.uid,
+            new_name: new_name,
+            excludeSocketID: window.socket.id,
+            success: async (fsentry)=>{
+                // Has the extension changed? in that case update options.sugggested_apps
+                const old_extension = path.extname(old_name); 
+                const new_extension = path.extname(new_name);
+                if(old_extension !== new_extension){
+                    suggest_apps_for_fsentry({
+                        uid: options.uid,
+                        onSuccess: function(suggested_apps){
+                            options.suggested_apps = suggested_apps;
+                        }
+                    });
+                }
+
+                // Set new item name
+                $(`.item[data-uid='${$(el_item).attr('data-uid')}'] .item-name`).html(html_encode(truncate_filename(new_name, TRUNCATE_LENGTH)).replaceAll(' ', '&nbsp;'));
+                $(el_item_name).show();
+
+                // Hide item name editor
+                $(el_item_name_editor).hide();
+
+                // Set new icon
+                const new_icon = (options.is_dir ? window.icons['folder.svg'] : (await item_icon(fsentry)).image);
+                $(el_item_icon).find('.item-icon-icon').attr('src', new_icon);
+
+                // Set new data-name
+                options.name = new_name;
+                $(el_item).attr('data-name', html_encode(new_name));
+                $(`.item[data-uid='${$(el_item).attr('data-uid')}']`).attr('data-name', html_encode(new_name));
+                $(`.window-${options.uid}`).attr('data-name', html_encode(new_name));
+
+                // Set new title attribute
+                $(`.item[data-uid='${$(el_item).attr('data-uid')}']`).attr('title', html_encode(new_name));
+                $(`.window-${options.uid}`).attr('title', html_encode(new_name));
+
+                // Set new value for item-name-editor
+                $(`.item[data-uid='${$(el_item).attr('data-uid')}'] .item-name-editor`).val(html_encode(new_name));
+                $(`.item[data-uid='${$(el_item).attr('data-uid')}'] .item-name`).attr('title', html_encode(new_name));
+
+                // Set new data-path
+                options.path = path.join( path.dirname(options.path), options.name);
+                const new_path = options.path;
+                $(el_item).attr('data-path', new_path);
+                $(`.item[data-uid='${$(el_item).attr('data-uid')}']`).attr('data-path', new_path);
+                $(`.window-${options.uid}`).attr('data-path', new_path);
+
+                // Update all elements that have matching paths
+                $(`[data-path="${html_encode(old_path)}" i]`).each(function(){
+                    $(this).attr('data-path', new_path)
+                    if($(this).hasClass('window-navbar-path-dirname'))
+                        $(this).text(new_name);
+                });
+
+                // Update the paths of all elements whose paths start with old_path
+                $(`[data-path^="${html_encode(old_path) + '/'}"]`).each(function(){
+                    const new_el_path = _.replace($(this).attr('data-path'), old_path + '/', new_path+'/');
+                    $(this).attr('data-path', new_el_path);
+                });
+
+                // Update the 'Sites Cache'
+                if($(el_item).attr('data-has_website') === '1')
+                    await update_sites_cache();
+
+                // Update website_url
+                website_url = determine_website_url(new_path);
+                $(el_item).attr('data-website_url', website_url);
+
+                // Update all exact-matching windows
+                $(`.window-${options.uid}`).each(function(){
+                    update_window_path(this, options.path);
+                })
+
+                // Set new name for corresponding open windows
+                $(`.window-${options.uid} .window-head-title`).text(new_name);
+
+                // Re-sort all matching item containers
+                $(`.item[data-uid='${$(el_item).attr('data-uid')}']`).parent('.item-container').each(function(){
+                    sort_items(this, $(el_item).closest('.item-container').attr('data-sort_by'), $(el_item).closest('.item-container').attr('data-sort_order'));
+                })
+            },
+            error: function (err){
+                // reset to old name
+                $(el_item_name).text(truncate_filename(options.name, TRUNCATE_LENGTH));
+                $(el_item_name).show();
+
+                // hide item name editor
+                $(el_item_name_editor).hide();
+                $(el_item_name_editor).val(html_encode($(el_item).attr('data-name')));
+
+                //show error
+                if(err.message){
+                    UIAlert(err.message)
+                }
+            },
+        });
+    }
+    
+    // --------------------------------------------------------
+    // Rename if enter pressed on Item Name Editor
+    // --------------------------------------------------------
+    $(el_item_name_editor).on('keypress',function(e) {
+        // If name editor is not active don't continue
+        if(!$(el_item_name_editor).is(":visible"))
+            return;
+
+        // Enter key = rename
+        if(e.which === 13) {
+            e.stopPropagation();
+            e.preventDefault();
+            $(el_item_name_editor).blur();
+            $(el_item).addClass('item-selected');
+            last_enter_pressed_to_rename_ts = Date.now();
+            update_explorer_footer_selected_items_count($(el_item).closest('.item-container'));
+            return false;
+        }
+    })
+
+    // --------------------------------------------------------
+    // Cancel and undo if escape pressed on Item Name Editor
+    // --------------------------------------------------------
+    $(el_item_name_editor).on('keyup',function(e) {
+        if(!$(el_item_name_editor).is(":visible"))
+            return;
+
+        // Escape = undo rename
+        else if(e.which === 27){
+            e.stopPropagation();
+            e.preventDefault();
+            rename_cancelled = true;
+            $(el_item_name_editor).hide();
+            $(el_item_name_editor).val(options.name);
+            $(el_item_name).show();
+        }
+    });
+
+    $(el_item_name_editor).on('focusout',function(e) {
+        e.stopPropagation();
+        e.preventDefault();
+        rename();
+    });
+
+    /************************************************
+     *  Takes care of 'click to edit item name'
+     ************************************************/
+    let skip_a_rename_click = true;
+    $(el_item_name).on('click', function(e){
+        if( !skip_a_rename_click && e.which !== 3 && $(el_item_name).parent('.item-selected').length > 0){
+            last_mousedown_ts = Date.now();       
+            setTimeout(() => {
+                if(!skip_a_rename_click && (Date.now() - last_mousedown_ts) > 400){
+                    if (!e.ctrlKey && !e.metaKey)
+                        activate_item_name_editor(el_item)
+                    last_mousedown_ts = 0
+                }else{
+                    last_mousedown_ts = Date.now() + 500;
+                    skip_a_rename_click= false;
+                }
+            }, 500);
+        }
+        skip_a_rename_click = false;
+    })
+    $(el_item_name).on('dblclick', function(e){
+        skip_a_rename_click = true;
+    })
+
+    // --------------------------------------------------------
+    // ContextMenu
+    // --------------------------------------------------------
+    $(el_item).bind("contextmenu taphold", async function (event) {
+        // if item is disabled, do not allow any action
+        if($(el_item).hasClass('item-disabled'))
+            return false;
+
+        // if on website link badge, don't continue
+        if($(event.target).hasClass('item-has-website-url-badge'))
+            return false;
+
+        // dimiss taphold on regular devices
+        if(event.type==='taphold' && !isMobile.phone && !isMobile.tablet)
+            return;
+
+        // if editing item name, preserve native context menu
+        if(event.target === el_item_name_editor)
+            return;
+
+        // if ctrl is pressed don't open ctxmenu, ctrl is for drag and copy
+        if(event.ctrlKey)
+            return false;
+
+        event.preventDefault();
+        let menu_items;
+        const $selected_items = $(el_item).closest('.item-container').find('.item-selected').not(el_item).addBack();
+        // -------------------------------------------------------
+        // Multiple items selected
+        // -------------------------------------------------------
+        if($selected_items.length > 1){
+            const are_trashed = $selected_items.attr('data-path').startsWith(trash_path + '/');
+            menu_items = []
+            // -------------------------------------------
+            // Restore
+            // -------------------------------------------
+            if(are_trashed){
+                menu_items.push({
+                    html: "Restore",
+                    onClick: function(){
+                        $selected_items.each(function() {
+                            const ell = this;
+                            let metadata = $(ell).attr('data-metadata') === '' ? {} : JSON.parse($(ell).attr('data-metadata'))
+                            move_items([ell], path.dirname(metadata.original_path));
+                        })
+                    }
+                });
+                // -------------------------------------------
+                // -
+                // -------------------------------------------
+                menu_items.push('-');
+            }
+            if(!are_trashed){
+                // -------------------------------------------
+                // Donwload
+                // -------------------------------------------
+                menu_items.push({
+                    html: 'Download',
+                    onClick: async function(){
+                        let items = [];
+                        for (let index = 0; index < $selected_items.length; index++) {
+                            items.push($selected_items[index]);
+                        }
+
+                        zipItems(items, path.dirname($(el_item).attr('data-path')), true);
+                    }
+                });
+                // -------------------------------------------
+                // Zip
+                // -------------------------------------------
+                menu_items.push({
+                    html: 'Zip',
+                    onClick: async function(){
+                        let items = [];
+                        for (let index = 0; index < $selected_items.length; index++) {
+                            items.push($selected_items[index]);
+                        }
+
+                        zipItems(items, path.dirname($(el_item).attr('data-path')), false);
+                    }
+                });
+                // -------------------------------------------
+                // -
+                // -------------------------------------------
+                menu_items.push('-');
+            }
+            // -------------------------------------------
+            // Cut
+            // -------------------------------------------
+            menu_items.push({
+                html: "Cut",
+                onClick: function(){
+                    window.clipboard_op= 'move';
+                    window.clipboard = [];
+                    $selected_items.each(function() {
+                        const ell = this;
+                        window.clipboard.push($(ell).attr('data-path'));
+                    })
+                }
+            });
+
+            // -------------------------------------------
+            // Copy
+            // -------------------------------------------
+            if(!are_trashed){
+                menu_items.push({
+                    html: "Copy",
+                    onClick: function(){
+                        window.clipboard_op= 'copy';
+                        window.clipboard = [];
+                        $selected_items.each(function() {
+                            const ell = this;
+                            window.clipboard.push({path: $(ell).attr('data-path')});
+                        })
+                    }
+                });
+            }
+            // -------------------------------------------
+            // -
+            // -------------------------------------------
+            menu_items.push('-');
+            // -------------------------------------------
+            // Delete Permanently
+            // -------------------------------------------
+            if(are_trashed){
+                menu_items.push({
+                    html: 'Delete Permanently',
+                    onClick: async function(){
+                        const alert_resp = await UIAlert({
+                            message: `Are you sure you want to permanently delete these items?`,
+                            buttons:[
+                                {
+                                    label: 'Delete',
+                                    type: 'primary',
+                                },
+                                {
+                                    label: 'Cancel'
+                                },
+                            ]
+                        })
+                        if((alert_resp) === 'Delete'){
+                            for (let index = 0; index < $selected_items.length; index++) {
+                                const element = $selected_items[index];
+                                await delete_item(element);
+                            }
+                            const trash = await puter.fs.stat(trash_path);
+
+                            // update other clients
+                            if(window.socket){
+                                window.socket.emit('trash.is_empty', {is_empty: trash.is_empty});
+                            }
+
+                            if(trash.is_empty){
+                                $(`.item[data-path="${html_encode(trash_path)}" i], .item[data-shortcut_to_path="${trash_path}" i]`).find('.item-icon > img').attr('src', window.icons['trash.svg']);
+                                $(`.window[data-path="${html_encode(trash_path)}"]`).find('.window-head-icon').attr('src', window.icons['trash.svg']);
+                            }            
+                        }
+                    }
+                });
+            }
+            // -------------------------------------------
+            // Create Shortcut
+            // -------------------------------------------
+            if(!are_trashed && window.feature_flags.create_shortcut){
+                menu_items.push({
+                    html: 'Create Shortcut',
+                    onClick: async function(){
+                        $selected_items.each(function() {
+                            let base_dir = path.dirname($(this).attr('data-path'));
+                            // Trash on Desktop is a special case
+                            if($(this).attr('data-path') && $(this).closest('.item-container').attr('data-path') === window.desktop_path){
+                                base_dir = window.desktop_path;
+                            }
+                            // create shortcut
+                            create_shortcut(
+                                path.basename($(this).attr('data-path')), 
+                                $(this).attr('data-is_dir') === '1', 
+                                base_dir, 
+                                $(this).closest('.item-container'), 
+                                $(this).attr('data-shortcut_to') === '' ? $(this).attr('data-uid') : $(this).attr('data-shortcut_to'),
+                                $(this).attr('data-shortcut_to_path') === '' ? $(this).attr('data-path') : $(this).attr('data-shortcut_to_path'),
+                            );
+                        })
+                    }
+                });
+            }
+            // -------------------------------------------
+            // Delete
+            // -------------------------------------------
+            if(!are_trashed){
+                menu_items.push({
+                    html: 'Delete',
+                    onClick: async function(){
+                        move_items($selected_items, trash_path);
+                    }
+                });
+            }
+
+        }
+
+        // -------------------------------------------------------
+        // One item selected
+        // -------------------------------------------------------   
+        else{
+            const is_trash = $(el_item).attr('data-path') === trash_path || $(el_item).attr('data-shortcut_to_path') === trash_path;
+            menu_items = [];
+            // -------------------------------------------
+            // Open
+            // -------------------------------------------
+            if(!is_trashed){
+                menu_items.push({
+                    html: 'Open',
+                    onClick: function(){
+                        open_item({item: el_item});
+                    }
+                });
+
+                // -------------------------------------------
+                // -
+                // -------------------------------------------
+                if(options.associated_app_name || is_trash)
+                    menu_items.push('-');
+            }
+            // -------------------------------------------
+            // Open With
+            // -------------------------------------------
+            if(!is_trashed && !is_trash  && (options.associated_app_name === null || options.associated_app_name === undefined)){
+                let items = [];
+                if(!options.suggested_apps || options.suggested_apps.length === 0){
+                    // try to find suitable apps
+                    const suitable_apps = await suggest_apps_for_fsentry({
+                        uid: options.uid,
+                        path: options.path,
+                    });
+                    if(suitable_apps && suitable_apps.length > 0){
+                        options.suggested_apps = suitable_apps;
+                    }
+                }
+
+                if(options.suggested_apps && options.suggested_apps.length > 0){
+                    for (let index = 0; index < options.suggested_apps.length; index++) {
+                        const suggested_app = options.suggested_apps[index];
+                        if ( ! suggested_app ) {
+                            console.warn(`suggested_app is null`, options.suggested_apps, index);
+                            continue;
+                        }
+                        items.push({
+                            html: suggested_app.title,
+                            icon: `<img src="${html_encode(suggested_app.icon ?? window.icons['app.svg'])}" style="width:16px; height: 16px; margin-bottom: -4px;">`,
+                            onClick: async function(){
+                                launch_app({ 
+                                    name: suggested_app.name,
+                                    file_path: $(el_item).attr('data-path'),
+                                    window_title: $(el_item).attr('data-name'),
+                                    file_uid: $(el_item).attr('data-uid'),
+                                });
+                            }
+                        })
+                    }
+                }else{                    
+                    items.push({
+                        html: 'No suitable apps found',
+                        disabled: true,
+                    });
+                }
+                // add all suitable apps
+                menu_items.push({
+                    html: 'Open With',
+                    items: items,
+                });
+
+                // -------------------------------------------
+                // -- seperator --
+                // -------------------------------------------
+                menu_items.push('-');
+            }
+
+            // -------------------------------------------
+            // Open in New Window
+            // (only if the item is on a window)
+            // -------------------------------------------
+            if($(el_item).closest('.window-body').length > 0 && options.is_dir){
+                menu_items.push({
+                    html: 'Open in New Window',
+                    onClick: function(){
+                        if(options.is_dir){
+                            open_item({item: el_item, new_window: true})
+                        }
+                    }
+                });
+                // -------------------------------------------
+                // -- seperator --
+                // -------------------------------------------
+                if(!is_trash && !is_trashed && options.is_dir)
+                    menu_items.push('-');
+            }
+
+            // -------------------------------------------
+            // Publish As Website
+            // -------------------------------------------
+            if(!is_trashed && !is_trash && options.is_dir){
+                menu_items.push({
+                    html: 'Publish As Website',
+                    disabled: !options.is_dir,
+                    onClick: async function () {
+                        if(window.require_email_verification_to_publish_website){
+                            if(window.user.is_temp && 
+                                !await UIWindowSaveAccount({
+                                    send_confirmation_code: true,
+                                    message: 'Please create an account to proceed.',
+                                    window_options: {
+                                        backdrop: true,
+                                        close_on_backdrop_click: false,
+                                    }                                
+                                }))
+                                return;
+                            else if(!window.user.email_confirmed && !await UIWindowEmailConfirmationRequired())
+                                return;
+                        }
+                        UIWindowPublishWebsite(options.uid, $(el_item).attr('data-name'), $(el_item).attr('data-path'));
+                    }
+                });
+
+            }
+            // -------------------------------------------
+            // Deploy As App
+            // -------------------------------------------
+            if(!is_trashed && !is_trash && options.is_dir){
+                menu_items.push({
+                    html: 'Deploy As App',
+                    disabled: !options.is_dir,
+                    onClick: async function () {
+                        launch_app({
+                            name: 'dev-center',
+                            file_path: $(el_item).attr('data-path'),
+                            file_uid: $(el_item).attr('data-uid'),
+                            params: {
+                                source_path: options.path,
+                            }
+                        })
+                    }
+                });
+
+                menu_items.push('-');
+            }
+
+            // -------------------------------------------
+            // Empty Trash
+            // -------------------------------------------
+            if(is_trash){
+                menu_items.push({
+                    html: 'Empty Trash',
+                    onClick: async function(){
+                        empty_trash();
+                    }
+                });
+
+            }
+            // -------------------------------------------
+            // Donwload
+            // -------------------------------------------
+            if(!is_trash && !is_trashed && (options.associated_app_name === null || options.associated_app_name === undefined)){
+                menu_items.push({
+                    html: 'Download',
+                    disabled: options.is_dir && !window.feature_flags.download_directory,
+                    onClick: async function(){
+                        if(options.is_dir)
+                            zipItems(el_item, path.dirname($(el_item).attr('data-path')), true);
+                        else
+                            trigger_download([options.path]);
+                    }
+                });                
+            }
+
+
+            // -------------------------------------------
+            // Get Copy Link
+            // -------------------------------------------
+            if(!is_trashed && !is_trash && (options.associated_app_name === null || options.associated_app_name === undefined)){
+                menu_items.push({
+                    html: 'Get Copy Link',
+                    onClick: async function(){
+                        if(window.user.is_temp && 
+                            !await UIWindowSaveAccount({
+                                message: 'Please create an account to proceed.',
+                                send_confirmation_code: true,
+                                window_options: {
+                                    backdrop: true,
+                                    close_on_backdrop_click: false,
+                                }                                
+                            }))
+                            return;
+                        else if(!window.user.email_confirmed && !await UIWindowEmailConfirmationRequired())
+                            return;
+
+                        UIWindowGetCopyLink({
+                            name: $(el_item).attr('data-name'),
+                            uid: $(el_item).attr('data-uid'),
+                            path: $(el_item).attr('data-path'),
+                            is_dir: options.is_dir,
+                        });
+                    }
+                });
+            }
+            // -------------------------------------------
+            // Zip
+            // -------------------------------------------
+            if(!is_trash && !is_trashed && !$(el_item).attr('data-path').endsWith('.zip')){
+                menu_items.push({
+                    html: "Zip",
+                    onClick: function(){
+                        zipItems(el_item, path.dirname($(el_item).attr('data-path')), false);
+                    }
+                })
+            }
+            // -------------------------------------------
+            // Unzip
+            // -------------------------------------------
+            if(!is_trash && !is_trashed && $(el_item).attr('data-path').endsWith('.zip')){
+                menu_items.push({
+                    html: "Unzip",
+                    onClick: async function(){
+                        const zip = new JSZip();
+                        let filPath = $(el_item).attr('data-path');
+                        let file = puter.fs.read($(el_item).attr('data-path'));
+
+                        zip.loadAsync(file).then(async function (zip) {
+                            const rootdir = await puter.fs.mkdir(path.dirname(filPath) + '/' + path.basename(filPath, '.zip'), {dedupeName: true});
+                            Object.keys(zip.files).forEach(async function (filename) {
+                                if(filename.endsWith('/'))
+                                    await puter.fs.mkdir(rootdir.path +'/' + filename, {createMissingParents: true});
+                                zip.files[filename].async('blob').then(async function (fileData) {
+                                    await puter.fs.write(rootdir.path +'/' + filename, fileData);
+                                }).catch(function (e) {
+                                    // UIAlert(e.message);
+                                })
+                            })
+                        }).catch(function (e) {
+                            // UIAlert(e.message);
+                        })
+                    }
+                })
+            }
+            // -------------------------------------------
+            // Restore
+            // -------------------------------------------
+            if(is_trashed){
+                menu_items.push({
+                    html: 'Restore',
+                    onClick: async function(){
+                        let metadata = $(el_item).attr('data-metadata') === '' ? {} : JSON.parse($(el_item).attr('data-metadata'))
+                        move_items([el_item], path.dirname(metadata.original_path));
+                    }
+                });
+            }
+            // -------------------------------------------
+            // -
+            // -------------------------------------------
+            if(!is_trash && (options.associated_app_name === null || options.associated_app_name === undefined))
+                menu_items.push('-');
+            // -------------------------------------------
+            // Cut
+            // -------------------------------------------
+            if($(el_item).attr('data-immutable') === '0'){
+                menu_items.push({
+                    html: "Cut",
+                    onClick: function(){
+                        window.clipboard_op= 'move';
+                        window.clipboard= [options.path];
+                    }
+                });
+            }
+            // -------------------------------------------
+            // Copy
+            // -------------------------------------------
+            if(!is_trashed && !is_trash){
+                menu_items.push({
+                    html: "Copy",
+                    onClick: function(){
+                        window.clipboard_op= 'copy';
+                        window.clipboard= [{path: options.path}];
+                    }
+                });
+            }
+            // -------------------------------------------
+            // Paste Into Folder
+            // -------------------------------------------
+            if($(el_item).attr('data-is_dir') === '1' && !is_trashed && !is_trash){
+                menu_items.push({
+                    html: "Paste Into Folder",
+                    disabled: clipboard.length > 0 ? false : true,
+                    onClick: function(){
+                        if(clipboard_op === 'copy')
+                            copy_clipboard_items($(el_item).attr('data-path'), null);
+                        else if(clipboard_op === 'move')
+                            move_clipboard_items(null, $(el_item).attr('data-path'))
+                    }
+                })
+            }
+            // -------------------------------------------
+            // -
+            // -------------------------------------------
+            if($(el_item).attr('data-immutable') === '0' && !is_trash){
+                menu_items.push('-')
+            }
+            // -------------------------------------------
+            // Create Shortcut
+            // -------------------------------------------
+            if(!is_trashed && window.feature_flags.create_shortcut){
+                menu_items.push({
+                    html: 'Create Shortcut',
+                    onClick: async function(){
+                        let base_dir = path.dirname($(el_item).attr('data-path'));
+                        // Trash on Desktop is a special case
+                        if($(el_item).attr('data-path') && $(el_item).closest('.item-container').attr('data-path') === window.desktop_path){
+                            base_dir = window.desktop_path;
+                        }
+
+                        create_shortcut(
+                            path.basename($(el_item).attr('data-path')), 
+                            options.is_dir, 
+                            base_dir, 
+                            options.appendTo, 
+                            options.shortcut_to === '' ? options.uid : options.shortcut_to,
+                            options.shortcut_to_path === '' ? options.path : options.shortcut_to_path,
+                        );
+                    }
+                });
+            }
+            // -------------------------------------------
+            // Delete
+            // -------------------------------------------
+            if($(el_item).attr('data-immutable') === '0' && !is_trashed){
+                menu_items.push({
+                    html: 'Delete',
+                    onClick: async function(){
+                        move_items([el_item], trash_path);
+                    }
+                });
+            }
+            // -------------------------------------------
+            // Delete Permanently
+            // -------------------------------------------
+            if(is_trashed){
+                menu_items.push({
+                    html: 'Delete Permanently',
+                    onClick: async function(){
+                        const alert_resp = await UIAlert({
+                            message: `Are you sure you want to permanently delete this item?`,
+                            buttons:[
+                                {
+                                    label: 'Delete',
+                                    type: 'primary',
+                                },
+                                {
+                                    label: 'Cancel'
+                                },
+                            ]
+                        })
+
+                        if((alert_resp) === 'Delete'){
+                            await delete_item(el_item);
+                            // check if trash is empty
+                            const trash = await puter.fs.stat(trash_path);
+                            // update other clients
+                            if(window.socket){
+                                window.socket.emit('trash.is_empty', {is_empty: trash.is_empty});
+                            }
+                            // update this client
+                            if(trash.is_empty){
+                                $(`.item[data-path="${html_encode(trash_path)}" i], .item[data-shortcut_to_path="${html_encode(trash_path)}" i]`).find('.item-icon > img').attr('src', window.icons['trash.svg']);
+                                $(`.window[data-path="${trash_path}"]`).find('.window-head-icon').attr('src', window.icons['trash.svg']);
+                            }            
+                        }
+                    }
+                });
+            }
+            // -------------------------------------------
+            // Rename
+            // -------------------------------------------
+            if($(el_item).attr('data-immutable') === '0' && !is_trashed && !is_trash){
+                menu_items.push({
+                    html: "Rename",
+                    onClick: function(){
+                        activate_item_name_editor(el_item)
+                    }
+                });
+            }
+            // -------------------------------------------
+            // -
+            // -------------------------------------------
+            menu_items.push('-');
+            // -------------------------------------------
+            // Properties
+            // -------------------------------------------
+            menu_items.push({
+                html: "Properties",
+                onClick: function(){
+                    let window_height = 500;
+                    let window_width = 450;
+
+                    let left = $(el_item).position().left + $(el_item).width();
+                    left = left > (window.innerWidth - window_width)? (window.innerWidth - window_width) : left;
+
+                    let top = $(el_item).position().top + $(el_item).height();
+                    top = top > (window.innerHeight - (window_height + window.taskbar_height + window.toolbar_height))? (window.innerHeight - (window_height + window.taskbar_height + window.toolbar_height)) : top;
+
+                    UIWindowItemProperties(
+                        $(el_item).attr('data-name'), 
+                        $(el_item).attr('data-path'), 
+                        $(el_item).attr('data-uid'),
+                        left,
+                        top,
+                        window_width,
+                        window_height,
+                    );
+                }
+            });
+        }     
+        
+        // Create ContextMenu
+        UIContextMenu({
+            parent_element: ($(options.appendTo).hasClass('desktop') ? undefined : options.appendTo),
+            items: menu_items
+        });
+
+        return false
+    })
+
+    // --------------------------------------------------------
+    // Resize Item Name Editor on every keystroke
+    // --------------------------------------------------------
+    $(el_item_name_editor).on('input keypress focus', function(){
+        const val = $(el_item_name_editor).val();
+        $('.item-name-shadow').html(html_encode(val).replaceAll(' ', '&nbsp;'));
+        if(val !== ''){
+            const w = $('.item-name-shadow').width();
+            const h = $('.item-name-shadow').height();
+            $(el_item_name_editor).width(w + 4)
+            $(el_item_name_editor).height(h + 2)
+        }
+    })
+
+    if(options.sort_container_after_append){
+        sort_items(options.appendTo, $(el_item).closest('.item-container').attr('data-sort_by'), $(el_item).closest('.item-container').attr('data-sort_order'));
+    }
+    if(options.editable){
+        activate_item_name_editor(el_item)
+    }
+}
+
+// Create item-name-shadow
+// This element has the exact styling as item name editor and allows us
+// to measure the width and height of the item name editor and automatically
+// resize it to fit the text.
+$('body').append(`<span class="item-name-shadow"></span>`);
+
+$(document).on('click', '.item-has-website-url-badge', async function(e){
+    e.stopPropagation();
+    e.preventDefault();
+    const website_url = $(this).closest('.item').attr('data-website_url');
+    if(website_url){
+        window.open(website_url, '_blank');
+    }  
+    return false;
+})
+
+$(document).on('mousedown', '.item-has-website-url-badge', async function(e){
+    console.log('mousedown')
+    e.stopPropagation();
+    e.preventDefault();
+    return false;   
+})
+
+$(document).on('contextmenu', '.item-has-website-url-badge', async function(e){
+    e.stopPropagation();
+    e.preventDefault();
+    
+    // close other context menus
+    const $ctxmenus = $(".context-menu");
+    $ctxmenus.fadeOut(200, function(){
+        $ctxmenus.remove();
+    });
+
+    UIContextMenu({
+        parent_element: this,
+        items: [
+            // Open
+            {
+                html: `Open in New Tab <img src="${window.icons['launch.svg']}" style="width:10px; height:10px; margin-left: 5px;">` ,
+                html_active: `Open in New Tab <img src="${window.icons['launch-white.svg']}" style="width:10px; height:10px; margin-left: 5px;">` ,
+                onClick: function(){
+                    const website_url = $(e.target).closest('.item').attr('data-website_url');
+                    if(website_url){
+                        window.open(website_url, '_blank');
+                    }  
+                }
+            },
+            // Copy Link
+            {
+                html: 'Copy Link',
+                onClick: async function(){
+                    const website_url = $(e.target).closest('.item').attr('data-website_url');
+                    if(website_url){
+                        await copy_to_clipboard(website_url);
+                    }  
+                }
+            },
+        ]
+    });
+    
+    return false;
+})
+
+
+$(document).on('click', '.item-has-website-badge', async function(e){
+    puter.fs.stat({
+        uid: $(this).closest('.item').attr('data-uid'),
+        returnSubdomains: true,
+        returnPermissions: false,
+        returnVersions: false,
+        success: function (fsentry){
+            if(fsentry.subdomains)
+                window.open(fsentry.subdomains[0].address, '_blank');
+        }
+    })
+})
+
+$(document).on('long-hover', '.item-has-website-badge', function(e){
+    puter.fs.stat({
+        uid: $(this).closest('.item').attr('data-uid'),
+        returnSubdomains: true,
+        returnPermissions: false,
+        returnVersions: false,
+        success: function (fsentry){
+            var box = e.target.getBoundingClientRect();
+
+            var body = document.body;
+            var docEl = document.documentElement;
+        
+            var scrollTop = window.pageYOffset || docEl.scrollTop || body.scrollTop;
+            var scrollLeft = window.pageXOffset || docEl.scrollLeft || body.scrollLeft;
+        
+            var clientTop = docEl.clientTop || body.clientTop || 0;
+            var clientLeft = docEl.clientLeft || body.clientLeft || 0;
+        
+            var top  = box.top +  scrollTop - clientTop;
+            var left = box.left + scrollLeft - clientLeft;
+        
+        
+            if(fsentry.subdomains){
+                let h = `<div class="allow-user-select website-badge-popover-content">`;
+                h += `<div class="website-badge-popover-title">Associated website${ fsentry.subdomains.length > 1 ? 's':''}</div>`;
+                fsentry.subdomains.forEach(subdomain => {
+                    h += `
+                    <a class="website-badge-popover-link" href="${subdomain.address}" style="font-size:13px;" target="_blank">${subdomain.address.replace('https://', '')}</a>
+                    <br>`;
+                });
+
+                h += `</div>`;
+
+                // close other website popovers
+                $('.website-badge-popover-content').closest('.popover').remove();
+
+                // show a UIPopover with the website
+                UIPopover({
+                    target: e.target,
+                    content:h,
+                    snapToElement: e.target,
+                    parent_element: e.target,
+                    top: top - 30,
+                    left: left + 20,
+                })
+            }
+        }
+    })
+})
+
+$(document).on('click', '.website-badge-popover-link', function(e){
+    // remove the parent popover
+    $(e.target).closest('.popover').remove();
+})
+
+// removes item(s)
+$.fn.removeItems = async function(options) {
+    options = options || {};
+    $(this).each(async function() {
+        const parent_container = $(this).closest('.item-container');
+        $(this).remove();
+        show_or_hide_empty_folder_message(parent_container);
+    });
+
+    return this;
+}
+
+window.activate_item_name_editor= function(el_item){
+    // files in trash cannot be renamed, the user should be notified with an Alert.
+    if($(el_item).attr('data-immutable') !== '0'){
+        return;
+    }
+    // files in trash cannot be renamed, user should be notified with an Alert.
+    else if(path.dirname($(el_item).attr('data-path')) === window.trash_path){
+        UIAlert(`This item can't be renamed because it's in the trash. To rename this item, first drag it out of the Trash.`)
+        return;
+    }
+
+    const el_item_name = $(el_item).find('.item-name');
+    const el_item_name_editor = $(el_item).find('.item-name-editor').get(0);
+
+    $(el_item_name).hide();
+    $(el_item_name_editor).show();
+    $(el_item_name_editor).focus();
+    $(el_item_name_editor).addClass('item-name-editor-active');
+
+    // select all text before extension
+    const item_name = $(el_item).attr('data-name');
+    const is_dir = parseInt($(el_item).attr('data-is_dir'));
+    const extname = path.extname('/'+item_name);
+    if(extname !== '' && !is_dir)
+        el_item_name_editor.setSelectionRange(0, item_name.length - extname.length)
+    else
+        $(el_item_name_editor).select();
+}
+
+export default UIItem;

+ 57 - 0
src/UI/UINotification.js

@@ -0,0 +1,57 @@
+function UINotification(options){
+    global_element_id++;
+
+    options.content = options.content ?? '';
+
+    let h = '';
+    h += `<div id="ui-notification__${global_element_id}" class="notification antialiased animate__animated animate__fadeInRight animate__slow">`;
+        h += `<img class="notification-close" src="${html_encode(window.icons['close.svg'])}">`;
+        h += options.content;
+    h += `</div>`;
+
+    $('body').append(h);
+
+
+    const el_notification = document.getElementById(`ui-notification__${global_element_id}`);
+
+    $(el_notification).show(0, function(e){
+        // options.onAppend()
+        if(options.onAppend && typeof options.onAppend === 'function'){
+            options.onAppend(el_notification);
+        }
+    })
+
+    // Show Notification
+    $(el_notification).delay(100).show(0).
+    // In the right position (the mouse)
+    css({
+        top: toolbar_height + 15,
+    });
+
+    return el_notification;
+}
+
+$(document).on('click', '.notification', function(e){
+    if($(e.target).hasClass('notification')){
+        if(options.click && typeof options.click === 'function'){
+            options.click(e);
+        }
+        window.close_notification(e.target);
+    }else{
+        window.close_notification($(e.target).closest('.notification'));
+    }
+});
+
+$(document).on('click', '.notification-close', function(e){
+    window.close_notification($(e.target).closest('.notification'));
+});
+
+
+window.close_notification = function(el_notification){
+    $(el_notification).addClass('animate__fadeOutRight');
+    setTimeout(function(){
+        $(el_notification).remove();
+    }, 500);
+}
+
+export default UINotification;

+ 85 - 0
src/UI/UIPopover.js

@@ -0,0 +1,85 @@
+// todo change to apps popover or sth
+function UIPopover(options){
+    // skip if popover already open
+    if(options.parent_element && $(options.parent_element).hasClass('has-open-popover'))
+        return;
+
+    $('.window-active .window-app-iframe').css('pointer-events', 'none');
+
+    global_element_id++;
+
+    options.content = options.content ?? '';
+
+    let h = '';
+    h += `<div id="popover-${global_element_id}" class="popover">`;
+        h += options.content;
+    h += `</div>`;
+
+    $('body').append(h);
+
+
+    const el_popover = document.getElementById(`popover-${global_element_id}`);
+
+    $(el_popover).show(0, function(e){
+        // options.onAppend()
+        if(options.onAppend && typeof options.onAppend === 'function'){
+            options.onAppend(el_popover);
+        }
+    })
+
+    let x_pos;
+    let y_pos;
+
+    if(options.parent_element){
+        $(options.parent_element).addClass('has-open-popover');
+    }
+    $(el_popover).on("remove", function () {
+        if(options.parent_element){
+            $(options.parent_element).removeClass('has-open-popover');
+        }
+    })
+
+    function position_popover(){
+        // X position
+        const popover_width = options.width ?? $(el_popover).width();
+        if(options.center_horizontally){
+            x_pos = window.innerWidth/2 - popover_width/2 - 15;
+        }else{
+            if(options.position === 'bottom' || options.position === 'top')
+                x_pos = options.left ?? ($(options.snapToElement).offset().left - (popover_width/ 2) + 10);
+            else
+                x_pos = options.left ?? ($(options.snapToElement).offset().left + 5);
+        }
+
+        // Y position
+        const popover_height = options.height ?? $(el_popover).height();
+        if(options.center_horizontally){
+            y_pos = options.top ?? (window.innerHeight - (taskbar_height + popover_height + 10));
+        }else{
+            y_pos = options.top ?? ($(options.snapToElement).offset().top + $(options.snapToElement).height() + 5);
+        }
+
+        $(el_popover).css({
+            left: x_pos + "px",
+            top: y_pos + "px",
+        });
+    }
+    position_popover();
+
+    // If the window is resized, reposition the popover
+    $(window).on('resize', function(){
+        position_popover();
+    });
+    
+    // Show Popover
+    $(el_popover).delay(100).show(0).
+    // In the right position (the mouse)
+    css({
+        left: x_pos + "px",
+        top: y_pos + "px",
+    });
+
+    return el_popover;
+}
+
+export default UIPopover;

+ 103 - 0
src/UI/UIPrompt.js

@@ -0,0 +1,103 @@
+import UIWindow from './UIWindow.js'
+
+function UIPrompt(options){
+    // set sensible defaults
+    if(arguments.length > 0){
+        // if first argument is a string, then assume it is the message
+        if(isString(arguments[0])){
+            options = {};
+            options.message = arguments[0];
+        }
+        // if second argument is an array, then assume it is the buttons
+        if(arguments[1] && Array.isArray(arguments[1])){
+            options.buttons = arguments[1];
+        }
+    }
+
+    return new Promise(async (resolve) => {
+        // provide an 'OK' button if no buttons are provided
+        if(!options.buttons || options.buttons.length === 0){
+            options.buttons = [
+                {label: 'Cancel', value: false, type: 'default'},
+                {label: 'OK', value: true, type: 'primary'},
+            ]
+        }
+
+        let h = '';
+        // message
+        h += `<div class="window-prompt-message">${options.message}</div>`;
+        // prompt
+        h += `<div class="window-alert-prompt" style="margin-top: 20px;">`;
+            h += `<input type="text" class="prompt-input" placeholder="${options.placeholder ?? ''}" value="${options.value ?? ''}">`;
+        h += `</div>`;
+        // buttons
+        if(options.buttons && options.buttons.length > 0){
+            h += `<div style="overflow:hidden; margin-top:20px; float:right;">`;
+                h += `<button class="button button-default prompt-resp-button prompt-resp-btn-cancel" data-label="Cancel" style="padding: 0 20px;">Cancel</button>`;
+                h += `<button class="button button-primary prompt-resp-button prompt-resp-btn-ok" data-label="OK" data-value="true" autofocus>OK</button>`;
+            h += `</div>`;
+        }
+
+        const el_window = await UIWindow({
+            title: null,
+            icon: null,
+            uid: null,
+            is_dir: false,
+            message: options.message,
+            backdrop: options.backdrop ?? false,
+            is_resizable: false,
+            is_droppable: false,
+            has_head: false,
+            stay_on_top: options.stay_on_top ?? false,
+            selectable_body: false,
+            draggable_body: true,
+            allow_context_menu: false,
+            show_in_taskbar: false,
+            window_class: 'window-alert',
+            dominant: true,
+            body_content: h,
+            width: 450,
+            parent_uuid: options.parent_uuid,
+            onAppend: function(this_window){
+                setTimeout(function(){
+                    $(this_window).find('.prompt-input').get(0).focus({preventScroll:true});
+                }, 30);
+            },
+            ...options.window_options,
+            window_css:{
+                height: 'initial',
+            },
+            body_css: {
+                width: 'initial',
+                padding: '20px',
+                'background-color': 'rgba(231, 238, 245, .95)',
+                'backdrop-filter': 'blur(3px)',
+            }
+        });
+        // focus to primary btn
+        $(el_window).find('.button-primary').focus();
+
+        // --------------------------------------------------------
+        // Button pressed
+        // --------------------------------------------------------
+        $(el_window).find('.prompt-resp-button').on('click',  async function(event){
+            event.preventDefault(); 
+            event.stopPropagation();
+            if($(this).attr('data-value') === 'true'){
+                resolve($(el_window).find('.prompt-input').val());
+            }else{
+                resolve(false);
+            }
+            $(el_window).close();
+            return false;
+        })
+
+        $(el_window).find('.prompt-input').on('keyup', async function(e){
+            if(e.keyCode === 13){
+                $(el_window).find('.prompt-resp-btn-ok').click();
+            }
+        })
+    })
+}
+
+export default UIPrompt;

+ 286 - 0
src/UI/UITaskbar.js

@@ -0,0 +1,286 @@
+import UITaskbarItem from './UITaskbarItem.js'
+import UIPopover from './UIPopover.js'
+
+async function UITaskbar(options){
+    global_element_id++;
+
+    options = options ?? {};
+    options.content = options.content ?? '';
+
+    // get launch apps
+    $.ajax({
+        url: api_origin + "/get-launch-apps",
+        type: 'GET',
+        async: true,
+        contentType: "application/json",
+        headers: {
+            "Authorization": "Bearer "+auth_token
+        },
+        success: function (apps){ 
+            window.launch_apps = apps;
+        }
+    });
+
+    let h = '';
+    h += `<div id="ui-taskbar_${global_element_id}" class="taskbar" style="height:${window.taskbar_height}px;"><span id='clock'></span></div>`;
+
+    $('.desktop').append(h);
+
+    //---------------------------------------------
+    // add `Start` to taskbar
+    //---------------------------------------------
+    UITaskbarItem({
+        icon: window.icons['start.svg'],
+        name: 'Start',
+        sortable: false,
+        keep_in_taskbar: true,
+        disable_context_menu: true,
+        onClick: async function(item){
+            // skip if popover already open
+            if($(item).hasClass('has-open-popover'))
+                return;
+
+            // show popover
+            let popover = UIPopover({
+                content: `<div class="launch-popover hide-scrollbar"><span class="close-launch-popover">✕</span></div>`,
+                snapToElement: item,
+                parent_element: item,
+                width: 500,
+                height: 500,
+                center_horizontally: true,
+            });
+
+            // In the rare case that launch_apps is not populated yet, get it from the server
+            // then populate the popover
+            if(!launch_apps || !launch_apps.recent || launch_apps.recent.length === 0){
+                // get launch apps
+                launch_apps = await $.ajax({
+                    url: api_origin + "/get-launch-apps",
+                    type: 'GET',
+                    async: true,
+                    contentType: "application/json",
+                    headers: {
+                        "Authorization": "Bearer "+auth_token
+                    },
+                });
+            }
+            
+            let apps_str = '';
+
+            apps_str += `<div style="margin-bottom: 10px; padding: 5px; position: relative;">`
+                apps_str += `<input style="background-image:url(${window.icons['magnifier-outline.svg']});" class="launch-search">`;
+                apps_str += `<img class="launch-search-clear" src="${window.icons['close.svg']}">`;
+            apps_str += `</div>`;
+            // -------------------------------------------
+            // Recent apps
+            // -------------------------------------------
+            if(launch_apps.recent.length > 0){
+                // heading
+                apps_str += `<h1 class="start-section-heading start-section-heading-recent">Recent</h1>`;
+
+                // apps
+                apps_str += `<div class="launch-apps-recent">`;
+                for (let index = 0; index < window.launch_recent_apps_count && index < launch_apps.recent.length; index++) {
+                    const app_info = launch_apps.recent[index];
+                    apps_str += `<div title="${html_encode(app_info.title)}" data-name="${html_encode(app_info.name)}" class="start-app-card">`;
+                        apps_str += `<div class="start-app" data-app-name="${html_encode(app_info.name)}" data-app-uuid="${html_encode(app_info.uuid)}" data-app-icon="${html_encode(app_info.icon)}" data-app-title="${html_encode(app_info.title)}">`;
+                            apps_str += `<img class="start-app-icon" src="${html_encode(app_info.icon ? app_info.icon : window.icons['app.svg'])}">`;
+                            apps_str += `<span class="start-app-title">${html_encode(app_info.title)}</span>`;
+                        apps_str += `</div>`;
+                    apps_str += `</div>`;
+                }
+                apps_str += `</div>`;
+            }
+            // -------------------------------------------
+            // Reccomended apps
+            // -------------------------------------------
+            if(launch_apps.recommended.length > 0){
+                // heading
+                apps_str += `<h1 class="start-section-heading start-section-heading-recommended" style="${launch_apps.recent.length > 0 ? 'padding-top: 30px;' : ''}">Recommended</h1>`;
+                
+                // apps
+                apps_str += `<div class="launch-apps-recommended">`;
+                for (let index = 0; index < launch_apps.recommended.length; index++) {
+                    const app_info = launch_apps.recommended[index];
+                    apps_str += `<div title="${html_encode(app_info.title)}" data-name="${html_encode(app_info.name)}" class="start-app-card">`;
+                        apps_str += `<div class="start-app" data-app-name="${html_encode(app_info.name)}" data-app-uuid="${html_encode(app_info.uuid)}" data-app-icon="${html_encode(app_info.icon)}" data-app-title="${html_encode(app_info.title)}">`;
+                            apps_str += `<img class="start-app-icon" src="${html_encode(app_info.icon ? app_info.icon : window.icons['app.svg'])}">`;
+                            apps_str += `<span class="start-app-title">${html_encode(app_info.title)}</span>`;
+                        apps_str += `</div>`;
+                    apps_str += `</div>`;
+                }
+                apps_str += `</div>`;
+            }
+
+            // add apps to popover
+            $(popover).find('.launch-popover').append(apps_str);
+
+            // focus on search input only if not on mobile
+            if(!isMobile.phone)
+                $(popover).find('.launch-search').focus();
+
+            // make apps draggable
+            $(popover).find('.start-app').draggable({
+                appendTo: "body",
+                helper: "clone",
+                revert: "invalid",
+                connectToSortable: ".taskbar",
+                //containment: "document",
+                zIndex: parseInt($(popover).css('z-index')) + 1,
+                scroll: false,
+                distance: 5,
+                revertDuration: 100,
+                helper: 'clone',
+                cursorAt: { left: 18, top: 20 },
+                start: function(event, ui){
+                },
+                drag: function(event, ui){
+                },
+                stop: function(){
+                }
+            });
+        }
+    });            
+
+    //---------------------------------------------
+    // add `Explorer` to the taskbar
+    //---------------------------------------------
+    UITaskbarItem({
+        icon: window.icons['folders.svg'],
+        app: 'explorer',
+        name: 'Explorer',
+        sortable: false,
+        keep_in_taskbar: true,
+        lock_keep_in_taskbar: true,
+        onClick: function(){
+            let open_window_count = parseInt($(`.taskbar-item[data-app="explorer"]`).attr('data-open-windows'));
+            if(open_window_count === 0){
+                launch_app({ name: 'explorer', path: window.home_path});
+            }else{
+                return false;
+            }
+        }
+    })
+
+    //---------------------------------------------
+    // Add other useful apps to the taskbar
+    //---------------------------------------------
+    if(window.user.taskbar_items && window.user.taskbar_items.length > 0){
+        for (let index = 0; index < window.user.taskbar_items.length; index++) {
+            const app_info = window.user.taskbar_items[index];
+            // add taskbar item for each app
+            UITaskbarItem({
+                icon: app_info.icon,
+                app: app_info.name,
+                name: app_info.title,
+                keep_in_taskbar: true,
+                onClick: function(){
+                    let open_window_count = parseInt($(`.taskbar-item[data-app="${app_info.name}"]`).attr('data-open-windows'));
+                    if(open_window_count === 0){
+                        launch_app({
+                            name: app_info.name,
+                        }) 
+                    }else{
+                        return false;
+                    }
+                }
+            });
+        }
+    }
+
+    //---------------------------------------------
+    // add `Trash` to the taskbar
+    //---------------------------------------------
+    const trash = await puter.fs.stat(trash_path);
+    if(window.socket){
+        window.socket.emit('trash.is_empty', {is_empty: trash.is_empty});
+    }
+
+    UITaskbarItem({
+        icon: trash.is_empty ? window.icons['trash.svg'] : window.icons['trash-full.svg'],
+        app: 'trash',
+        name: 'Trash',
+        sortable: false,
+        keep_in_taskbar: true,
+        lock_keep_in_taskbar: true,
+        onClick: function(){
+            let open_windows = $(`.window[data-path="${html_encode(trash_path)}"]`);
+            if(open_windows.length === 0){
+                launch_app({ name: 'explorer', path: window.trash_path});
+            }else{
+                open_windows.focusWindow();
+            }
+        },
+        onItemsDrop: function(items){
+            move_items(items, trash_path);
+        }
+    })
+
+    make_taskbar_sortable();
+}
+
+window.make_taskbar_sortable = function(){
+    //-------------------------------------------
+    // Taskbar is sortable
+    //-------------------------------------------
+    $('.taskbar').sortable({
+        axis: "x",
+        items: '.taskbar-item-sortable:not(.has-open-contextmenu)',
+        cancel: '.has-open-contextmenu',
+        placeholder: "taskbar-item-sortable-placeholder",
+        helper : 'clone',
+        distance: 5,
+        revert: 10,
+        receive: function(event, ui){
+            if(!$(ui.item).hasClass('taskbar-item')){
+                // if app is already in taskbar, cancel
+                if($(`.taskbar-item[data-app="${$(ui.item).attr('data-app-name')}"]`).length !== 0){
+                    $(this).sortable('cancel');
+                    $('.taskbar .start-app').remove();
+                    return;
+                }else{
+                }
+            }
+        },
+        update: function(event, ui){
+            if(!$(ui.item).hasClass('taskbar-item')){
+                // if app is already in taskbar, cancel
+                if($(`.taskbar-item[data-app="${$(ui.item).attr('data-app-name')}"]`).length !== 0){
+                    $(this).sortable('cancel');
+                    $('.taskbar .start-app').remove();
+                    return;
+                }
+                
+                let item = UITaskbarItem({
+                    icon: $(ui.item).attr('data-app-icon'),
+                    app: $(ui.item).attr('data-app-name'),
+                    name: $(ui.item).attr('data-app-title'),
+                    append_to_taskbar: false,
+                    keep_in_taskbar: true,
+                    onClick: function(){
+                        let open_window_count = parseInt($(`.taskbar-item[data-app="${$(ui.item).attr('data-app-name')}"]`).attr('data-open-windows'));
+                        if(open_window_count === 0){
+                            launch_app({
+                                name: $(ui.item).attr('data-app-name'),
+                            }) 
+                        }else{
+                            return false;
+                        }
+                    }
+                });
+                let el = ($(item).detach())
+                $(el).insertAfter(ui.item);
+                // $(ui.item).insertBefore(`<h1>Hello!</h1>`);
+                $(el).show();
+                $(ui.item).removeItems();  
+                update_taskbar();  
+            }
+            // only proceed to update DB if the item sorted was a pinned item otherwise no point in updating the taskbar in DB
+            else if($(ui.item).attr('data-keep-in-taskbar') === 'true'){
+                update_taskbar();
+            }
+        },
+    });
+}
+
+export default UITaskbar;

+ 346 - 0
src/UI/UITaskbarItem.js

@@ -0,0 +1,346 @@
+import UIContextMenu from './UIContextMenu.js';
+
+let tray_item_id = 1;
+
+function UITaskbarItem(options){
+    let h = ``;
+    tray_item_id++;
+    options.sortable = options.sortable ?? true;
+    options.open_windows_count = options.open_windows_count ?? 0;
+    options.lock_keep_in_taskbar = options.lock_keep_in_taskbar ?? false;
+    options.append_to_taskbar = options.append_to_taskbar ?? true;
+    const element_id = global_element_id++;
+
+    h += `<div  class = "taskbar-item ${options.sortable ? 'taskbar-item-sortable' : ''} disable-user-select"
+                id = "taskbar-item-${tray_item_id}"
+                data-taskbar-item-id = "${tray_item_id}"
+                data-element-id = "${html_encode(element_id)}"
+                data-name = "${html_encode(options.name)}"
+                data-app = "${html_encode(options.app)}"
+                data-keep-in-taskbar = "${html_encode(options.keep_in_taskbar ?? 'false')}"
+                data-open-windows="${(options.open_windows_count)}"
+                title = "${html_encode(options.name)}"
+                style= "${options.style ? html_encode(options.style) : ''}"
+            >`;
+        let icon = options.icon ? options.icon : window.icons['app.svg'];
+        if(options.app === 'explorer')
+            icon = window.icons['folders.svg'];
+
+        // taskbar icon
+        h += `<div class="taskbar-icon">`;
+            h += `<img src="${html_encode(icon)}" style="${options.group === 'apps' ? 'filter:none;' : ''}">`;
+        h += `</div>`;
+
+        // active indicator
+        if(options.app !== 'apps')
+            h += `<span class="active-taskbar-indicator"></span>`;
+    h += `</div>`;
+
+    if(options.append_to_taskbar)
+        $('.taskbar').append(h);
+    else
+        $('body').prepend(h);
+
+    const el_taskbar_item = document.querySelector(`#taskbar-item-${tray_item_id}`);
+
+    // fade in the taskbar item
+    $(el_taskbar_item).show(50);
+
+    $(el_taskbar_item).on("click", function(){
+        // If this item has an open context menu, don't do anything
+        if($(el_taskbar_item).hasClass('has-open-contextmenu'))
+            return;
+
+        if(options.onClick === undefined || options.onClick(el_taskbar_item) === false){
+            // re-show each window in this app group
+            $(`.window[data-app="${options.app}"]`).showWindow();
+        }
+    })
+
+    $(el_taskbar_item).on('contextmenu taphold', function(e){
+        // seems like the only way to stop sortable is to destroy it
+        if(options.sortable) {
+            $('.taskbar').sortable('destroy');
+        }
+
+        e.preventDefault();
+        e.stopPropagation();
+
+        // If context menu is disabled on this item, return
+        if(options.disable_context_menu)
+            return;
+
+        // don't allow context menu to open if it's already open
+        if($(el_taskbar_item).hasClass('has-open-contextmenu'))
+            return;
+
+        const menu_items =[];
+        const open_windows = parseInt($(el_taskbar_item).attr('data-open-windows'));        
+        // -------------------------------------------
+        // List of open windows belonging to this app
+        // -------------------------------------------
+        $(`.window[data-app="${options.app}"]`).each(function(){
+            menu_items.push({
+                html: $(this).find(`.window-head-title`).html(),
+                val: $(this).attr('data-id'),
+                onClick: function(e){
+                    $(`.window[data-id="${e.value}"]`).showWindow();
+                }
+            })
+        })
+        // -------------------------------------------
+        // divider
+        // -------------------------------------------
+        if(menu_items.length > 0)
+            menu_items.push('-');
+
+        //------------------------------------------
+        // New Window
+        //------------------------------------------
+        if(options.app){
+            menu_items.push({
+                html: 'New Window',
+                val: $(this).attr('data-id'),
+                onClick: function(){
+                    launch_app({
+                        name: options.app,
+                        maximized: (isMobile.phone || isMobile.tablet),
+                    })
+                }
+            })
+        }
+        //------------------------------------------
+        // Empty Trash
+        //------------------------------------------
+        if(options.app === 'trash' && options.name === 'Trash'){
+            // divider
+            menu_items.push('-');
+
+            // Empty Trash menu item
+            menu_items.push({
+                html: 'Empty Trash',
+                val: $(this).attr('data-id'),
+                onClick: async function(){
+                    empty_trash();
+                }
+            })
+        }
+
+        //------------------------------------------
+        // Remove from Taskbar
+        //------------------------------------------
+        if(options.keep_in_taskbar && !options.lock_keep_in_taskbar){
+            menu_items.push({
+                html: 'Remove from Taskbar',
+                val: $(this).attr('data-id'),
+                onClick: function(){
+                    $(el_taskbar_item).attr('data-keep-in-taskbar', 'false');
+                    if($(el_taskbar_item).attr('data-open-windows') === '0'){
+                        remove_taskbar_item(el_taskbar_item);
+                    }
+                    update_taskbar();
+                    options.keep_in_taskbar = false;
+                }
+            })
+        }
+        //------------------------------------------
+        // Keep in Taskbar
+        //------------------------------------------
+        else if(!options.keep_in_taskbar){
+            menu_items.push({
+                html: 'Keep in Taskbar',
+                val: $(this).attr('data-id'),
+                onClick: function(){
+                    $(el_taskbar_item).attr('data-keep-in-taskbar', 'true');
+                    update_taskbar();
+                    options.keep_in_taskbar = true;
+                }
+            })  
+        }
+
+        if(open_windows > 0){
+            // -------------------------------------------
+            // divider
+            // -------------------------------------------
+            menu_items.push('-');
+            // -------------------------------------------
+            // Show All Windows
+            // -------------------------------------------
+            menu_items.push({
+                html: "Show All Windows",
+                onClick: function(){
+                    if(open_windows > 0)
+                        $(el_taskbar_item).trigger('click');
+                }
+            })
+            // -------------------------------------------
+            // Hide All Windows
+            // -------------------------------------------
+            menu_items.push({
+                html: "Hide All Windows",
+                onClick: function(){
+                    if(open_windows > 0)
+                        $(`.window[data-app="${options.app}"]`).hideWindow();
+                }
+            })
+            // -------------------------------------------
+            // Close All Windows
+            // -------------------------------------------
+            menu_items.push({
+                html: "Close All Windows",
+                onClick: function(){
+                    $(`.window[data-app="${options.app}"]`).close();
+                }
+            })
+        }
+        const pos = el_taskbar_item.getBoundingClientRect();
+        UIContextMenu({
+            parent_element: el_taskbar_item,
+            position: {top: pos.top - 15, left: pos.left+5},
+            items: menu_items
+        });
+
+        return false;
+    });
+
+    $( el_taskbar_item ).tooltip({
+        items: ".taskbar:not(.children-have-open-contextmenu) .taskbar-item",
+        position: {
+            my: "center bottom-20",
+            at: "center top",
+            using: function( position, feedback ) {
+              $( this ).css( position );
+              $( "<div>" )
+                .addClass( "arrow" )
+                .addClass( feedback.vertical )
+                .addClass( feedback.horizontal )
+                .appendTo( this );
+            }
+        }    
+    });
+
+    // --------------------------------------------------------
+    // Droppable
+    // --------------------------------------------------------
+    $(el_taskbar_item).droppable({
+        accept: '.item',
+        // 'pointer' is very important because of active window tracking is based on the position of cursor.
+        tolerance: 'pointer',
+        drop: async function( event, ui ) {
+            // Check if hovering over an item that is VISIBILE
+            if($(event.target).closest('.window').attr('data-id') !== $(mouseover_window).attr('data-id'))
+                return;
+
+            // If ctrl is pressed and source is Trashed, cancel whole operation
+            if(event.ctrlKey && path.dirname($(ui.draggable).attr('data-path')) === window.trash_path)
+                return;
+
+            const items_to_move = []
+            
+            // First item
+            items_to_move.push(ui.draggable); 
+            
+            // All subsequent items
+            const cloned_items = document.getElementsByClassName('item-selected-clone');
+            for(let i =0; i<cloned_items.length; i++){
+                const source_item = document.getElementById('item-' + $(cloned_items[i]).attr('data-id'));
+                if(source_item !== null)
+                    items_to_move.push(source_item);
+            }
+
+            // --------------------------------------------------------
+            // If `options.onItemsDrop` is set, call it with the items to move
+            //--------------------------------------------------------
+            if(options.onItemsDrop && typeof options.onItemsDrop === 'function'){
+                options.onItemsDrop(items_to_move);
+                return;
+            }
+            // --------------------------------------------------------
+            // If dropped on an app, open the app with the dropped item as an argument
+            //--------------------------------------------------------
+            else if(options.app){
+                // an array that hold the items to sign
+                const items_to_sign = [];
+
+                // prepare items to sign
+                for(let i=0; i < items_to_move.length; i++){
+                    items_to_sign.push({
+                        name: $(items_to_move[i]).attr('data-name'), 
+                        uid: $(items_to_move[i]).attr('data-uid'), 
+                        action: 'write', 
+                        path: $(items_to_move[i]).attr('data-path')
+                    });
+                }
+
+                // open each item
+                for (let i = 0; i < items_to_sign.length; i++) {
+                    const item = items_to_sign[i];
+                    launch_app({ 
+                        name: options.app, 
+                        file_path: item.path,
+                        // app_obj: open_item_meta.suggested_apps[0],
+                        window_title: item.name,
+                        file_uid: item.uid,
+                        // file_signature: item,
+                    });
+                }
+
+                // deselect dragged item
+                for(let i=0; i < items_to_move.length; i++)
+                    $(items_to_move[i]).removeClass('item-selected');
+            }
+
+            // Unselect directory/app if item is dropped
+            if(options.is_dir || options.app){
+                $(el_taskbar_item).removeClass('active');
+                $(el_taskbar_item).tooltip('close');
+                $('.ui-draggable-dragging .item-name, .item-selected-clone .item-name').css('opacity', 'initial')
+                $('.item-container').removeClass('item-container-transparent-border')
+            }
+
+            // Re-enable droppable on all item-container
+            $('.item-container').droppable('enable')
+
+            return false;
+        },
+        over: function(event, ui){
+            // Check hovering over an item that is VISIBILE
+            const $event_parent_win = $(event.target).closest('.window')
+            if( $event_parent_win.length > 0 && $event_parent_win.attr('data-id') !== $(mouseover_window).attr('data-id'))
+                return;
+            // Don't do anything if the dragged item is NOT a UIItem
+            if(!$(ui.draggable).hasClass('item'))
+                return;
+            // If this is a directory or an app, and an item was dragged over it, highlight it.
+            if(options.is_dir || options.app){
+                $(el_taskbar_item).addClass('active');
+                // show tooltip of this item
+                $(el_taskbar_item).tooltip().mouseover();
+                // make item name partially transparent
+                $('.ui-draggable-dragging .item-name, .item-selected-clone .item-name').css('opacity', 0.1)
+                // remove all item-container active borders
+                $('.item-container').addClass('item-container-transparent-border')
+            }
+            // Disable all window bodies 
+            $('.item-container').droppable( 'disable' )
+        },
+        out: function(event, ui){
+            // Don't do anything if the dragged item is NOT a UIItem
+            if(!$(ui.draggable).hasClass('item'))
+                return;
+
+            // Unselect directory/app if item is dragged out
+            if(options.is_dir || options.app){
+                $(el_taskbar_item).removeClass('active');
+                $(el_taskbar_item).tooltip('close');
+                $('.ui-draggable-dragging .item-name, .item-selected-clone .item-name').css('opacity', 'initial')
+                $('.item-container').removeClass('item-container-transparent-border')
+            }
+            $('.item-container').droppable( 'enable' )    
+        }
+    });
+
+    return el_taskbar_item;
+}
+
+export default UITaskbarItem

+ 3233 - 0
src/UI/UIWindow.js

@@ -0,0 +1,3233 @@
+import UIAlert from './UIAlert.js';
+import UIContextMenu from './UIContextMenu.js';
+import path from '../lib/path.js';
+import UITaskbarItem from './UITaskbarItem.js';
+import UIWindowLogin from './UIWindowLogin.js';
+import UIWindowPublishWebsite from './UIWindowPublishWebsite.js';
+import UIWindowItemProperties from './UIWindowItemProperties.js';
+
+const el_body = document.getElementsByTagName('body')[0];
+
+async function UIWindow(options) {
+    const win_id = global_element_id++;
+    last_window_zindex++;
+
+    // options.dominant places the window in center close to top.
+    options.dominant = options.dominant ?? false;
+
+    // in case of file dialogs, the window is automatically dominant
+    if(options.is_openFileDialog || options.is_saveFileDialog || options.is_directoryPicker)
+        options.dominant = true;
+ 
+    // we don't want to increment window_counter for dominant windows
+    if(!options.dominant)
+        window.window_counter++;
+
+    // add this window's id to the window_stack
+    window_stack.push(win_id);
+
+    // =====================================
+    // set options defaults
+    // =====================================
+
+    // indicates if sidebar is hidden, only applies to directory windows
+    let sidebar_hidden = false;
+
+    const default_window_top = ('calc(15% + ' + ((window.window_counter-1) % 10 * 20) + 'px)');
+
+    // list of file types that are allowed, other types will be disabled but still shown
+    options.allowed_file_types = options.allowed_file_types ?? '';
+    options.app = options.app ?? '';
+    options.allow_context_menu = options.allow_context_menu ?? true;
+    options.allow_native_ctxmenu = options.allow_native_ctxmenu ?? false;
+    options.allow_user_select = options.allow_user_select ?? false;
+    options.backdrop = options.backdrop ?? false;
+    options.body_css = options.body_css ?? {};
+    options.border_radius = options.border_radius ?? undefined;
+    options.draggable_body = options.draggable_body ?? false;
+    options.element_uuid = options.element_uuid ?? uuidv4();
+    options.center = options.center ?? false;
+    options.close_on_backdrop_click = options.close_on_backdrop_click ?? true;
+    options.disable_parent_window = options.disable_parent_window ?? false;
+    options.has_head = options.has_head ?? true;
+    options.height = options.height ?? 380;
+    options.icon = options.icon ?? null;
+    options.iframe_msg_uid = options.iframe_msg_uid ?? null;
+    options.is_droppable = options.is_droppable ?? true;
+    options.is_draggable = options.is_draggable ?? true;
+    options.is_dir = options.is_dir ?? false;
+    options.is_minimized = options.is_minimized ?? false;
+    options.is_maximized = options.is_maximized ?? false;
+    options.is_openFileDialog = options.is_openFileDialog ?? false;
+    options.is_resizable = options.is_resizable ?? true;
+    // if this is a fullpage window, it won't be resizable
+    if(options.is_fullpage)
+        options.is_resizable = false;
+
+    // in the embedded/fullpage mode every window is on top since there is no taskbar to switch between windows
+    // if user has specifically asked for this window to NOT stay on top, honor it.
+    if((is_embedded || window.is_fullpage_mode) && !options.parent_uuid && options.stay_on_top !== false)
+        options.stay_on_top = true;
+    // Keep the window on top of all previously opened windows
+    options.stay_on_top = options.stay_on_top ?? false;
+
+    options.is_saveFileDialog = options.is_saveFileDialog ?? false;
+    options.show_minimize_button = options.show_minimize_button ?? true;
+    options.on_close = options.on_close ?? undefined;
+    options.parent_uuid = options.parent_uuid ?? null;
+    options.selectable_body = options.selectable_body ?? true;
+    options.show_in_taskbar = options.show_in_taskbar ?? true;
+    options.show_maximize_button = options.show_maximize_button ?? true;
+    options.single_instance = options.single_instance ?? false;
+    options.sort_by = options.sort_by ?? 'name';
+    options.sort_order = options.sort_order ?? 'asc';
+    options.title = options.title ?? null;
+    options.top = options.top ?? default_window_top;
+    options.type = options.type ?? null;
+    options.update_window_url = options.update_window_url ?? false;
+    options.layout = options.layout ?? 'icons';
+    options.width = options.width ?? 680;
+    options.window_css = options.window_css ?? {};
+    options.window_class = (options.window_class !== undefined ? ' ' + options.window_class : '');
+
+    // if only one instance is allowed, bring focus to the window that is already open
+    if(options.single_instance && options.app !== ''){
+        let $already_open_window =  $(`.window[data-app="${html_encode(options.app)}"]`);
+        if($already_open_window.length){
+            $(`.window[data-app="${html_encode(options.app)}"]`).focusWindow();
+            return;
+        }
+    }
+
+    // left
+    if(!options.dominant && !options.center){
+        options.left = options.left ?? ((window.innerWidth/2 - options.width/2) +(window.window_counter-1) % 10 * 30) + 'px';
+    }else if(!options.dominant && options.center){
+        options.left = options.left ?? ((window.innerWidth/2 - options.width/2)) + 'px';
+    }
+    else if(options.dominant){
+        options.left = (window.innerWidth/2 - options.width/2) + 'px';
+    }   
+    else
+        options.left = options.left ?? ((window.innerWidth/2 - options.width/2) + 'px');
+ 
+    // top
+    if(!options.dominant && !options.center){
+        options.top = options.top ?? ((window.innerHeight/2 - options.height/2) +(window.window_counter-1) % 10 * 30) + 'px';
+    }else if(!options.dominant && options.center){
+        options.top = options.top ?? ((window.innerHeight/2 - options.height/2)) + 'px';
+    }
+    else if(options.dominant){
+        options.top = (window.innerHeight * 0.15);
+    }
+    else if(isMobile.phone)
+        options.top = 100;
+    
+    if(isMobile.phone){
+        options.left = 0;
+        options.top = window.toolbar_height + 'px';
+        options.width = '100%';
+        options.height = 'calc(100% - ' + window.toolbar_height + 'px)';
+    }else{
+        options.width += 'px'
+        options.height += 'px'
+    }
+
+    // =====================================
+    // cover page
+    // =====================================
+    if(options.cover_page){
+        options.left = 0;
+        options.top = 0;
+        options.width = '100%';
+        options.height = '100%';
+    }
+    // --------------------------------------------------------
+    // HTML for Window
+    // --------------------------------------------------------
+    let h = '';
+
+    // Window
+    let zindex = options.stay_on_top ? (99999999 + last_window_zindex + 1 + ' !important') : last_window_zindex;
+    h += `<div class="window window-active 
+                        ${options.cover_page ? 'window-cover-page' : ''}
+                        ${options.uid !== undefined ? 'window-'+options.uid : ''} 
+                        ${options.window_class} 
+                        ${options.allow_user_select ? ' allow-user-select' : ''}
+                        ${options.is_openFileDialog || options.is_saveFileDialog || options.is_directoryPicker ? 'window-filedialog' : ''}" 
+                id="window-${win_id}" 
+                data-allowed_file_types = "${html_encode(options.allowed_file_types)}"
+                data-app="${html_encode(options.app)}" 
+                data-app_uuid="${html_encode(options.app_uuid ?? '')}" 
+                data-disable_parent_window = "${html_encode(options.disable_parent_window)}"
+                data-name="${html_encode(options.title)}" 
+                data-path ="${html_encode(options.path)}"
+                data-uid ="${options.uid}"
+                data-element_uuid="${options.element_uuid}"
+                data-parent_uuid="${options.parent_uuid}"
+                data-id ="${win_id}"
+                data-iframe_msg_uid ="${options.iframe_msg_uid}"
+                data-is_dir ="${options.is_dir}"
+                data-return_to_parent_window = "${options.return_to_parent_window}"
+                data-initiating_app_uuid = "${options.initiating_app_uuid}"
+                data-is_openFileDialog ="${options.is_openFileDialog}"
+                data-is_saveFileDialog ="${options.is_saveFileDialog}"
+                data-is_directoryPicker ="${options.is_directoryPicker}"
+                data-is_fullpage ="${options.is_fullpage ? 1 : 0}"
+                data-is_minimized ="${options.is_minimized ? 1 : 0}"
+                data-is_maximized ="${options.is_maximized ? 1 : 0}"
+                data-layout ="${options.layout}"
+                data-stay_on_top ="${options.stay_on_top}"
+                data-sort_by ="${options.sort_by ?? 'name'}"
+                data-sort_order ="${options.sort_order ?? 'asc'}"
+                data-multiselectable = "${options.selectable_body}"
+                data-update_window_url = "${options.update_window_url}"
+                data-initial_zindex = "${zindex}"
+                style=" z-index: ${zindex}; 
+                        ${options.width !== undefined ? 'width: ' + html_encode(options.width) +'; ':''}
+                        ${options.height !== undefined ? 'height: ' + html_encode(options.height) +'; ':''}
+                        ${options.border_radius !== undefined ? 'border-radius: ' + html_encode(options.border_radius) +'; ':''}
+                    " 
+                >`;
+        // window mask
+        h += `<div class="window-disable-mask">`;
+            //busy indicator
+            h += `<div class="busy-indicator">BUSY</div>`;
+        h += `</div>`;
+
+
+        // Head
+        if(options.has_head){
+            h += `<div class="window-head">`;
+                // draggable handle which also contains icon and title
+                h+=`<div class="window-head-draggable">`;
+                    // icon
+                    if(options.icon)
+                        h += `<img class="window-head-icon" />`;
+                    // title
+                    h += `<span class="window-head-title" title="${html_encode(options.title)}"></span>`;
+                h += `</div>`;
+                // Minimize button, only if window is resizable and not embedded
+                if(options.is_resizable && options.show_minimize_button && !is_embedded)
+                    h += `<span class="window-action-btn window-minimize-btn" style="margin-left:0;"><img src="${html_encode(window.icons['minimize.svg'])}" draggable="false"></span>`;
+                // Maximize button
+                if(options.is_resizable && options.show_maximize_button)
+                    h += `<span class="window-action-btn window-scale-btn"><img src="${html_encode(window.icons['scale.svg'])}" draggable="false"></span>`;
+                // Close button
+                h += `<span class="window-action-btn window-close-btn"><img src="${html_encode(window.icons['close.svg'])}" draggable="false"></span>`;
+            h += `</div>`;
+        }
+
+        // Sidebar
+        if(options.is_dir && !isMobile.phone){
+            h += `<div class="window-sidebar disable-user-select hide-scrollbar"
+                    style="${window.window_sidebar_width ? 'width: ' + html_encode(window.window_sidebar_width) + 'px !important;' : ''}"
+                    draggable="false"
+                >`;
+                // favorites
+                h += `<h2 class="window-sidebar-title disable-user-select">Favorites</h2>`;
+                h += `<div draggable="false" title="Home" class="window-sidebar-item disable-user-select ${options.path === window.home_path ? 'window-sidebar-item-active' : ''}" data-path="${html_encode(window.home_path)}"><img draggable="false" class="window-sidebar-item-icon" src="${html_encode(window.icons['folder-home.svg'])}">Home</div>`;
+                h += `<div draggable="false" title="Documents" class="window-sidebar-item disable-user-select ${options.path === window.docs_path ? 'window-sidebar-item-active' : ''}" data-path="${html_encode(window.docs_path)}"><img draggable="false" class="window-sidebar-item-icon" src="${html_encode(window.icons['folder-documents.svg'])}">Documents</div>`;
+                h += `<div draggable="false" title="Pictures" class="window-sidebar-item disable-user-select ${options.path === window.pictures_path ? 'window-sidebar-item-active' : ''}" data-path="${html_encode(window.pictures_path)}"><img draggable="false" class="window-sidebar-item-icon" src="${html_encode(window.icons['folder-pictures.svg'])}">Pictures</div>`;
+                h += `<div draggable="false" title="Desktop" class="window-sidebar-item disable-user-select ${options.path === window.desktop_path ? 'window-sidebar-item-active' : ''}" data-path="${html_encode(window.desktop_path)}"><img draggable="false" class="window-sidebar-item-icon" src="${html_encode(window.icons['folder-desktop.svg'])}">Desktop</div>`;
+                h += `<div draggable="false" title="Videos" class="window-sidebar-item disable-user-select ${options.path === window.videos_path ? 'window-sidebar-item-active' : ''}" data-path="${html_encode(window.videos_path)}"><img draggable="false" class="window-sidebar-item-icon" src="${html_encode(window.icons['folder-videos.svg'])}">Videos</div>`;
+            h += `</div>`;
+        }
+
+        // Navbar
+        if(options.is_dir){
+            h += `<div class="window-navbar">`;
+                h += `<div style="float:left; margin-left:5px; margin-right:5px;">`;
+                    // Back
+                    h += `<img draggable="false" class="window-navbar-btn window-navbar-btn-back window-navbar-btn-disabled" src="${html_encode(window.icons['arrow-left.svg'])}" title="Click to go back.">`;
+                    // Forward
+                    h += `<img draggable="false" class="window-navbar-btn window-navbar-btn-forward window-navbar-btn-disabled" src="${html_encode(window.icons['arrow-right.svg'])}" title="Click to go forward.">`;
+                    // Up
+                    h += `<img draggable="false" class="window-navbar-btn window-navbar-btn-up ${options.path === '/' ? 'window-navbar-btn-disabled' : ''}" src="${html_encode(window.icons['arrow-up.svg'])}" title="Click to go one directory up.">`;
+                h += `</div>`;
+                // Path
+                h += `<div class="window-navbar-path">${navbar_path(options.path, window.user.username)}</div>`;
+                // Path editor
+                h += `<input class="window-navbar-path-input" data-path="${html_encode(options.path)}" value="${html_encode(options.path)}" spellcheck="false"/>`;
+                // Layout settings
+                h += `<img class="window-navbar-layout-settings" src="${html_encode(options.layout === 'icons' ? window.icons['layout-icons.svg'] : window.icons['layout-list.svg'])}" draggable="false">`;
+            h += `</div>`;
+        }
+
+        // Body
+        h += `<div 
+                class="window-body${options.is_dir ? ' item-container' : ''}${options.iframe_url !== undefined || options.iframe_srcdoc !== undefined ? ' window-body-app' : ''}${options.is_saveFileDialog || options.is_openFileDialog || options.is_directoryPicker ? ' window-body-filedialog' : ''}" 
+                data-allowed_file_types="${html_encode(options.allowed_file_types)}"
+                data-path="${html_encode(options.path)}"
+                data-multiselectable = "${options.selectable_body}"
+                data-sort_by ="${options.sort_by ?? 'name'}"
+                data-sort_order ="${options.sort_order ?? 'asc'}"
+                data-uid ="${options.uid}"
+                id="window-body-${win_id}" 
+                style="${!options.has_head ? ' height: 100%;' : ''}">`;
+            // iframe, for apps
+            if(options.iframe_url || options.iframe_srcdoc){
+                // iframe
+                h += `<iframe tabindex="-1"
+                        data-app="${html_encode(options.app)}"
+                        class="window-app-iframe" 
+                        allowtransparency="true" allowpaymentrequest="true" allowfullscreen="true"
+                        frameborder="0" webkitallowfullscreen="webkitallowfullscreen" mozallowfullscreen="mozallowfullscreen"
+                        ${options.iframe_url ? 'src="'+ html_encode(options.iframe_url)+'"' : ''}
+                        ${options.iframe_srcdoc ? 'srcdoc="'+ html_encode(options.iframe_srcdoc) +'"' : ''}
+                        allow = "accelerometer; camera; encrypted-media; display-capture; geolocation; gyroscope; microphone; midi; clipboard-read; clipboard-write; web-share; fullscreen;"
+                        sandbox="allow-forms allow-modals allow-pointer-lock allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-top-navigation-by-user-activation allow-downloads allow-presentation"></iframe>`;
+            }
+            // custom body
+            else if(options.body_content !== undefined){
+                h += options.body_content;
+            }
+
+            // Directory
+            if(options.is_dir){
+                // Detail layout header
+                h += window.explore_table_headers();
+
+                // Add 'This folder is empty' message by default
+                h += `<div class="explorer-empty-message">This folder is empty</div>`;
+
+                // Loading spinner
+                h += `<div class="explorer-loading-spinner">`;
+                    h +=`<svg style="display:block; margin: 0 auto; " xmlns="http://www.w3.org/2000/svg" height="24" width="24" viewBox="0 0 24 24"><title>circle anim</title><g fill="#212121" class="nc-icon-wrapper"><g class="nc-loop-circle-24-icon-f"><path d="M12 24a12 12 0 1 1 12-12 12.013 12.013 0 0 1-12 12zm0-22a10 10 0 1 0 10 10A10.011 10.011 0 0 0 12 2z" fill="#212121" opacity=".4"></path><path d="M24 12h-2A10.011 10.011 0 0 0 12 2V0a12.013 12.013 0 0 1 12 12z" data-color="color-2"></path></g><style>.nc-loop-circle-24-icon-f{--animation-duration:0.5s;transform-origin:12px 12px;animation:nc-loop-circle-anim var(--animation-duration) infinite linear}@keyframes nc-loop-circle-anim{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}</style></g></svg>`;
+                    h += `<p class="explorer-loading-spinner-msg">Loading...</p>`;
+                h += `</div>`;
+            }
+
+        h += `</div>`;
+
+        // Explorer footer
+        if(options.is_dir && !options.is_saveFileDialog && !options.is_openFileDialog && !options.is_directoryPicker){
+            h += `<div class="explorer-footer">`
+                h += `<span class="explorer-footer-item-count"></span>`;
+                h += `<span class="explorer-footer-seperator">|</span>`;
+                h += `<span class="explorer-footer-selected-items-count"></span>`;
+            h += `</div>`;
+        }
+
+        // is_saveFileDialog
+        if(options.is_saveFileDialog){
+            h += `<div class="window-filedialog-prompt">`;
+                h += `<div style="display:flex;">`;
+                    h += `<input type="text" class="savefiledialog-filename" autocorrect="off" spellcheck="false" value="${html_encode(options.saveFileDialog_default_filename) ?? ''}">`;
+                    h += `<button class="button button-small filedialog-cancel-btn">Cancel</button>`;
+                    h += `<button class="button `;
+                        if(options.saveFileDialog_default_filename === undefined || options.saveFileDialog_default_filename === '')
+                            h+= `disabled `; 
+                    h += `button-small button-primary savefiledialog-save-btn">Save</button>`;
+                h += `</div>`;
+            h += `</div>`;
+        }
+
+        // is_openFileDialog
+        else if(options.is_openFileDialog){
+            h += `<div class="window-filedialog-prompt">`;
+                h += `<div style="text-align:right;">`;
+                    h += `<button class="button button-small filedialog-cancel-btn">Cancel</button>`;
+                    h += `<button class="button disabled button-small button-primary openfiledialog-open-btn">Open</button>`;
+                h += `</div>`;
+            h += `</div>`;
+        }
+
+        // is_directoryPicker
+        else if(options.is_directoryPicker){
+            h += `<div class="window-filedialog-prompt">`;
+                h += `<div style="text-align:right;">`;
+                    h += `<button class="button button-small filedialog-cancel-btn">Cancel</button>`;
+                    h += `<button class="button button-small button-primary directorypicker-select-btn" style="margin-left:10px;">Select</button>`;
+                h += `</div>`;
+            h += `</div>`;
+        }
+    h += `</div>`;
+
+    // backdrop
+    if(options.backdrop){
+        let backdrop_zindex;
+        // backdrop should also cover over taskbar
+        let taskbar_zindex = $('.taskbar').css('z-index');
+        if(taskbar_zindex === null || taskbar_zindex === undefined)
+            backdrop_zindex = zindex;
+        else{
+            taskbar_zindex = parseInt(taskbar_zindex);
+            backdrop_zindex = taskbar_zindex > zindex ? taskbar_zindex : zindex;
+        }
+        
+        h = `<div class="window-backdrop" style="z-index:${backdrop_zindex};">` + h + `</div>`;
+    }
+
+    // Append
+    $(el_body).append(h);
+    
+    // disable_parent_window
+    if(options.disable_parent_window && options.parent_uuid !== null){
+        const $el_parent_window = $(`.window[data-element_uuid="${options.parent_uuid}"]`);
+        const $el_parent_disable_mask = $el_parent_window.find('.window-disable-mask');
+        //disable parent window
+        $el_parent_window.addClass('window-disabled')
+        $el_parent_disable_mask.show();
+        $el_parent_disable_mask.css('z-index', parseInt($el_parent_window.css('z-index')) + 1);
+        $el_parent_window.find('iframe').blur();
+    }
+    
+    // Add Taskbar Item
+    if(!options.is_openFileDialog && !options.is_saveFileDialog && !options.is_directoryPicker && options.show_in_taskbar){
+        // add icon if there is no similar app already open
+        if($(`.taskbar-item[data-app="${options.app}"]`).length === 0){
+            UITaskbarItem({
+                icon: options.icon,
+                name: options.title,
+                app: options.app,
+                open_windows_count: 1,
+                onClick: function(){
+                    let open_window_count = parseInt($(`.taskbar-item[data-app="${options.app}"]`).attr('data-open-windows'));
+                    if(open_window_count === 0){
+                        launch_app({
+                            name: options.app,
+                        }) 
+                    }else{
+                        return false;
+                    }
+                }
+            });
+            if(options.app)
+                $(`.taskbar-item[data-app="${options.app}"] .active-taskbar-indicator`).show();
+        }else{
+            if(options.app){
+                $(`.taskbar-item[data-app="${options.app}"]`).attr('data-open-windows', parseInt($(`.taskbar-item[data-app="${options.app}"]`).attr('data-open-windows')) + 1);
+                $(`.taskbar-item[data-app="${options.app}"] .active-taskbar-indicator`).show();
+            }
+        }
+    }
+    
+    // if directory, set window_nav_history and window_nav_history_current_position
+    if(options.is_dir){
+        window_nav_history[win_id] = [options.path];
+        window_nav_history_current_position[win_id] = 0;
+    }
+
+    // get all the elements needed
+    const el_window = document.querySelector(`#window-${win_id}`);
+    const el_window_head = document.querySelector(`#window-${win_id} > .window-head`);
+    const el_window_sidebar = document.querySelector(`#window-${win_id} > .window-sidebar`);
+    const el_window_head_title = document.querySelector(`#window-${win_id} > .window-head .window-head-title`);
+    const el_window_head_icon = document.querySelector(`#window-${win_id} > .window-head .window-head-icon`);
+    const el_window_head_scale_btn = document.querySelector(`#window-${win_id} > .window-head > .window-scale-btn`);
+    const el_window_navbar_back_btn = document.querySelector(`#window-${win_id} .window-navbar-btn-back`);
+    const el_window_navbar_forward_btn = document.querySelector(`#window-${win_id} .window-navbar-btn-forward`);
+    const el_window_navbar_up_btn = document.querySelector(`#window-${win_id} .window-navbar-btn-up`);
+    const el_window_body = document.querySelector(`#window-${win_id} > .window-body`);
+    const el_window_app_iframe = document.querySelector(`#window-${win_id} > .window-body > .window-app-iframe`);
+    const el_savefiledialog_filename = document.querySelector(`#window-${win_id} .savefiledialog-filename`);
+    const el_savefiledialog_save_btn = document.querySelector(`#window-${win_id} .savefiledialog-save-btn`);
+    const el_filedialog_cancel_btn = document.querySelector(`#window-${win_id} .filedialog-cancel-btn`);
+    const el_openfiledialog_open_btn = document.querySelector(`#window-${win_id} .openfiledialog-open-btn`);
+    const el_directorypicker_select_btn = document.querySelector(`#window-${win_id} .directorypicker-select-btn`);
+
+    if(options.is_maximized){
+        // save original size and position
+        $(el_window).attr({
+            'data-left-before-maxim': ((window.innerWidth/2 - 680/2) +(window.window_counter-1) % 10 * 30) + 'px',
+            'data-top-before-maxim': default_window_top,
+            'data-width-before-maxim': '680px',
+            'data-height-before-maxim': '350px',
+            'data-is_maximized': '1',
+        });
+
+        // shrink icon
+        $(el_window).find('.window-scale-btn>img').attr('src', window.icons['scale-down-3.svg']);
+
+        // set new size and position
+        $(el_window).css({
+            'top': window.toolbar_height + 'px',
+            'left': '0',
+            'width': '100%',
+            'height': `calc(100% - ${window.taskbar_height + window.toolbar_height + 1}px)`,
+            'transform': 'none',
+        });
+    }
+
+    // when a window is created, focus is brought to it and 
+    // therefore it is the current active element
+    window.active_element =  el_window;
+
+    // set name
+    $(el_window_head_title).html(html_encode(options.title));
+
+    // set icon
+    if(options.icon)
+        $(el_window_head_icon).attr('src', options.icon.image ?? options.icon);
+    
+    // root folder of a shared user?
+    if(options.is_dir && (options.path.split('/').length - 1) === 1 && options.path !== '/'+window.user.username){
+        $(el_window_head_icon).attr('src', window.icons['shared.svg']);
+    }
+    // focus on this window and deactivate other windows
+    $(el_window).focusWindow();
+
+    if (animate_window_opening) {
+        // animate window opening
+        $(el_window).css({
+            'opacity': '0',
+            'transition': 'opacity 70ms ease-in-out',
+        });
+
+        // Use requestAnimationFrame to schedule a function to run at the next repaint of the browser window
+        requestAnimationFrame(() => {
+            // Change the window's opacity to 1 and scale to 1 to create an opening effect
+            $(el_window).css({
+                'opacity': '1',
+            })
+
+            // Set a timeout to run after the transition duration (100ms) 
+            setTimeout(function () {
+                // Remove the transition property, so future CSS changes won't be animated
+                $(el_window).css({
+                    'transition': 'none',
+                })
+            }, 70);
+        });
+    }
+
+    // onAppend() - using show() is a hack to make sure window is visible AND onAppend is called when
+    // window is actually appended and usable.
+    $(el_window).show(0, function(e){
+        // if SaveFileDialog, bring focus to the el_savefiledialog_filename and select all
+        if(options.is_saveFileDialog){
+            let item_name = el_savefiledialog_filename.value;
+            const extname = path.extname('/' + item_name);
+            if(extname !== '')
+            el_savefiledialog_filename.setSelectionRange(0, item_name.length - extname.length)
+            else
+                $(el_savefiledialog_filename).select();
+    
+            $(el_savefiledialog_filename).get(0).focus({preventScroll:true});
+        }
+        //set custom window css
+        $(el_window).css(options.window_css);
+        // onAppend()
+        if(options.onAppend && typeof options.onAppend === 'function'){
+            options.onAppend(el_window);
+        }
+    })
+
+    if(options.is_saveFileDialog){
+        //------------------------------------------------
+        // SaveFileDialog > Save button
+        //------------------------------------------------
+        $(el_savefiledialog_save_btn).on('click', function(e){
+            const filename = $(el_savefiledialog_filename).val();
+            try{
+                validate_fsentry_name(filename)
+            }catch(err){
+                UIAlert(err.message, 'error', 'OK')
+                return;
+            }
+            const target_path = path.join($(el_window).attr('data-path'), filename);
+            if(options.onSaveFileDialogSave && typeof options.onSaveFileDialogSave === 'function')
+                options.onSaveFileDialogSave(target_path, el_window)
+        })
+
+        //------------------------------------------------
+        // SaveFileDialog > Enter
+        //------------------------------------------------
+        $(el_savefiledialog_filename).on('keypress', function(event) {
+            if(event.which === 13){
+                $(el_savefiledialog_save_btn).trigger('click');
+            }
+        })
+
+        //------------------------------------------------
+        // Enable/disable Save button based on input
+        //------------------------------------------------
+        $(el_savefiledialog_filename).bind('keydown change input paste', function(){
+            if($(this).val() !== '')
+                $(el_savefiledialog_save_btn).removeClass('disabled');
+            else
+                $(el_savefiledialog_save_btn).addClass('disabled');
+        })
+        $(el_savefiledialog_filename).get(0).focus({preventScroll:true});
+    }
+
+    if(options.is_openFileDialog){
+        //------------------------------------------------
+        // OpenFileDialog > Open button
+        //------------------------------------------------
+        $(el_openfiledialog_open_btn).on('click', async function(e){
+            const selected_els = $(el_window).find('.item-selected[data-is_dir="0"]');
+            let selected_files;
+
+            // No item selected
+            if(selected_els.length === 0)
+                return;
+            // ------------------------------------------------
+            // Item(s) selected
+            // ------------------------------------------------
+            else{
+                selected_files = []
+                // an array that hold the items to sign
+                const items_to_sign = [];
+
+                // prepare items to sign
+                for(let i=0; i<selected_els.length; i++)
+                    items_to_sign.push({uid: $(selected_els[i]).attr('data-uid'), action: 'write', path: $(selected_els[i]).attr('data-path')});
+
+                // sign items
+                selected_files = await puter.fs.sign(options.initiating_app_uuid, items_to_sign);
+                selected_files = selected_files.items;
+                selected_files = Array.isArray(selected_files) ? selected_files : [selected_files];
+
+                // change path of each item to preserve privacy
+                for(let i=0; i<selected_files.length; i++)
+                    selected_files[i].path = `~/` + selected_files[i].path.split('/').slice(2).join('/');
+            }
+
+            const ifram_msg_uid = $(el_window).attr('data-iframe_msg_uid');
+            if(options.return_to_parent_window){
+                window.opener.postMessage({
+                    msg: "fileOpenPicked", 
+                    original_msg_id: ifram_msg_uid, 
+                    items: Array.isArray(selected_files) ? [...selected_files] : [selected_files],
+                    // LEGACY SUPPORT, remove this in the future when Polotno uses the new SDK
+                    // this is literally put in here to support Polotno's legacy code
+                    ...(selected_files.length === 1 && selected_files[0])
+                }, '*');
+
+                window.close();
+                window.open('','_self').close();
+            }
+            else if(options.parent_uuid){
+                // send event to iframe
+                const target_iframe = $(`.window[data-element_uuid="${options.parent_uuid}"]`).find('.window-app-iframe').get(0);
+                if(target_iframe){
+                    target_iframe.contentWindow.postMessage({
+                        msg: "fileOpenPicked", 
+                        original_msg_id: ifram_msg_uid, 
+                        items: Array.isArray(selected_files) ? [...selected_files] : [selected_files],
+                        // LEGACY SUPPORT, remove this in the future when Polotno uses the new SDK
+                        // this is literally put in here to support Polotno's legacy code
+                        ...(selected_files.length === 1 && selected_files[0])
+                    }, '*');
+                }
+                // focus on iframe
+                $(target_iframe).get(0)?.focus({preventScroll:true});
+
+                // send file_opened event
+                const file_opened_event = new CustomEvent('file_opened', {detail: Array.isArray(selected_files) ? [...selected_files] : [selected_files]});
+
+                // dispatch event to parent window
+                $(`.window[data-element_uuid="${options.parent_uuid}"]`).get(0)?.dispatchEvent(file_opened_event);
+
+                $(el_window).close();
+            }
+        })
+    }
+    else if(options.is_directoryPicker){
+        //------------------------------------------------
+        // DirectoryPicker > Select button
+        //------------------------------------------------
+        $(el_directorypicker_select_btn).on('click', async function(e){
+            const selected_els = $(el_window).find('.item-selected[data-is_dir="1"]');
+            let selected_dirs;
+            // ------------------------------------------------
+            // No item selected, return current directory
+            // ------------------------------------------------
+            if(selected_els.length === 0){
+                selected_dirs = await puter.fs.sign(options.initiating_app_uuid, {uid: $(el_window).attr('data-uid'), action: 'write'})
+                selected_dirs = selected_dirs.items;
+            }             
+
+            // ------------------------------------------------
+            // directorie(s) selected
+            // ------------------------------------------------
+            else{
+                selected_dirs = []
+                // an array that hold the items to sign
+                const items_to_sign = [];
+
+                // prepare items to sign
+                for(let i=0; i<selected_els.length; i++)
+                    items_to_sign.push({uid: $(selected_els[i]).attr('data-uid'), action: 'write', path: $(selected_els[i]).attr('data-path')});
+
+                // sign items
+                selected_dirs = await puter.fs.sign(options.initiating_app_uuid, items_to_sign);
+                selected_dirs = selected_dirs.items;
+                selected_dirs = Array.isArray(selected_dirs) ? selected_dirs : [selected_dirs];
+
+                // change path of each item to preserve privacy
+                for(let i=0; i<selected_dirs.length; i++)
+                    selected_dirs[i].path = `~/` + selected_dirs[i].path.split('/').slice(2).join('/');
+            }
+
+            const ifram_msg_uid = $(el_window).attr('data-iframe_msg_uid');
+
+            if(options.return_to_parent_window){
+                window.opener.postMessage({
+                    msg: "directoryPicked", 
+                    original_msg_id: ifram_msg_uid, 
+                    items: Array.isArray(selected_dirs) ? [...selected_dirs] : [selected_dirs],
+                    // LEGACY SUPPORT, remove this in the future when Polotno uses the new SDK
+                    // this is literally put in here to support Polotno's legacy code
+                    ...(selected_dirs.length === 1 && selected_dirs[0])
+                }, '*');
+
+                window.close();
+                window.open('','_self').close();
+            }
+            if(options.parent_uuid){
+                // Send directoryPicked event to iframe
+                const target_iframe = $(`.window[data-element_uuid="${options.parent_uuid}"]`).find('.window-app-iframe').get(0);
+                if(target_iframe){
+                    target_iframe.contentWindow.postMessage({
+                        msg: "directoryPicked", 
+                        original_msg_id: ifram_msg_uid, 
+                        items: Array.isArray(selected_dirs) ? [...selected_dirs] : [selected_dirs],
+                    }, '*');
+                }
+                $(target_iframe).get(0).focus({preventScroll:true});
+                $(el_window).close();
+            }
+        })
+    }
+
+    if(options.is_saveFileDialog || options.is_openFileDialog || options.is_directoryPicker){
+        //------------------------------------------------
+        // FileDialog > Cancel button
+        //------------------------------------------------
+        $(el_filedialog_cancel_btn).on('click', function(e){
+            if(options.return_to_parent_window){
+                window.close();
+                window.open('','_self').close();
+            }
+            $(el_window).hide(0, ()=>{
+                // re-anable parent window
+                $(`.window[data-element_uuid="${options.parent_uuid}"]`).removeClass('window-disabled');
+                $(`.window[data-element_uuid="${options.parent_uuid}"]`).find('.window-disable-mask').hide();
+                $(el_window).close();
+            })
+        })
+    }
+
+    if(options.is_dir){
+        navbar_path_droppable(el_window);
+        sidebar_item_droppable(el_window);
+        // --------------------------------------------------------
+        // Back button
+        // --------------------------------------------------------
+        $(el_window_navbar_back_btn).on('click', function(e){
+            // if history menu is open don't continue
+            if($(el_window_navbar_back_btn).hasClass('has-open-contextmenu'))
+                return;
+            // if ctrl/cmd are pressed, open in new window
+            if(e.ctrlKey || e.metaKey){
+                const dirpath = window_nav_history[win_id].at(window_nav_history_current_position[win_id] - 1);
+                UIWindow({
+                    path: dirpath,
+                    title: dirpath === '/' ? root_dirname : path.basename(dirpath),
+                    icon: window.icons['folder.svg'],
+                    // uid: $(el_item).attr('data-uid'),
+                    is_dir: true,
+                });
+            }
+            // ... otherwise, open in same window
+            else{
+                window_nav_history_current_position[win_id] > 0 && window_nav_history_current_position[win_id]--;
+                const new_path = window_nav_history[win_id].at(window_nav_history_current_position[win_id]);
+                // update window path
+                update_window_path(el_window, new_path);
+            }
+        })
+        // --------------------------------------------------------
+        // Back button click-hold
+        // --------------------------------------------------------
+        $(el_window_navbar_back_btn).on('taphold', function() {
+            let items = [];
+            const pos = el_window_navbar_back_btn.getBoundingClientRect();
+
+            for(let index = window_nav_history_current_position[win_id] - 1; index >= 0; index--){
+                const history_item = window_nav_history[win_id].at(index);
+
+                // build item for context menu
+                items.push({
+                    html: `<span>${history_item === window.home_path ? 'Home' : path.basename(history_item)}</span>`,
+                    val: index,
+                    onClick: async function(e){
+                        let history_index = e.value;
+                        window_nav_history_current_position[win_id] = history_index;
+                        const new_path = window_nav_history[win_id].at(window_nav_history_current_position[win_id]);
+                        // if ctrl/cmd are pressed, open in new window
+                        if(e.ctrlKey || e.metaKey && (new_path !== undefined && new_path !== null)){
+                            UIWindow({
+                                path: new_path,
+                                title: new_path === '/' ? root_dirname : path.basename(new_path),
+                                icon: window.icons['folder.svg'],
+                                is_dir: true,
+                            });
+                        }
+                        // update window path
+                        else{
+                            update_window_path(el_window, new_path);
+                        }
+                    }
+                })
+            }
+
+            // Menu
+            UIContextMenu({
+                position: {top: pos.top + pos.height + 3, left: pos.left},
+                parent_element: el_window_navbar_back_btn,
+                items: items,
+            })
+        })
+        // --------------------------------------------------------
+        // Forward button
+        // --------------------------------------------------------
+        $(el_window_navbar_forward_btn).on('click', function(e){
+            // if history menu is open don't continue
+            if($(el_window_navbar_forward_btn).hasClass('has-open-contextmenu'))
+                return;
+            // if ctrl/cmd are pressed, open in new window
+            if(e.ctrlKey || e.metaKey){
+                const dirpath = window_nav_history[win_id].at(window_nav_history_current_position[win_id] + 1);
+                UIWindow({
+                    path: dirpath,
+                    title: dirpath === '/' ? root_dirname : path.basename(dirpath),
+                    icon: window.icons['folder.svg'],
+                    // uid: $(el_item).attr('data-uid'),
+                    is_dir: true,
+                });
+            }
+            // ... otherwise, open in same window
+            else{
+                window_nav_history_current_position[win_id]++;
+                // get last path in history
+                const target_path = window_nav_history[win_id].at(window_nav_history_current_position[win_id]);
+                // update window path
+                if(target_path !== undefined){
+                    update_window_path(el_window, target_path);
+                }
+            }
+        })
+        // --------------------------------------------------------
+        // forward button click-hold
+        // --------------------------------------------------------
+        $(el_window_navbar_forward_btn).on('taphold', function() {
+            let items = [];
+            const pos = el_window_navbar_forward_btn.getBoundingClientRect();
+
+            for(let index = window_nav_history_current_position[win_id] + 1; index < window_nav_history[win_id].length; index++){
+                const history_item = window_nav_history[win_id].at(index);
+
+                // build item for context menu
+                items.push({
+                    html: `<span>${history_item === window.home_path ? 'Home' : path.basename(history_item)}</span>`,
+                    val: index,
+                    onClick: async function(e){
+                        let history_index = e.value;
+                        window_nav_history_current_position[win_id] = history_index;
+                        const new_path = window_nav_history[win_id].at(window_nav_history_current_position[win_id]);
+                        // if ctrl/cmd are pressed, open in new window
+                        if(e.ctrlKey || e.metaKey && (new_path !== undefined && new_path !== null)){
+                            UIWindow({
+                                path: new_path,
+                                title: new_path === '/' ? root_dirname : path.basename(new_path),
+                                icon: window.icons['folder.svg'],
+                                is_dir: true,
+                            });
+                        }
+                        // update window path
+                        else{
+                            update_window_path(el_window, new_path);
+                        }
+                    }
+                })
+            }
+
+            // Menu
+            UIContextMenu({                    
+                parent_element: el_window_navbar_forward_btn,
+                position: {top: pos.top + pos.height + 3, left: pos.left},
+                items: items,
+            })
+        })
+
+        // --------------------------------------------------------
+        // Up button
+        // --------------------------------------------------------
+        $(el_window_navbar_up_btn).on('click', function(e){
+            const target_path = path.resolve(path.join($(el_window).attr('data-path'), '..'));
+            // if ctrl/cmd are pressed, open in new window
+            if(e.ctrlKey || e.metaKey && (target_path !== undefined && target_path !== null)){
+                UIWindow({
+                    path: target_path,
+                    title: target_path === '/' ? root_dirname : path.basename(target_path),
+                    icon: window.icons['folder.svg'],
+                    // uid: $(el_item).attr('data-uid'),
+                    is_dir: true,
+                });
+            }
+            // ... otherwise, open in same window
+            else if(target_path !== undefined && target_path !== null){
+                // update history
+                window_nav_history[win_id] = window_nav_history[win_id].slice(0, window_nav_history_current_position[win_id]+1);
+                window_nav_history[win_id].push(target_path);
+                window_nav_history_current_position[win_id]++;
+                // update window path
+                update_window_path(el_window, target_path);
+            }
+        })
+
+        const layouts = ['icons', 'list', 'details'];
+
+        $(el_window).find('.window-navbar-layout-settings').on('contextmenu taphold', function() {
+            let cur_layout = $(el_window).attr('data-layout');
+            let items = [];
+            for(let i=0; i<layouts.length; i++){
+                items.push({
+                    html: `<span style="text-transform: capitalize;">${layouts[i]}</span>`,
+                    icon: cur_layout === layouts[i] ? '✓' : '',
+                    onClick: async function(e){
+                        update_window_layout(el_window, layouts[i]);
+                        window.set_layout($(el_window).attr('data-uid'), layouts[i]);
+                    }
+                })
+            }
+            UIContextMenu({
+                parent_element: this,
+                items: items,
+            })
+        })
+        $(el_window).find('.window-navbar-layout-settings').on('click', function() {
+            let cur_layout = $(el_window).attr('data-layout');
+            for(let i=0; i<layouts.length; i++){
+                if(cur_layout === layouts[i]){
+                    if(i === layouts.length - 1){
+                        update_window_layout(el_window, layouts[0]);
+                        window.set_layout($(el_window).attr('data-uid'), layouts[0]);
+                    }else{
+                        update_window_layout(el_window, layouts[i+1]);
+                        window.set_layout($(el_window).attr('data-uid'), layouts[i+1]);
+                    }
+                    break;
+                }
+            }
+        })
+        // --------------------------------------------------------
+        // directory content
+        // --------------------------------------------------------
+        //auth
+        if(!is_auth() && !(await UIWindowLogin()))
+            return;
+
+        // get directory content
+        refresh_item_container(el_window_body, options);
+    }
+
+    // set iframe url
+    if (options.iframe_url){
+        $(el_window_app_iframe).attr('src', options.iframe_url)
+        //bring focus to iframe
+        el_window_app_iframe.contentWindow.focus();
+    }
+    // set the position of window
+    if(!options.is_maximized){
+        $(el_window).css('top', options.top)
+        $(el_window).css('left', options.left)
+    }
+    $(el_window).css('display', 'block');
+
+    // mousedown on the window body will unselect selected items if neither ctrl nor command are pressed
+    $(el_window_body).on('mousedown', function(e){
+        if($(e.target).hasClass('window-body') && !e.ctrlKey && !e.metaKey){
+            $(el_window_body).find('.item-selected').removeClass('item-selected');
+            update_explorer_footer_selected_items_count(el_window);
+            // if this is openFileDialog, disable the Open button
+            if(options.is_openFileDialog)
+                $(el_openfiledialog_open_btn).addClass('disabled')
+        }
+    })
+
+    // on_close event
+    $(el_window).on('remove', function(e){
+        // if on_close callback is set, call it
+        options.on_close?.();
+    })
+
+    // --------------------------------------------------------
+    // Backdrop click
+    // --------------------------------------------------------
+    if(options.backdrop && options.close_on_backdrop_click){
+        $(el_window).closest('.window-backdrop').on('mousedown', function(e){
+            if($(e.target).hasClass('window-backdrop')){
+                $(el_window).close();
+            }
+        })
+    }
+    // --------------------------------------------------------
+    // Selectable
+    // only for Desktop screens
+    // --------------------------------------------------------
+    if(options.is_dir && options.selectable_body && !isMobile.phone && !isMobile.tablet){
+        let selected_ctrl_items = [];
+        // init viselect
+        const selection = new SelectionArea({
+            selectionContainerClass: '.selection-area-container',
+            container: `#window-body-${win_id}`,
+            selectables: [`#window-body-${win_id} .item`],
+            startareas: [`#window-body-${win_id}`],
+            boundaries: [`#window-body-${win_id}`],
+            behaviour: {
+                overlap: 'drop',
+                intersect: 'touch',
+                startThreshold: 10,
+                scrolling: {
+                    speedDivider: 10,
+                    manualSpeed: 750,
+                    startScrollMargins: {x: 0, y: 0}
+                }
+            },
+            features: {
+                touch: true,
+                range: true,
+                singleTap: {
+                    allow: true,
+                    intersect: 'native'
+                }
+            }
+        });
+        
+        selection.on('beforestart', ({store, event}) => {
+            selected_ctrl_items = [];
+            return $(event.target).is(`#window-body-${win_id}`)
+        })
+        .on('beforedrag', evt => {
+        })
+        .on('start', ({store, event}) => {
+            if (!event.ctrlKey && !event.metaKey) {
+        
+                for (const el of store.stored) {
+                    el.classList.remove('item-selected');
+                }
+        
+                selection.clearSelection();
+            }
+        })
+        .on('move', ({store: {changed: {added, removed}}, event}) => {
+            for (const el of added) {
+                // if ctrl or meta key is pressed and the item is already selected, then unselect it
+                if((event.ctrlKey || event.metaKey) && $(el).hasClass('item-selected')){
+                    el.classList.remove('item-selected');
+                    selected_ctrl_items.push(el);
+                }
+                // otherwise select it
+                else{
+                    el.classList.add('item-selected');
+                    // the latest selected item is the active element
+                    active_element = el;
+                }
+            }
+        
+            for (const el of removed) {
+                el.classList.remove('item-selected');
+                // in case this item was selected by ctrl+click before, then reselect it again
+                if(selected_ctrl_items.includes(el))
+                    $(el).addClass('item-selected');
+            }
+
+            update_explorer_footer_selected_items_count(el_window);
+
+            // If this is openFileDialog, enable/disable the Open button accordingly
+            if(options.is_openFileDialog && $(el_window).find('.item-selected').length)
+                $(el_openfiledialog_open_btn).removeClass('disabled')
+            else
+                $(el_openfiledialog_open_btn).addClass('disabled')
+        })
+        .on('stop', ({store, event}) => {
+            // If this is openFileDialog, enable/disable the Open button accordingly
+            if(options.is_openFileDialog && $(el_window).find('.item-selected').length)
+                $(el_openfiledialog_open_btn).removeClass('disabled')
+            else
+                $(el_openfiledialog_open_btn).addClass('disabled')
+        });   
+    }
+
+    // --------------------------------------------------------
+    // Droppable
+    // --------------------------------------------------------
+    $(el_window_body).droppable({
+        accept: '.item',
+        greedy: true,
+        tolerance: "pointer",
+        drop: async function( e, ui ) {
+            // check if item was actually dropped on this window
+            if($(mouseover_window).attr('data-id') !== $(el_window).attr('data-id'))
+                return;
+
+            // can't drop anything here but a UIItem
+            if(!$(ui.draggable).hasClass('item'))
+                return;
+
+            // --------------------------------------------------
+            // In case this was dropped on an App window
+            // --------------------------------------------------
+            if(el_window_app_iframe !== null){
+                const items_to_move = []
+
+                // first item
+                items_to_move.push(ui.draggable); 
+
+                // all subsequent items
+                const cloned_items = document.getElementsByClassName('item-selected-clone');
+                for(let i =0; i<cloned_items.length; i++){
+                    const source_item = document.getElementById('item-' + $(cloned_items[i]).attr('data-id'));
+                    if(source_item !== null)
+                        items_to_move.push(source_item);
+                }
+
+                // sign all items
+                const items_to_sign = []
+
+                // prepare items to sign
+                for(let i=0; i<items_to_move.length; i++)
+                    items_to_sign.push({uid: $(items_to_move[i]).attr('data-uid'), action: 'write', path: $(items_to_move[i]).attr('data-path')});
+
+                // sign items
+                let signatures = await puter.fs.sign(options.app_uuid, items_to_sign);
+                signatures = signatures.items;
+                signatures = Array.isArray(signatures) ? signatures : [signatures];
+
+                // prepare items
+                let items = [];
+                for (let index = 0; index < signatures.length; index++) {
+                    const item = signatures[index];
+                    items.push({
+                        name: item.fsentry_name,
+                        readURL: item.read_url,
+                        writeURL: item.write_url,
+                        metadataURL: item.metadata_url,
+                        isDirectory: item.fsentry_is_dir,
+                        path: `~/` + item.path.split('/').slice(2).join('/'),
+                        uid: item.uid,
+                    })
+                }
+                
+                // send to app iframe
+                el_window_app_iframe.contentWindow.postMessage({
+                    msg: "itemsOpened", 
+                    original_msg_id: $(el_window).attr('data-iframe_msg_uid'), 
+                    items: items,
+                }, '*');
+
+                // if item is dragged over an app iframe, highlight the iframe
+                var rect = el_window_app_iframe.getBoundingClientRect();
+
+                // if mouse is inside iframe, send drag message to iframe
+                el_window_app_iframe.contentWindow.postMessage({msg: "drop", x: (mouseX - rect.left), y: (mouseY - rect.top), items: items}, '*');
+
+                // bring focus to this window
+                $(el_window).focusWindow();
+            }
+
+            // if this window is not a directory, cancel drop.
+            // why not simply only launch droppable on directories? this is because 
+            // if a window is not droppable and an item is dropped on it, the app will think
+            // it was dropped on desktop.
+            if(!options.is_dir){
+                return false;
+            }
+            // If dropped on the same window, do not proceed
+            if($(ui.draggable).closest('.item-container').attr('data-path') === $(mouseover_window).attr('data-path') && !e.ctrlKey){
+                return;
+            }
+            // If ctrl is pressed and source is Trashed, cancel whole operation
+            if(e.ctrlKey && path.dirname($(ui.draggable).attr('data-path')) === window.trash_path)
+                return;
+
+            // Unselect already selected items
+            $(el_window_body).find('.item-selected').removeClass('item-selected')
+
+            const items_to_move = []
+
+            // first item
+            items_to_move.push(ui.draggable); 
+
+            // all subsequent items
+            const cloned_items = document.getElementsByClassName('item-selected-clone');
+            for(let i =0; i<cloned_items.length; i++){
+                const source_item = document.getElementById('item-' + $(cloned_items[i]).attr('data-id'));
+                if(source_item !== null){
+                    items_to_move.push(source_item);
+                }
+            }
+
+            // If ctrl key is down, copy items. Except if target is Trash
+            if(e.ctrlKey && $(mouseover_window).attr('data-path') !== window.trash_path){
+                // Copy items
+                copy_items(items_to_move, $(mouseover_window).attr('data-path'))
+            }
+
+            // if alt key is down, create shortcut items
+            else if(e.altKey){
+                items_to_move.forEach((item_to_move) => {
+                    create_shortcut(
+                        path.basename($(item_to_move).attr('data-path')), 
+                        $(item_to_move).attr('data-is_dir') === '1', 
+                        $(mouseover_window).attr('data-path'), 
+                        null, 
+                        $(item_to_move).attr('data-shortcut_to') === '' ? $(item_to_move).attr('data-uid') : $(item_to_move).attr('data-shortcut_to'),
+                        $(item_to_move).attr('data-shortcut_to_path') === '' ? $(item_to_move).attr('data-path') : $(item_to_move).attr('data-shortcut_to_path'),
+                    );
+                });
+            }
+            // otherwise, move items
+            else{
+                move_items(items_to_move, $(mouseover_window).attr('data-path'));
+            }
+        },
+        over: function(event, ui){
+            // Don't do anything if the dragged item is NOT a UIItem
+            if(!$(ui.draggable).hasClass('item'))
+                return;
+        },
+        out: function(event, ui){
+            // Don't do anything if the dragged item is NOT a UIItem
+            if(!$(ui.draggable).hasClass('item'))
+                return;
+        }
+    });
+
+    // --------------------------------------------------------
+    // Double Click on Head
+    // double click on a window head will maximize or shrink window
+    // only maximize/shrink if window is marked `is_resizable`
+    // --------------------------------------------------------
+    if(options.is_resizable){
+        $(el_window_head).dblclick(function () {
+            scale_window(el_window);
+        })
+    }
+
+    $(el_window_head).mousedown(function () {
+        if(window_is_snapped){
+            $( el_window ).draggable( "option", "cursorAt", { left: width_before_snap/2 } );
+        }
+    })
+
+    // --------------------------------------------------------
+    // Click On The `Scale` Button 
+    // (the little rectangle in the window head)
+    // --------------------------------------------------------
+    if(options.is_resizable){
+        $(el_window_head_scale_btn).click(function () {
+            scale_window(el_window);
+        })
+    }
+
+    // --------------------------------------------------------
+    // Dragster
+    // If a local item is dragged over this window, bring it to front
+    // --------------------------------------------------------
+    let drag_enter_timeout;
+    $(el_window).dragster({
+        enter: function (dragsterEvent, event) {
+            // make sure to cancel any previous timeouts otherwise the window will be brought to front multiple times
+            clearTimeout(drag_enter_timeout);
+            // If items are dragged over this window long enough, bring it to front
+            drag_enter_timeout = setTimeout(function(){
+                // focus window
+                $(el_window).focusWindow();
+            }, 1400);
+        },
+        leave: function (dragsterEvent, event) {
+            // cancel the timeout for 'bringing window to front'
+            clearTimeout(drag_enter_timeout);
+        },
+        drop: function (dragsterEvent, event) {
+            // cancel the timeout for 'bringing window to front'
+            clearTimeout(drag_enter_timeout);
+        },
+        over: function (dragsterEvent, event) {
+            // cancel the timeout for 'bringing window to front'
+            clearTimeout(drag_enter_timeout);
+        }
+    });
+
+    // --------------------------------------------------------
+    // Dragster
+    // Allow dragging of local files onto this window, if it's is_dir
+    // --------------------------------------------------------
+    $(el_window_body).dragster({
+        enter: function (dragsterEvent, event) {
+            if(options.is_dir){
+                // remove any context menu that might be open
+                $('.context-menu').remove();
+            
+                // highlight this item container
+                $(el_window).find('.item-container').addClass('item-container-active');
+            }
+        },
+        leave: function (dragsterEvent, event) {
+            if(options.is_dir){
+                $(el_window).find('.item-container').removeClass('item-container-active');
+            }
+        },
+        drop: function (dragsterEvent, event) {
+            const e = event.originalEvent;
+            if(options.is_dir){
+                // if files were dropped...
+                if(e.dataTransfer?.items?.length>0){
+                    upload_items(e.dataTransfer.items, $(el_window).attr('data-path'))
+                }
+                // de-highlight all windows
+                $('.item-container').removeClass('item-container-active');
+            }
+            e.stopPropagation();
+            e.preventDefault();
+            return false;
+        }
+    });
+    
+    // --------------------------------------------------------
+    // Close button
+    // --------------------------------------------------------
+    $(`#window-${win_id} > .window-head > .window-close-btn`).click(function () {
+        $(el_window).close({
+            shrink_to_target: options.on_close_shrink_to_target
+        });
+    })
+
+    // --------------------------------------------------------
+    // Minimize button
+    // --------------------------------------------------------
+    $(`#window-${win_id} > .window-head > .window-minimize-btn`).click(function () {
+        $(el_window).hideWindow();
+    })
+
+    // --------------------------------------------------------
+    // Draggable
+    // --------------------------------------------------------
+    let width_before_snap = 0;
+    let height_before_snap = 0;
+    let window_is_snapped = false;
+    let snap_placeholder_active = false;
+    let snap_trigger_timeout;
+
+    if(options.is_draggable){
+        let window_snap_placeholder = $(
+            `<div class="window-snap-placeholder animate__animated animate__zoomIn animate__faster">
+                <div class="window-snap-placeholder-inner"></div>
+             </div>`
+        );
+
+        $(el_window).draggable({
+            start: function(e, ui){
+                // if window is snapped, unsnap it and reset its position to where it was before snapping
+                if(options.is_resizable && window_is_snapped){
+                    window_is_snapped = false;
+                    $(el_window).css({
+                        'width': width_before_snap,
+                        'height': height_before_snap + 'px',
+                    });
+
+                    // if at any point the window's width is "too small", hide the sidebar
+                    if($(el_window).width() < window_width_threshold_for_sidebar){
+                        if(width_before_snap >= window_width_threshold_for_sidebar && !sidebar_hidden){
+                            $(el_window_sidebar).hide();
+                        }
+                        sidebar_hidden = true;
+                    }
+                    // if at any point the window's width is "big enough", show the sidebar
+                    else if($(el_window).width() >= window_width_threshold_for_sidebar){
+                        if(sidebar_hidden){
+                            $(el_window_sidebar).show();
+                        }
+                        sidebar_hidden = false;
+                    }
+                }
+
+                $(el_window).addClass('window-dragging');
+
+                // since jquery draggable sets the z-index automatically we need this to 
+                // bring windows to the front when they are clicked.
+                last_window_zindex = parseInt($(el_window).css('z-index'));
+
+                //transform causes draggable to start inaccurately
+                $(el_window).css('transform', 'none');
+            },
+            drag: function ( e, ui ) {
+                $(el_window_app_iframe).css('pointer-events', 'none');
+                $('.window').css('pointer-events', 'none');
+                // jqueryui changes the z-index automatically, if the stay_on_top flag is set
+                // make sure window stays on top
+                $(`.window[data-stay_on_top="true"]`).css('z-index', 999999999)
+
+                if($(el_window).attr('data-is_maximized') === '1'){
+                    $(el_window).attr('data-is_maximized', '0');
+                    // maximize icon
+                    $(el_window_head_scale_btn).find('img').attr('src', window.icons['scale.svg']);
+                }
+                // --------------------------------------------------------
+                // Snap to screen edges
+                // --------------------------------------------------------
+                if(options.is_resizable){
+                    clearTimeout(snap_trigger_timeout);
+                    // if window is not snapped, check if it should be snapped
+                    snap_trigger_timeout = setTimeout(function(){
+                        // if cursor is not in a snap zone, don't snap
+                        if(!current_active_snap_zone){
+                            return;
+                        }
+                        // if dragging has stopped by now, don't snap
+                        if(!$(el_window).hasClass('window-dragging')){
+                            return;
+                        }
+
+                        // W
+                        if(!window_is_snapped && current_active_snap_zone === 'w'){
+                            window_snap_placeholder.css({
+                                'display': 'block',
+                                'width': '50%',
+                                'height': desktop_height,
+                                'top': toolbar_height,
+                                'left': 0,
+                                'z-index': last_window_zindex - 1,
+                            })
+                        }
+                        // NW
+                        else if(!window_is_snapped && current_active_snap_zone === 'nw'){
+                            window_snap_placeholder.css({
+                                'display': 'block',
+                                'width': '50%',
+                                'height': desktop_height/2,
+                                'top': toolbar_height,
+                                'left': 0,
+                                'z-index': last_window_zindex - 1,
+                            })
+                        }
+                        // NE
+                        else if(!window_is_snapped && current_active_snap_zone ==='ne'){
+                            window_snap_placeholder.css({
+                                'display': 'block',
+                                'width': '50%',
+                                'height': desktop_height/2,
+                                'top': toolbar_height,
+                                'left': desktop_width/2,
+                                'z-index': last_window_zindex - 1,
+                            })
+                        }
+                        // E
+                        else if(!window_is_snapped && current_active_snap_zone ==='e'){
+                            window_snap_placeholder.css({
+                                'display': 'block',
+                                'width': '50%',
+                                'height': desktop_height,
+                                'top': toolbar_height,
+                                'left': 'initial',
+                                'right': 0,
+                                'z-index': last_window_zindex - 1,
+                            })
+                        }
+                        // N
+                        else if(!window_is_snapped && current_active_snap_zone ==='n'){
+                            window_snap_placeholder.css({
+                                'display': 'block',
+                                'width': desktop_width,
+                                'height': desktop_height,
+                                'top': toolbar_height,
+                                'left': 0,
+                                'z-index': last_window_zindex - 1,
+                            })
+                        }
+                        // SW
+                        else if(!window_is_snapped && current_active_snap_zone ==='sw'){
+                            window_snap_placeholder.css({
+                                'display': 'block',
+                                'top': toolbar_height + desktop_height/2,
+                                'left': 0,
+                                'width': '50%',
+                                'height': desktop_height/2,
+                                'z-index': last_window_zindex - 1,
+                            })
+                        }
+                        // SE
+                        else if(!window_is_snapped && current_active_snap_zone ==='se'){
+                            window_snap_placeholder.css({
+                                'display': 'block',
+                                'top': toolbar_height + desktop_height/2,
+                                'left': desktop_width/2,
+                                'width': '50%',
+                                'height': desktop_height/2,
+                                'z-index': last_window_zindex - 1,
+                            })
+                        }
+
+                        // If snap placeholder is not active, append it and make it active
+                        if(!window_is_snapped && !snap_placeholder_active){
+                            snap_placeholder_active = true;
+                            $(el_body).append(window_snap_placeholder);
+                        }
+
+                        // save window size before snap
+                        width_before_snap = $(el_window).width();
+                        height_before_snap = $(el_window).height();
+                    }, 500);
+
+                    // if mouse is not in a snap zone, hide snap placeholder
+                    if(snap_placeholder_active && !current_active_snap_zone){
+                        snap_placeholder_active = false;
+                        window_snap_placeholder.fadeOut(80);
+                    }
+                }
+            },
+            stop: function () {
+                let window_will_snap = false;
+                $( el_window ).draggable( "option", "cursorAt", false );
+
+                $(el_window).removeClass('window-dragging');
+                $(el_window).attr({
+                    'data-orig-top': $(el_window).position().top, 
+                    'data-orig-left': $(el_window).position().left, 
+                })
+    
+                $(el_window_app_iframe).css('pointer-events', 'all');
+                $('.window').css('pointer-events', 'initial');
+
+                // jqueryui changes the z-index automatically, if the stay_on_top flag is set
+                // make sure window stays on top with the initial zindex though
+                $(`.window[data-stay_on_top="true"]`).each(function(){
+                    $(this).css('z-index', $(this).attr('data-initial_zindex'))
+                })
+
+                if(options.is_resizable && snap_placeholder_active && !window_is_snapped){
+                    window_will_snap = true;
+                    $(window_snap_placeholder).css('padding', 0);
+
+                    setTimeout(function(){
+                        // snap to w
+                        if(current_active_snap_zone === 'w'){
+                            $(el_window).css({
+                                'top': toolbar_height,
+                                'left': 0,
+                                'width': '50%',
+                                'height': desktop_height,
+                            })
+                        }
+                        // snap to nw
+                        else if(current_active_snap_zone === 'nw'){
+                            $(el_window).css({
+                                'top': toolbar_height,
+                                'left': 0,
+                                'width': '50%',
+                                'height': desktop_height/2,
+                            })
+                        }
+                        // snap to ne
+                        else if(current_active_snap_zone === 'ne'){
+                            $(el_window).css({
+                                'top': toolbar_height,
+                                'left': '50%',
+                                'width': '50%',
+                                'height': desktop_height/2,
+                            })
+                        }
+                        // snap to sw
+                        else if(current_active_snap_zone === 'sw'){
+                            $(el_window).css({
+                                'top': toolbar_height + desktop_height/2,
+                                'left': 0,
+                                'width': '50%',
+                                'height': desktop_height/2,
+                            })
+                        }
+                        // snap to se
+                        else if(current_active_snap_zone === 'se'){
+                            $(el_window).css({
+                                'top': toolbar_height + desktop_height/2,
+                                'left': desktop_width/2,
+                                'width': '50%',
+                                'height': desktop_height/2,
+                            })
+                        }
+                        // snap to e
+                        else if(current_active_snap_zone === 'e'){
+                            $(el_window).css({
+                                'top': toolbar_height,
+                                'left': '50%',
+                                'width': '50%',
+                                'height': desktop_height,
+                            })
+                        }
+                        // snap to n
+                        else if(current_active_snap_zone === 'n'){
+                            scale_window(el_window);
+                        }
+                        // snap placeholder is no longer active
+                        snap_placeholder_active = false;
+                        // hide snap placeholder
+                        window_snap_placeholder.css('display', 'none');
+                        window_snap_placeholder.css('padding', '10px');
+                        // mark window as snapped
+                        window_is_snapped = true;
+
+                        // if at any point the window's width is "too small", hide the sidebar
+                        if($(el_window).width() < window_width_threshold_for_sidebar){
+                            if(width_before_snap >= window_width_threshold_for_sidebar && !sidebar_hidden){
+                                $(el_window_sidebar).hide();
+                            }
+                            sidebar_hidden = true;
+                        }
+                        // if at any point the window's width is "big enough", show the sidebar
+                        else if($(el_window).width() >= window_width_threshold_for_sidebar){
+                            if(sidebar_hidden){
+                                $(el_window_sidebar).show();
+                            }
+                            sidebar_hidden = false;
+                        }
+                    }, 100);
+                }
+
+                // if window is dropped below the taskbar, move it up
+                // the lst '- 30' is to account for the window head
+                if($(el_window).position().top > window.innerHeight - taskbar_height - 30 && !window_will_snap){
+                    $(el_window).animate({
+                        top: window.innerHeight - taskbar_height - 60,
+                    }, 100);
+                }
+                // if window is dropped too far to the right, move it left
+                if($(el_window).position().left > window.innerWidth - 50 && !window_will_snap){
+                    $(el_window).animate({
+                        left: window.innerWidth - 50,
+                    }, 100);
+                }
+                // if window is dropped too far to the left, move it right
+                if(($(el_window).position().left + $(el_window).width() - 150 )< 0 && !window_will_snap){
+                    $(el_window).animate({
+                        left: -1 * ($(el_window).width() - 150),
+                    }, 100);
+                }
+            },
+            handle: `.window-head-draggable` + (options.draggable_body ? `, .window-body` : ``),
+            stack: `.window`,
+            scroll: false,
+            containment: '.window-container',
+        });
+    }
+
+    // --------------------------------------------------------
+    // Resizable
+    // --------------------------------------------------------
+    if(options.is_resizable){
+        if($(el_window).width() < window_width_threshold_for_sidebar){
+            $(el_window_sidebar).hide();
+            sidebar_hidden = true;
+        }
+
+        $(el_window).resizable({
+            handles: "n, ne, nw, e, s, se, sw, w",
+            minWidth: 200,
+            minHeight: 200,
+            start: function(){
+                $(el_window_app_iframe).css('pointer-events', 'none');
+                $('.window').css('pointer-events', 'none');
+            },
+            resize: function (e, ui) {
+                // if at any point the window's width is "too small", hide the sidebar
+                if(ui.size.width < window_width_threshold_for_sidebar){
+                    if(ui.originalSize.width >= window_width_threshold_for_sidebar && !sidebar_hidden){
+                        $(el_window_sidebar).hide();
+                    }
+                    sidebar_hidden = true;
+                }
+                // if at any point the window's width is "big enough", show the sidebar
+                else if(ui.size.width >= window_width_threshold_for_sidebar){
+                    if(sidebar_hidden){
+                        $(el_window_sidebar).show();
+                    }
+                    sidebar_hidden = false;
+                }
+
+                // when resizing the top of the window, make sure the window head is not hidden behind the toolbar
+                if($(el_window).position().top < toolbar_height){
+                    var difference = toolbar_height - $(el_window).position().top;
+                    $(el_window).css({
+                        'top': toolbar_height,
+                        'height': ui.size.height - difference  // Reduce the height by the difference
+                    });
+                    // don't resize
+                    return false;
+                }
+            },
+            stop: function () {
+                $(el_window_app_iframe).css('pointer-events', 'all');
+                $('.window').css('pointer-events', 'initial');
+                $(el_window_sidebar).resizable("option", "maxWidth", el_window.getBoundingClientRect().width/2);
+                $(el_window).attr({
+                    'data-orig-width': $(el_window).width(), 
+                    'data-orig-height': $(el_window).height(), 
+                })
+                // maximize icon
+                $(el_window_head_scale_btn).find('img').attr('src', window.icons['scale.svg']);
+                $(el_window).attr('data-is_maximized', '0');
+            },
+            containment: 'parent',
+        })
+    }
+
+    let side = $(el_window).find('.window-sidebar')
+    side.resizable({
+        handles: "e,w",
+        minWidth: 100,
+        maxWidth: el_window.getBoundingClientRect().width/2,
+        start: function(){
+            $(el_window_app_iframe).css('pointer-events', 'none');
+            $('.window').css('pointer-events', 'none');
+        },
+        stop: function () {
+            $(el_window_app_iframe).css('pointer-events', 'all');
+            $('.window').css('pointer-events', 'initial');
+            const new_width = $(el_window_sidebar).width();
+            // save new width in the cloud, to user's settings
+            setItem({key: "window_sidebar_width", value: new_width});
+            // save new width locally, to window object
+            window.window_sidebar_width = new_width;
+        }
+    })
+
+    // --------------------------------------------------------
+    // Alt/Option + Shift + click on window head will open a prompt to enter iframe url
+    // --------------------------------------------------------
+    $(el_window_head).on('click', function(e){
+        if(e.altKey && e.shiftKey && el_window_app_iframe !== null){
+            let url = prompt("Enter URL", options.iframe_url);
+            if(url){
+                $(el_window_app_iframe).attr('src', url);
+            }
+        }
+    })
+    // --------------------------------------------------------
+    // Head Context Menu
+    // --------------------------------------------------------
+    $(el_window_head).bind("contextmenu taphold", function (event) {
+        // dimiss taphold on regular devices
+        if(event.type==='taphold' && !isMobile.phone && !isMobile.tablet)
+            return;
+
+        const $target = $(event.target);
+
+        // Cases in which native ctx menu should be preserved
+        if(options.allow_native_ctxmenu || $target.hasClass('allow-native-ctxmenu') || $target.is('input') || $target.is('textarea'))
+            return true;
+        
+        // custom ctxmenu for all other elements
+        event.preventDefault();
+
+        // If window has no head, don't show ctxmenu
+        if(!options.has_head)
+            return;
+        
+        let menu_items = [];
+        // -------------------------------------------
+        // Maximize/Minimize
+        // -------------------------------------------
+        if(options.is_resizable){
+            menu_items.push({
+                html: $(el_window).attr('data-is_maximized') === '0' ? 'Maximize' : 'Restore',
+                onClick: function(){
+                    // maximize window
+                    scale_window(el_window);
+                }
+            });
+            menu_items.push({
+                html: 'Minimize',
+                onClick: function(){
+                    $(el_window).hideWindow();
+                }
+            });
+            // -
+            menu_items.push('-')
+        }
+        // -------------------------------------------
+        // Close
+        // -------------------------------------------
+        menu_items.push({
+            html: 'Close',
+            onClick: function(){
+                $(el_window).close();
+            }
+        });
+
+        UIContextMenu({
+            parent_element: el_window_head,
+            items: menu_items,
+            parent_id: win_id,
+        })                
+    })
+
+    // --------------------------------------------------------
+    // Body Context Menu
+    // --------------------------------------------------------
+    $(el_window_body).bind("contextmenu taphold", function (event) {
+        // dimiss taphold on regular devices
+        if(event.type==='taphold' && !isMobile.phone && !isMobile.tablet)
+            return;
+
+        const $target = $(event.target);
+
+        // Cases in which native ctx menu should be preserved
+        if(options.allow_native_ctxmenu || $target.hasClass('allow-native-ctxmenu') || $target.is('input') || $target.is('textarea'))
+            return true
+
+        // custom ctxmenu for all other elements
+        event.preventDefault();
+        if(options.allow_context_menu && event.target === el_window_body){
+            // Regular directories
+            if($(el_window).attr('data-path') !== trash_path){
+                UIContextMenu({
+                    parent_element: el_window_body,
+                    items: [
+                        // -------------------------------------------
+                        // Sort by
+                        // -------------------------------------------
+                        {
+                            html: "Sort by",
+                            items: [
+                                {
+                                    html: `Name`,
+                                    icon: $(el_window).attr('data-sort_by') === 'name' ? '✓' : '',
+                                    onClick: async function(){
+                                        sort_items(el_window_body, 'name', $(el_window).attr('data-sort_order'));
+                                        set_sort_by($(el_window).attr('data-uid'), 'name', $(el_window).attr('data-sort_order'))
+                                    }
+                                },
+                                {
+                                    html: `Date modified`,
+                                    icon: $(el_window).attr('data-sort_by') === 'modified' ? '✓' : '',
+                                    onClick: async function(){
+                                        sort_items(el_window_body, 'modified', $(el_window).attr('data-sort_order'));
+                                        set_sort_by($(el_window).attr('data-uid'), 'modified', $(el_window).attr('data-sort_order'))
+                                    }
+                                },
+                                {
+                                    html: `Type`,
+                                    icon: $(el_window).attr('data-sort_by') === 'type' ? '✓' : '',
+                                    onClick: async function(){
+                                        sort_items(el_window_body, 'type', $(el_window).attr('data-sort_order'));
+                                        set_sort_by($(el_window).attr('data-uid'), 'type', $(el_window).attr('data-sort_order'))
+                                    }
+                                },
+                                {
+                                    html: `Size`,
+                                    icon: $(el_window).attr('data-sort_by') === 'size' ? '✓' : '',
+                                    onClick: async function(){
+                                        sort_items(el_window_body, 'size', $(el_window).attr('data-sort_order'));
+                                        set_sort_by($(el_window).attr('data-uid'), 'size', $(el_window).attr('data-sort_order'))
+                                    }
+                                },
+                                // -------------------------------------------
+                                // -
+                                // -------------------------------------------
+                                '-',
+                                {
+                                    html: `Ascending`,
+                                    icon: $(el_window).attr('data-sort_order') === 'asc' ? '✓' : '',
+                                    onClick: async function(){
+                                        const sort_by = $(el_window).attr('data-sort_by')
+                                        sort_items(el_window_body, sort_by, 'asc');
+                                        set_sort_by($(el_window).attr('data-uid'), sort_by, 'asc')
+                                    }
+                                },
+                                {
+                                    html: `Descending`,
+                                    icon: $(el_window).attr('data-sort_order') === 'desc' ? '✓' : '',
+                                    onClick: async function(){
+                                        const sort_by = $(el_window).attr('data-sort_by')
+                                        sort_items(el_window_body, sort_by, 'desc');
+                                        set_sort_by($(el_window).attr('data-uid'), sort_by, 'desc')
+                                    }
+                                },
+
+                            ]
+                        },
+                        // -------------------------------------------
+                        // Refresh
+                        // -------------------------------------------
+                        {
+                            html: "Refresh",
+                            onClick: function(){
+                                refresh_item_container(el_window_body, options);
+                            }
+                        },
+                        // -------------------------------------------
+                        // -
+                        // -------------------------------------------
+                        '-',
+                        // -------------------------------------------
+                        // New
+                        // -------------------------------------------
+                        window.new_context_menu_item($(el_window).attr('data-path'), el_window_body),
+                        // -------------------------------------------
+                        // -
+                        // -------------------------------------------
+                        '-',
+                        // -------------------------------------------
+                        // Paste
+                        // -------------------------------------------
+                        {
+                            html: "Paste",
+                            disabled: (clipboard.length === 0 || $(el_window).attr('data-path') === '/') ? true : false,
+                            onClick: function(){
+                                if(clipboard_op === 'copy')
+                                    copy_clipboard_items($(el_window).attr('data-path'), el_window_body);
+                                else if(clipboard_op === 'move')
+                                    move_clipboard_items(el_window_body)
+                            }
+                        },
+                        // -------------------------------------------
+                        // Upload Here
+                        // -------------------------------------------
+                        {
+                            html: "Upload Here",
+                            disabled: $(el_window).attr('data-path') === '/' ? true : false,
+                            onClick: function(){
+                                init_upload_using_dialog(el_window_body, $(el_window).attr('data-path') + '/');
+                            }
+                        },
+                        // -------------------------------------------
+                        // Request Files
+                        // -------------------------------------------
+                        // {
+                        //     html: "Request Files",
+                        //     onClick: function(){
+                        //         UIWindowRequestFiles({dir_path: $(el_window).attr('data-path')})
+                        //     }
+                        // },
+                        // -------------------------------------------
+                        // -
+                        // -------------------------------------------
+                        '-',
+                        // -------------------------------------------
+                        // Publish As Website
+                        // -------------------------------------------
+                        {
+                            html: 'Publish As Website',
+                            disabled: !options.is_dir,
+                            onClick: async function () {
+                                if (window.require_email_verification_to_publish_website) {
+                                    if (window.user.is_temp &&
+                                        !await UIWindowSaveAccount({
+                                            send_confirmation_code: true,
+                                            message: 'Please create an account to proceed.',
+                                            window_options: {
+                                                backdrop: true,
+                                                close_on_backdrop_click: false,
+                                            }
+                                        }))
+                                        return;
+                                    else if (!window.user.email_confirmed && !await UIWindowEmailConfirmationRequired())
+                                        return;
+                                }
+                                UIWindowPublishWebsite($(el_window).attr('data-uid'), $(el_window).attr('data-name'), $(el_window).attr('data-path'));
+                            }
+                        },
+                        // -------------------------------------------
+                        // Deploy as App
+                        // -------------------------------------------
+                        {
+                            html: 'Deploy as App',
+                            disabled: !options.is_dir,
+                            onClick: async function () {
+                                launch_app({
+                                    name: 'dev-center',
+                                    file_path: $(el_window).attr('data-path'),
+                                    file_uid: $(el_window).attr('data-uid'),
+                                    params: {
+                                        source_path: $(el_window).attr('data-path'),
+                                    }
+                                })
+        
+                            }
+                        },
+                        // -------------------------------------------
+                        // -
+                        // -------------------------------------------
+                        '-',                        
+                        // -------------------------------------------
+                        // Properties
+                        // -------------------------------------------
+                        {
+                            html: "Properties",
+                            onClick: function(){
+                                let window_height = 500;
+                                let window_width = 450;
+            
+                                let left = mouseX;
+                                left -= 200;
+                                left = left > (window.innerWidth - window_width)? (window.innerWidth - window_width) : left;
+            
+                                let top = mouseY;
+                                top = top > (window.innerHeight - (window_height + window.taskbar_height + window.toolbar_height))? (window.innerHeight - (window_height + window.taskbar_height + window.toolbar_height)) : top;
+            
+            
+                                UIWindowItemProperties(options.title, options.path, options.uid, left, top, window_width, window_height);
+                            }
+                        },
+                    ]
+                });
+            }
+            // Trash conext menu
+            else{
+                UIContextMenu({
+                    parent_element: el_window_body,
+                    items: [
+                        // -------------------------------------------
+                        // Empty Trash
+                        // -------------------------------------------
+                        {
+                            html: "Empty Trash",
+                            disabled: false,
+                            onClick: async function(){
+                                const alert_resp = await UIAlert({
+                                    message: `Are you sure you want to permanently delete the items in Trash?`,
+                                    buttons:[
+                                        {
+                                            label: 'Yes',
+                                            value: 'yes',
+                                            type: 'primary',
+                                        },
+                                        {
+                                            label: 'No',
+                                            value: 'no',
+                                        },
+                                    ]
+                                })
+                                if(alert_resp === 'no')
+                                    return;
+                                
+                                // todo this has to be case-insensitive but the `i` selector doesn't work on ^=
+                                $(`.item[data-path^="${html_encode(trash_path)}/"]`).each(function(){
+                                    delete_item(this);
+                                })
+                                // update other clients
+                                if(window.socket){
+                                    window.socket.emit('trash.is_empty', {is_empty: true});
+                                }
+                                // use the 'empty trash' icon
+                                $(`.item[data-path="${html_encode(trash_path)}" i], .item[data-shortcut_to_path="${html_encode(trash_path)}" i]`).find('.item-icon > img').attr('src', window.icons['trash.svg']); 
+                            }
+                        },
+                    ]
+                });
+            }
+        }
+    }); 
+    // --------------------------------------------------------
+    // Head Context Menu
+    // --------------------------------------------------------
+    if(options.has_head){
+        $(el_window_head).bind("contextmenu taphold", function (event) {
+            event.preventDefault();
+            return false;
+        })
+    }
+
+    // --------------------------------------------------------
+    // Droppable sidebar items
+    // --------------------------------------------------------
+    $(el_window).find('.window-sidebar-item').each(function (index){
+        // todo only continue if this item is a dir
+        const el_item = this;
+        $(el_item).dragster({
+            enter: function (dragsterEvent, event) {
+                $(el_item).addClass('item-selected');
+            },
+            leave: function (dragsterEvent, event) {
+                $(el_item).removeClass('item-selected');
+            },
+            drop: function (dragsterEvent, event) {
+                const e = event.originalEvent;        
+                $(el_item).removeClass('item-selected');
+                // if files were dropped...
+                if(e.dataTransfer?.items?.length > 0){
+                    upload_items(e.dataTransfer.items, $(el_item).attr('data-path'))
+                }
+
+                e.stopPropagation();
+                e.preventDefault();
+                return false;
+            }
+        });
+    })
+
+    //set styles
+    $(el_window_body).css(options.body_css);
+
+    // is fullpage?
+    if(options.is_fullpage){
+        $(el_window).hide()
+        setTimeout(function(){
+            enter_fullpage_mode(el_window);
+            $(el_window).show()
+        }, 5);
+    }
+
+    return el_window;
+}
+
+function delete_window_element (el_window){
+    // if this is the active element, set it to null
+    if(active_element === el_window){
+        active_element = null;
+    }
+    // remove DOM element
+    $(el_window).remove(); 
+    // if no other windows open, reset window_counter
+    // resetting window counter is important so that next window opens at the center of the screen
+    if($('.window').length === 0)
+        window.window_counter = 0;
+}    
+
+
+$(document).on('click', '.window-sidebar-item', async function(e){
+    const el_window = $(this).closest('.window');
+    const parent_win_id = $(el_window).attr('data-id');
+    const item_path =  $(this).attr('data-path');
+
+    // ctrl/cmd + click will open in new window
+    if(e.metaKey || e.ctrlKey){
+        UIWindow({
+            path: item_path,
+            title: path.basename(item_path),
+            icon: await item_icon({is_dir: true, path: item_path}),
+            // todo
+            // uid: $(el_item).attr('data-uid'),
+            is_dir: true,
+            // todo
+            // sort_by: $(el_item).attr('data-sort_by'),
+            app: 'explorer',
+            // top: options.maximized ? 0 : undefined,
+            // left: options.maximized ? 0 : undefined,
+            // height: options.maximized ? `calc(100% - ${window.taskbar_height + 1}px)` : undefined,
+            // width: options.maximized ? `100%` : undefined,
+        });
+    }
+    // update window path only if it's a new path AND no ctrl/cmd key pressed
+    else if(item_path !== $(el_window).attr('data-path')){
+        window_nav_history[parent_win_id] = window_nav_history[parent_win_id].slice(0, window_nav_history_current_position[parent_win_id] + 1);
+        window_nav_history[parent_win_id].push(item_path);
+        window_nav_history_current_position[parent_win_id]++;
+
+        update_window_path(el_window, item_path);
+    }
+})
+
+$(document).on('contextmenu', '.window-sidebar', function(e){
+    e.preventDefault();
+    e.stopPropagation();
+    return false;  
+})
+
+$(document).on('contextmenu taphold', '.window-sidebar-item', function(event){
+    // dismiss taphold on regular devices
+    if(event.type==='taphold' && !isMobile.phone && !isMobile.tablet)
+        return;
+
+    event.preventDefault();
+    event.stopPropagation();
+    // todo
+    // $(this).addClass('window-sidebar-item-highlighted');
+    const item = this;
+    UIContextMenu({
+        parent_element: $(this),
+        items: [
+            //--------------------------------------------------
+            // Open
+            //--------------------------------------------------
+            {
+                html: "Open",
+                onClick: function(){
+                    $(item).trigger('click');
+                }
+            },
+            //--------------------------------------------------
+            // Open in New Window
+            //--------------------------------------------------
+            {
+                html: "Open in New Window",
+                onClick: async function(){
+                    let item_path = $(item).attr('data-path');
+
+                    UIWindow({
+                        path: item_path,
+                        title: path.basename(item_path),
+                        icon: await item_icon({is_dir: true, path: item_path}),
+                        // todo
+                        // uid: $(el_item).attr('data-uid'),
+                        is_dir: true,
+                        // todo
+                        // sort_by: $(el_item).attr('data-sort_by'),
+                        app: 'explorer',
+                        // top: options.maximized ? 0 : undefined,
+                        // left: options.maximized ? 0 : undefined,
+                        // height: options.maximized ? `calc(100% - ${window.taskbar_height + 1}px)` : undefined,
+                        // width: options.maximized ? `100%` : undefined,
+                    });            
+                }
+            }
+        ]
+    });
+    return false;
+})
+
+$(document).on('dblclick', '.window .ui-resizable-handle', function(e){
+    let el_window = $(this).closest('.window');
+    // bottom
+    if($(this).hasClass('ui-resizable-s')){
+        let height = window.innerHeight - $(el_window).position().top - window.taskbar_height -1;
+        $(el_window).height(height);
+    }
+
+    // top
+    else if($(this).hasClass('ui-resizable-n')){
+        let height = $(el_window).height() +  $(el_window).position().top - window.toolbar_height;
+        $(el_window).css({
+            height: height,
+            top: window.toolbar_height, 
+        });
+    }
+    // right
+    else if($(this).hasClass('ui-resizable-e')){
+        let width = window.innerWidth - $(el_window).position().left;
+        $(el_window).css({
+            width: width,
+        });
+    }
+    // left
+    else if($(this).hasClass('ui-resizable-w')){
+        let width = $(el_window).width() +  $(el_window).position().left;
+        $(el_window).css({
+            width: width,
+            left: 0 
+        });
+    }
+    // bottom left
+    else if($(this).hasClass('ui-resizable-sw')){
+        let width = $(el_window).width() +  $(el_window).position().left;
+        let height = window.innerHeight - $(el_window).position().top - window.taskbar_height -1;
+        $(el_window).css({
+            width: width,
+            height: height,
+            left: 0 
+        });
+    }
+    // bottom right
+    else if($(this).hasClass('ui-resizable-se')){
+        let width = window.innerWidth - $(el_window).position().left;
+        let height = window.innerHeight - $(el_window).position().top - window.taskbar_height -1;
+        $(el_window).css({
+            width: width,
+            height: height,
+        });
+    }
+    // top right
+    else if($(this).hasClass('ui-resizable-ne')){
+        let width = window.innerWidth - $(el_window).position().left;
+        let height = $(el_window).height() +  $(el_window).position().top - window.toolbar_height;
+        $(el_window).css({
+            width: width,
+            height: height,
+            top: window.toolbar_height,
+        });
+    }
+    // top left
+    else if($(this).hasClass('ui-resizable-nw')){
+        let width = $(el_window).width() +  $(el_window).position().left;
+        let height = $(el_window).height() +  $(el_window).position().top - window.toolbar_height;
+        $(el_window).css({
+            width: width,
+            height: height,
+            top: window.toolbar_height,
+            left:0,
+        });
+    }
+
+})
+
+$(document).on('click', '.window-navbar-path', function(e){
+    if(!$(e.target).hasClass('window-navbar-path'))
+        return;
+
+    $(e.target).hide();
+    $(e.target).siblings('.window-navbar-path-input').show().select();
+})
+$(document).on('blur', '.window-navbar-path-input', function(e){
+    $(e.target).hide();
+    $(e.target).siblings('.window-navbar-path').show().select();
+})
+
+$(document).on('keyup', '.window-navbar-path-input', function(e){
+    if (e.key === 'Enter' || e.keyCode === 13) {
+        update_window_path($(e.target).closest('.window'), $(e.target).val());
+        $(e.target).hide();
+        $(e.target).siblings('.window-navbar-path').show().select();    
+    }
+})
+
+
+$(document).on('click', '.window-navbar-path-dirname', function(e){
+    const $el_parent_window = $(this).closest('.window');
+    const parent_win_id = $($el_parent_window).attr('data-id');
+
+    // open in new window
+    if(e.metaKey || e.ctrlKey){
+        const dirpath = $(this).attr('data-path');
+        UIWindow({
+            path: dirpath,
+            title: dirpath === '/' ? root_dirname : path.basename(dirpath),
+            icon: window.icons['folder.svg'],
+            // uid: $(el_item).attr('data-uid'),
+            is_dir: true,
+            app: 'explorer',
+        });
+    }
+    // only change dir if target is not the same as current path
+    else if($el_parent_window.attr('data-path') !== $(this).attr('data-path')){
+        window_nav_history[parent_win_id] = window_nav_history[parent_win_id].slice(0, window_nav_history_current_position[parent_win_id]+1);
+        window_nav_history[parent_win_id].push($(this).attr('data-path'));
+        window_nav_history_current_position[parent_win_id] = window_nav_history[parent_win_id].length - 1;
+        update_window_path($el_parent_window, $(this).attr('data-path'));
+    }
+})
+
+$(document).on('contextmenu taphold', '.window-navbar', function(event){
+    // don't disable system ctxmenu on the address bar input
+    if($(event.target).hasClass('window-navbar-path-input'))
+        return;
+
+    // dismiss taphold on regular devices
+    if(event.type==='taphold' && !isMobile.phone && !isMobile.tablet)
+        return;
+
+    event.preventDefault();
+    event.stopPropagation();
+    return false;
+})
+
+$(document).on('contextmenu taphold', '.window-navbar-path-dirname', function(event){
+    // dismiss taphold on regular devices
+    if(event.type==='taphold' && !isMobile.phone && !isMobile.tablet)
+        return;
+
+    event.preventDefault();
+    const menu_items = [];
+    const el = this;
+    // -------------------------------------------
+    // Open
+    // -------------------------------------------
+    menu_items.push({
+        html: 'Open',
+        onClick: ()=>{
+            $(this).trigger('click');
+        }
+    });
+    // -------------------------------------------
+    // Open in New Window
+    // (only if the item is on a window)
+    // -------------------------------------------
+    menu_items.push({
+        html: 'Open in New Window',
+        onClick: function(){
+            UIWindow({
+                path: $(el).attr('data-path'),
+                title:  $(el).attr('data-path') === '/' ? root_dirname : path.basename($(el).attr('data-path')),
+                icon: window.icons['folder.svg'],
+                uid: $(el).attr('data-uid'),
+                is_dir: true,
+                app: 'explorer',
+            });
+        }
+    });
+    // -------------------------------------------
+    // -
+    // -------------------------------------------
+    menu_items.push('-'),
+    // -------------------------------------------
+    // Paste
+    // -------------------------------------------
+    menu_items.push({
+        html: "Paste",
+        disabled: clipboard.length > 0 ? false : true,
+        onClick: function(){
+            if(clipboard_op === 'copy')
+                copy_clipboard_items($(el).attr('data-path'), null);
+            else if(clipboard_op === 'move')
+                move_clipboard_items(null, $(el).attr('data-path'))
+        }
+    })
+
+    UIContextMenu({
+        parent_element: $(this),
+        items: menu_items
+    });
+})
+
+// if the click is on the mask, bring focus to the active child window
+$(document).on('click', '.window-disable-mask', async function(e){
+    e.stopPropagation();
+    e.preventDefault();
+    return false;
+})
+
+// --------------------------------------------------------
+// Navbar Dir Droppable
+// --------------------------------------------------------
+window.navbar_path_droppable = (el_window)=>{
+    $(el_window).find('.window-navbar-path-dirname').droppable({
+        accept: '.item',
+        tolerance: 'pointer',
+        drop: function( event, ui ) {
+            // check if item was actually dropped on this navbar path
+            if($(mouseover_window).attr('data-id') !== $(el_window).attr('data-id')){
+                return;
+            }
+            const items_to_move = []
+            
+            // first item
+            items_to_move.push(ui.draggable); 
+            
+            // all subsequent items
+            const cloned_items = document.getElementsByClassName('item-selected-clone');
+            for(let i =0; i<cloned_items.length; i++){
+                const source_item = document.getElementById('item-' + $(cloned_items[i]).attr('data-id'));
+                if(source_item !== null)
+                    items_to_move.push(source_item);
+            }
+
+            // if alt key is down, create shortcut items
+            if(event.altKey){
+                items_to_move.forEach((item_to_move) => {
+                    create_shortcut(
+                        path.basename($(item_to_move).attr('data-path')), 
+                        $(item_to_move).attr('data-is_dir') === '1', 
+                        $(this).attr('data-path'), 
+                        null, 
+                        $(item_to_move).attr('data-shortcut_to') === '' ? $(item_to_move).attr('data-uid') : $(item_to_move).attr('data-shortcut_to'),
+                        $(item_to_move).attr('data-shortcut_to_path') === '' ? $(item_to_move).attr('data-path') : $(item_to_move).attr('data-shortcut_to_path'),
+                    );
+                });
+            }
+            // move items
+            else{
+                move_items(items_to_move, $(this).attr('data-path'));
+            }
+
+            $('.item-container').droppable('enable')
+            $(this).removeClass('window-navbar-path-dirname-active');
+
+            return false;
+        },
+        over: function(event, ui){
+            // check if item was actually hovered over this window
+            if($(mouseover_window).attr('data-id') !== $(el_window).attr('data-id'))
+                return;
+
+            // Don't do anything if the dragged item is NOT a UIItem
+            if(!$(ui.draggable).hasClass('item'))
+                return;
+            
+            // highlight this dirname
+            $(this).addClass('window-navbar-path-dirname-active');
+            $('.ui-draggable-dragging').css('opacity', 0.2)
+            $('.item-selected-clone').css('opacity', 0.2)
+
+            // disable all window bodies 
+            $('.item-container').droppable( 'disable' )
+        },
+        out: function(event, ui){
+            // Don't do anything if the dragged element is NOT a UIItem
+            if(!$(ui.draggable).hasClass('item'))
+                return;
+            
+            // unselect directory if item is dragged out
+            $(this).removeClass('window-navbar-path-dirname-active');
+            $('.ui-draggable-dragging').css('opacity', 'initial')
+            $('.item-selected-clone').css('opacity', 'initial')
+
+            $('.item-container').droppable( 'enable' )    
+        }
+    });
+}
+
+/**
+ * Constructs a XSS-safe string that represents a navigation bar path.
+ * The result is a string with HTML span elements for each directory in the path, each accompanied by a separator icon.
+ * Each span element has a `data-path` attribute holding the encoded path to that directory, and contains the encoded directory name as text.
+ * The root directory name is a constant defined in globals.js, represented as 'root_dirname'.
+ *
+ * @param {string} abs_path - The absolute path to be displayed in the navigation bar. It should be a string with directories separated by slashes ('/').
+ * 
+ * @returns {string} A string of HTML spans and separators, each span representing a directory in the navigation bar.
+ *
+ */
+window.navbar_path = (abs_path)=>{
+    const dirs = (abs_path === '/' ? [''] : abs_path.split('/'));
+    const dirpaths = (abs_path === '/' ? ['/'] : [])
+    const path_seperator_html = `<img class="path-seperator" draggable="false" src="${html_encode(window.icons['triangle-right.svg'])}">`;
+    if(dirs.length > 1){
+        for(let i=0; i<dirs.length; i++){
+            dirpaths[i] = '';
+            for(let j=1; j<=i; j++){
+                dirpaths[i] += '/'+dirs[j];
+            }
+        }
+    }
+    let str = `${path_seperator_html}<span class="window-navbar-path-dirname" data-path="${html_encode('/')}">${html_encode(window.root_dirname)}</span>`;
+    for(let k=1; k<dirs.length; k++){
+        str += `${path_seperator_html}<span class="window-navbar-path-dirname" data-path="${html_encode(dirpaths[k])}">${html_encode(dirs[k])}</span>`;
+    }
+    return str;
+}
+
+window.update_window_path = async function(el_window, target_path){
+    const win_id = $(el_window).attr('data-id');
+    const el_window_navbar_forward_btn = $(el_window).find('.window-navbar-btn-forward');
+    const el_window_navbar_back_btn = $(el_window).find('.window-navbar-btn-back');
+    const el_window_navbar_up_btn = $(el_window).find('.window-navbar-btn-up');
+    const el_window_body = $(el_window).find('.window-body');
+    const el_window_item_container = $(el_window).find('.item-container');
+    const el_window_navbar_path_input = $(el_window).find('.window-navbar-path-input');
+    const is_dir = ($(el_window).attr('data-is_dir') === '1' || $(el_window).attr('data-is_dir') === 'true');
+    const old_path = $(el_window).attr('data-path');
+
+    // update sidebar items' active status
+    $(el_window).find(`.window-sidebar-item`).removeClass('window-sidebar-item-active');
+    $(el_window).find(`.window-sidebar-item[data-path="${html_encode(target_path)}"]`).addClass('window-sidebar-item-active');
+
+    // clean
+    $(el_window).find('.explore-table-headers-th > .header-sort-icon').html('');
+
+    if(is_dir){
+        // if nav history for this window is empty, disable forward btn
+        if(window_nav_history[win_id] && window_nav_history[win_id].length - 1 === window_nav_history_current_position[win_id])
+            $(el_window_navbar_forward_btn).addClass('window-navbar-btn-disabled');
+        // ... else, enable forawrd btn
+        else
+            $(el_window_navbar_forward_btn).removeClass('window-navbar-btn-disabled');
+
+        // disable back button if path is root
+        if(window_nav_history_current_position[win_id] === 0)
+            $(el_window_navbar_back_btn).addClass('window-navbar-btn-disabled');
+        // ... enable back btn in all other cases
+        else
+            $(el_window_navbar_back_btn).removeClass('window-navbar-btn-disabled');
+
+        // disabled Up button if this is root
+        if(target_path === '/')
+            $(el_window_navbar_up_btn).addClass('window-navbar-btn-disabled');
+        // ... enable back btn in all other cases
+        else
+            $(el_window_navbar_up_btn).removeClass('window-navbar-btn-disabled');
+
+        $(el_window_item_container).attr('data-path', target_path);
+        $(el_window).find('.window-navbar-path').html(navbar_path(target_path, window.user.username));
+        
+        // empty body to be filled with the results of /readdir
+        $(el_window_body).find('.item').removeItems()
+
+        // add the 'Detail View' table header
+        if($(el_window).find('.explore-table-headers').length === 0)
+            $(el_window_body).prepend(window.explore_table_headers());
+        
+        // 'Detail View' table header is hidden by default
+        $(el_window).find('.explore-table-headers').hide();
+
+        // system directories with custom icons and predefined names
+        if(target_path === window.desktop_path){
+            $(el_window).find('.window-head-icon').attr('src', window.icons['folder-desktop.svg']);
+            $(el_window).find('.window-head-title').text('Desktop')
+        }else if (target_path === window.home_path){
+            $(el_window).find('.window-head-icon').attr('src', window.icons['folder-home.svg']);
+            $(el_window).find('.window-head-title').text('Home')
+        }else if (target_path === window.docs_path){
+            $(el_window).find('.window-head-icon').attr('src', window.icons['folder-documents.svg']);
+            $(el_window).find('.window-head-title').text('Documents')
+        }else if (target_path === window.videos_path){
+            $(el_window).find('.window-head-icon').attr('src', window.icons['folder-videos.svg']);
+            $(el_window).find('.window-head-title').text('Videos')
+        }else if (target_path === window.pictures_path){
+            $(el_window).find('.window-head-icon').attr('src', window.icons['folder-pictures.svg']);
+            $(el_window).find('.window-head-title').text('Pictures')
+        }// root folder of a shared user?
+        else if((target_path.split('/').length - 1) === 1 && target_path !== '/'+window.user.username)
+            $(el_window).find('.window-head-icon').attr('src', window.icons['shared.svg']);
+        else
+            $(el_window).find('.window-head-icon').attr('src', window.icons['folder.svg']);
+    }
+
+    $(el_window).attr('data-path', html_encode(target_path));
+    $(el_window).attr('data-name', html_encode(path.basename(target_path)));
+
+    // /stat
+    if(target_path !== '/'){
+        try{
+            puter.fs.stat(target_path, function(fsentry){
+                $(el_window).removeClass('window-' + $(el_window).attr('data-uid'));
+                $(el_window).addClass('window-' + fsentry.id);
+                $(el_window).attr('data-uid', fsentry.id);
+                $(el_window).attr('data-sort_by', fsentry.sort_by ?? 'name');
+                $(el_window).attr('data-sort_order', fsentry.sort_order ?? 'asc');
+                $(el_window).attr('data-layout', fsentry.layout ?? 'icons');
+                $(el_window_item_container).attr('data-uid', fsentry.id);
+                // title
+                if (target_path === window.home_path)
+                    $(el_window).find('.window-head-title').text('Home')
+                else
+                    $(el_window).find('.window-head-title').text(fsentry.name);
+                // data-name
+                $(el_window).attr('data-name', html_encode(fsentry.name));
+                // data-path
+                $(el_window).attr('data-path', html_encode(target_path));
+                $(el_window_navbar_path_input).val(target_path);
+                $(el_window_navbar_path_input).attr('data-path', target_path);
+                // update layout
+                update_window_layout(el_window, fsentry.layout);
+                // update explore header if in details view
+                if(fsentry.layout === 'details'){
+                    update_details_layout_sort_visuals(el_window, fsentry.sort_by, fsentry.sort_order);
+                }
+            });
+        }catch(err){
+            UIAlert(err.responseText)
+
+            // todo optim: this is dumb because updating the window should only happen if this /readdir request is successful,
+            // in that case there is no need for using update_window_path on error!!
+            update_window_path(el_window, old_path);
+        }
+    }
+    // path is '/' (global root)
+    else{
+        $(el_window).removeClass('window-' + $(el_window).attr('data-uid'));
+        $(el_window).addClass('window-null');
+        $(el_window).attr('data-uid', 'null');
+        $(el_window).attr('data-name', '');
+        $(el_window).find('.window-head-title').text(root_dirname);
+    }
+
+    if(is_dir){
+        refresh_item_container(el_window_body);
+        navbar_path_droppable(el_window)
+    }
+
+    update_explorer_footer_selected_items_count(el_window);
+}
+
+// --------------------------------------------------------
+// Sidebar Item Droppable
+// --------------------------------------------------------
+window.sidebar_item_droppable = (el_window)=>{
+    $(el_window).find('.window-sidebar-item').droppable({
+        accept: '.item',
+        tolerance: 'pointer',
+        drop: function( event, ui ) {
+            // check if item was actually dropped on this navbar path
+            if($(mouseover_window).attr('data-id') !== $(el_window).attr('data-id')){
+                return;
+            }
+            const items_to_move = []
+            
+            // first item
+            items_to_move.push(ui.draggable); 
+            
+            // all subsequent items
+            const cloned_items = document.getElementsByClassName('item-selected-clone');
+            for(let i =0; i<cloned_items.length; i++){
+                const source_item = document.getElementById('item-' + $(cloned_items[i]).attr('data-id'));
+                if(source_item !== null)
+                    items_to_move.push(source_item);
+            }
+
+            // if alt key is down, create shortcut items
+            if(event.altKey){
+                items_to_move.forEach((item_to_move) => {
+                    create_shortcut(
+                        path.basename($(item_to_move).attr('data-path')), 
+                        $(item_to_move).attr('data-is_dir') === '1', 
+                        $(this).attr('data-path'), 
+                        null, 
+                        $(item_to_move).attr('data-shortcut_to') === '' ? $(item_to_move).attr('data-uid') : $(item_to_move).attr('data-shortcut_to'),
+                        $(item_to_move).attr('data-shortcut_to_path') === '' ? $(item_to_move).attr('data-path') : $(item_to_move).attr('data-shortcut_to_path'),
+                    );
+                });
+            }
+            // move items
+            else{
+                move_items(items_to_move, $(this).attr('data-path'));
+            }
+
+            $('.item-container').droppable('enable')
+            $(this).removeClass('window-sidebar-item-drag-active');
+
+            return false;
+        },
+        over: function(event, ui){
+            // check if item was actually hovered over this window
+            if($(mouseover_window).attr('data-id') !== $(el_window).attr('data-id'))
+                return;
+
+            // Don't do anything if the dragged item is NOT a UIItem
+            if(!$(ui.draggable).hasClass('item'))
+                return;
+            
+            // highlight this item
+            $(this).addClass('window-sidebar-item-drag-active');
+            $('.ui-draggable-dragging').css('opacity', 0.2)
+            $('.item-selected-clone').css('opacity', 0.2)
+
+            // disable all window bodies 
+            $('.item-container').droppable( 'disable' )
+        },
+        out: function(event, ui){
+            // Don't do anything if the dragged element is NOT a UIItem
+            if(!$(ui.draggable).hasClass('item'))
+                return;
+            
+            // unselect item if item is dragged out
+            $(this).removeClass('window-sidebar-item-drag-active');
+            $('.ui-draggable-dragging').css('opacity', 'initial')
+            $('.item-selected-clone').css('opacity', 'initial')
+
+            $('.item-container').droppable( 'enable' )    
+        }
+    });
+}
+
+// closes a window
+$.fn.close = async function(options) {
+    options = options || {};
+    $(this).each(async function() {
+        const el_iframe = $(this).find('.window-app-iframe');
+        // tell child app that this window is about to close, get its response
+        if(el_iframe.length > 0 && el_iframe.attr('data-appUsesSDK') === 'true'){
+            if(!options.bypass_iframe_messaging){
+                const resp = await sendWindowWillCloseMsg(el_iframe.get(0));
+                if(!resp.msg){
+                    return false;
+                }
+            }
+        }
+
+        // Process window close if this is a window
+        if($(this).hasClass('window')){
+            const win_id = parseInt($(this).attr('data-id'));
+            let window_uuid = $(this).attr('data-element_uuid');
+            // remove all instances of win_id from window_stack
+            _.pullAll(window_stack, [win_id]);
+            // taskbar update
+            let open_window_count = parseInt($(`.taskbar-item[data-app="${$(this).attr('data-app')}"]`).attr('data-open-windows'));
+            // update open window count of corresponding taskbar item
+            if(open_window_count > 0){
+                $(`.taskbar-item[data-app="${$(this).attr('data-app')}"]`).attr('data-open-windows', open_window_count - 1);
+            }
+            // decide whether to remove taskbar item
+            if(open_window_count === 1){
+                $(`.taskbar-item[data-app="${$(this).attr('data-app')}"] .active-taskbar-indicator`).hide();
+                remove_taskbar_item($(`.taskbar-item[data-app="${$(this).attr('data-app')}"][data-keep-in-taskbar="false"]`));
+            }
+            // if no more windows of this app are open, remove taskbar item
+            if(open_window_count - 1 === 0)
+                $(`.taskbar-item[data-app="${$(this).attr('data-app')}"] .active-taskbar-indicator`).hide();
+            // if a fullpage window is closed, show desktop and taskbar
+            if($(this).attr('data-is_fullpage') === '1'){
+                exit_fullpage_mode();
+            }
+
+            // FileDialog closed
+            if($(this).hasClass('window-filedialog') || $(this).attr('data-disable_parent_window') === 'true'){
+                // re-enable this FileDialog's parent window
+                $(`.window[data-element_uuid="${$(this).attr('data-parent_uuid')}"]`).addClass('window-active');
+                $(`.window[data-element_uuid="${$(this).attr('data-parent_uuid')}"]`).removeClass('window-disabled');
+                $(`.window[data-element_uuid="${$(this).attr('data-parent_uuid')}"]`).find('.window-disable-mask').hide();
+                // bring focus back to app iframe, if needed
+                $(`.window[data-element_uuid="${$(this).attr('data-parent_uuid')}"]`).focusWindow();
+            }
+            // Other types of windows closed
+            else{
+                // close any open FileDialogs belonging to this window
+                $(`.window-filedialog[data-parent_uuid="${window_uuid}"]`).close();
+                // bring focus to the last window in the window-stack (only if not minimized)
+                if(!_.isEmpty(window_stack)){
+                    const $last_window_in_stack = $(`.window[data-id="${window_stack[window_stack.length - 1]}"]`);
+                    // check if previous window is not minimized
+                    if($last_window_in_stack !== null && $last_window_in_stack.attr('data-is_minimized') !== '1' && $last_window_in_stack.attr('data-is_minimized') !== 'true'){
+                        $(`.window[data-id="${window_stack[window_stack.length - 1]}"]`).focusWindow();
+                    }
+                    // otherwise, change URL/Title to desktop
+                    else{
+                        window.history.replaceState(null, document.title, '/');
+                        document.title = 'Puter';
+                    }
+                    // if it's explore 
+                    if($last_window_in_stack.attr('data-app') && $last_window_in_stack.attr('data-app').toLowerCase() === 'explorer'){
+                        window.history.replaceState(null, document.title, '/');
+                        document.title = 'Puter';
+                    }
+                }
+                // otherwise, change URL/Title to desktop
+                else{
+                    window.history.replaceState(null, document.title, '/');
+                    document.title = 'Puter';
+                }
+            }
+            // close child windows
+            $(`.window[data-parent_uuid="${window_uuid}"]`).close();
+            // remove backdrop
+            $(this).closest('.window-backdrop').remove();
+            // remove DOM element
+            if(options?.shrink_to_target){
+                // get target location
+                const target_pos = $(options.shrink_to_target).position();
+                const target_size = $(options.shrink_to_target).get(0).getBoundingClientRect();
+
+                // animate window to target location
+                $(this).animate({
+                    width: `1`,
+                    height: `1`,
+                    top: target_pos.top + target_size.height / 2,
+                    left: target_pos.left + target_size.width / 2,
+                }, 300, () => {
+                    // remove DOM element
+                    delete_window_element(this);
+                });
+            }
+            else if(window.animate_window_closing){
+                // start shrink animation
+                $(this).css({
+                    'transition': 'transform 400ms',
+                    'transform': 'scale(0)',
+                });
+                // remove DOM element after fadeout animation
+                $(this).fadeOut(80, function(){
+                    delete_window_element(this);
+                })
+            }else{
+                delete_window_element(this);
+            }
+        }
+        // focus back to desktop?
+        if(_.isEmpty(window_stack)){
+            // The following is to make sure the iphone keyboard is dismissed when the last window is closed
+            if(isMobile.phone || isMobile.tablet){
+                document.activeElement.blur();
+                $("input").blur();
+            }
+            // focus back to desktop
+            $('.desktop').find('.item-blurred').removeClass('item-blurred');
+            active_item_container = $('.desktop.item-container').get(0);
+        }
+    })
+
+    return this;
+};
+
+window.scale_window = (el_window)=>{
+    //maximize
+    if ($(el_window).attr('data-is_maximized') !== '1') {
+        // save original size and position
+        let el_window_rect = el_window.getBoundingClientRect();
+        $(el_window).attr({
+            'data-left-before-maxim': el_window_rect.left + 'px',
+            'data-top-before-maxim': el_window_rect.top + 'px',
+            'data-width-before-maxim': $(el_window).css('width'),
+            'data-height-before-maxim': $(el_window).css('height'),
+            'data-is_maximized': '1',
+        });
+
+        // shrink icon
+        $(el_window).find('.window-scale-btn>img').attr('src', window.icons['scale-down-3.svg']);
+
+        // set new size and position
+        $(el_window).css({
+            'top': toolbar_height+'px',
+            'left': '0',
+            'width': '100%',
+            'height': `calc(100% - ${window.taskbar_height + window.toolbar_height + 1}px)`,
+            'transform': 'none',
+        });
+    }
+    //shrink
+    else {
+        // set size and position to original before maximization
+        $(el_window).css({
+            'top': $(el_window).attr('data-top-before-maxim'),
+            'left': $(el_window).attr('data-left-before-maxim'),
+            'width': $(el_window).attr('data-width-before-maxim'),
+            'height': $(el_window).attr('data-height-before-maxim'),
+            'transform': 'none',
+        });
+    
+        // maximize icon
+        $(el_window).find('.window-scale-btn>img').attr('src', window.icons['scale.svg']);
+
+        $(el_window).attr({
+            'data-is_maximized': 0,
+        });
+    }
+
+    // record window size and position before scaling
+    $(el_window).attr({
+        'data-orig-width': $(el_window).width(), 
+        'data-orig-height': $(el_window).height(), 
+        'data-orig-top': $(el_window).position().top, 
+        'data-orig-left': $(el_window).position().left, 
+        'data-is_minimized': false, 
+    })
+}
+
+window.update_explorer_footer_item_count = function(el_window){
+    //update dir count in explorer footer
+    let item_count = $(el_window).find('.item').length;
+    $(el_window).find('.explorer-footer .explorer-footer-item-count').html(item_count + ' item' + (item_count == 0 || item_count > 1 ? 's' : ''));
+}
+
+window.update_explorer_footer_selected_items_count = function(el_window){
+    //update dir count in explorer footer
+    let item_count = $(el_window).find('.item-selected').length;
+    if(item_count > 0){
+        $(el_window).find('.explorer-footer-seperator, .explorer-footer-selected-items-count').show();
+        $(el_window).find('.explorer-footer .explorer-footer-selected-items-count').html(item_count + ' item' + (item_count == 0 || item_count > 1 ? 's' : '') + ' selected');
+    }else{
+        $(el_window).find('.explorer-footer-seperator, .explorer-footer-selected-items-count').hide();
+    }
+}
+
+window.set_sort_by = function(item_uid, sort_by, sort_order){
+    if(sort_order !== 'asc' && sort_order !== 'desc')
+        sort_order = 'asc';
+
+    $.ajax({
+        url: api_origin + "/set_sort_by",
+        type: 'POST',
+        data: JSON.stringify({ 
+            sort_by: sort_by,
+            item_uid: item_uid,
+            sort_order: sort_order,
+        }),
+        async: true,
+        contentType: "application/json",
+        headers: {
+            "Authorization": "Bearer "+auth_token
+        },
+        statusCode: {
+            401: function () {
+                logout();
+            },
+        },        
+        success: function (){ 
+        }  
+    })
+    // update the sort_by & sort_order attr of every matching element
+    $(`[data-uid="${item_uid}"]`).attr({
+        'data-sort_by': sort_by,
+        'data-sort_order': sort_order,
+    });
+}
+
+window.explore_table_headers = function(){
+    let h = ``;
+    h += `<div class="explore-table-headers">`;
+        h += `<div class="explore-table-headers-th explore-table-headers-th--name">Name<span class="header-sort-icon"></span></div>`;
+        h += `<div class="explore-table-headers-th explore-table-headers-th--modified">Modified<span class="header-sort-icon"></span></div>`;
+        h += `<div class="explore-table-headers-th explore-table-headers-th--size">Size<span class="header-sort-icon"></span></div>`;
+        h += `<div class="explore-table-headers-th explore-table-headers-th--type">Type<span class="header-sort-icon"></span></div>`;
+    h += `</div>`;
+    return h;
+}
+
+window.update_window_layout = function(el_window, layout){
+    layout = layout ?? 'icons';
+
+    if(layout === 'icons'){
+        $(el_window).find('.explore-table-headers').hide();
+        $(el_window).find('.item-container').removeClass('item-container-list');
+        $(el_window).find('.item-container').removeClass('item-container-details');
+        $(el_window).find('.window-navbar-layout-settings').attr('src', window.icons['layout-icons.svg']);
+        $(el_window).attr('data-layout', layout)
+    }
+    else if(layout === 'list'){
+        $(el_window).find('.explore-table-headers').hide();
+        $(el_window).find('.item-container').removeClass('item-container-details');
+        $(el_window).find('.item-container').addClass('item-container-list');
+        $(el_window).find('.window-navbar-layout-settings').attr('src', window.icons['layout-list.svg'])
+        $(el_window).attr('data-layout', layout)
+    }
+    else if(layout === 'details'){
+        $(el_window).find('.explore-table-headers').show();
+        $(el_window).find('.item-container').removeClass('item-container-list');
+        $(el_window).find('.item-container').addClass('item-container-details');
+        $(el_window).find('.window-navbar-layout-settings').attr('src', window.icons['layout-details.svg'])
+        $(el_window).attr('data-layout', layout)
+    }
+}
+
+$.fn.showWindow = async function(options) {
+    $(this).each(async function() {
+        if($(this).hasClass('window')){
+            // show window
+            const el_window = this;
+            $(el_window).css({
+                'transition': `top 0.2s, left 0.2s, bottom 0.2s, right 0.2s, width 0.2s, height 0.2s`,
+                top: $(el_window).attr('data-orig-top') + 'px',
+                left: $(el_window).attr('data-orig-left') + 'px',
+                width: $(el_window).attr('data-orig-width') + 'px',
+                height: $(el_window).attr('data-orig-height') + 'px',
+            });
+            $(el_window).css('z-index', ++last_window_zindex);
+
+            setTimeout(() => {
+                $(this).focusWindow();
+            }, 80);
+
+            // remove `transitions` a good while after setting css to make sure 
+            // it doesn't interfere with an ongoing animation
+            setTimeout(() => {
+                $(el_window).css('transition', 'none');
+            }, 250);
+        }
+    })
+    return this;
+};
+
+window.show_or_hide_empty_folder_message = function(el_item_container){
+    // if the item container is the desktop, don't show/hide the empty message
+    if($(el_item_container).hasClass('desktop'))
+        return;
+
+    // if the item container is empty, show the empty message
+    if($(el_item_container).has('.item').length === 0){
+        $(el_item_container).find('.explorer-empty-message').show();
+    }
+    // if the item container is not empty, hide the empty message
+    else{
+        $(el_item_container).find('.explorer-empty-message').hide();
+    }
+}
+
+$.fn.focusWindow = function(event) {
+    if(this.hasClass('window')){
+        const $app_iframe = $(this).find('.window-app-iframe');
+        $('.window').not(this).removeClass('window-active');
+        $(this).addClass('window-active');
+        // disable pointer events on all other windows' iframes, except for this window's iframe
+        $('.window-app-iframe').not($app_iframe).css('pointer-events', 'none');
+        // bring this window to front, only if it's not stay_on_top
+        if($(this).attr('data-stay_on_top') !== 'true'){
+            $(this).css('z-index', ++last_window_zindex);
+        }
+        // if this window has a parent, bring them to the front too
+        if($(this).attr('data-parent_uuid') !== 'null'){
+            $(`.window[data-element_uuid="${$(this).attr('data-parent_uuid')}"]`).css('z-index', last_window_zindex);
+        }
+        // if this window has child windows, bring them to the front too
+        if($(this).attr('data-element_uuid') !== 'null'){
+            $(`.window[data-parent_uuid="${$(this).attr('data-element_uuid')}"]`).css('z-index', ++last_window_zindex);
+        }
+        //
+        // if this has an iframe, focus on it
+        if(!$(this).hasClass('window-disabled') && $app_iframe.length > 0){
+            $($app_iframe).css('pointer-events', 'all');
+            $app_iframe.get(0)?.focus({preventScroll:true});
+            $app_iframe.get(0)?.contentWindow?.focus({preventScroll:true});
+            // todo check if iframe is using SDK before sending messages
+            $app_iframe.get(0).contentWindow.postMessage({msg: "focus"}, '*');
+            var rect = $app_iframe.get(0).getBoundingClientRect();
+            // send click event to iframe, if this focus event was triggered by a click or similar mouse event
+            if(
+                event !== undefined && 
+                (event.type === 'click' || event.type === 'dblclick' || event.type === 'contextmenu' || event.type === 'mousedown' || event.type === 'mouseup' || event.type === 'mousemove')
+            ){
+                $app_iframe.get(0).contentWindow.postMessage({msg: "click", x: (mouseX - rect.left), y: (mouseY - rect.top)}, '*');
+            }
+        }
+        // set active_item_container
+        active_item_container = $(this).find('.item-container').get(0);
+        // grey out all selected items on other windows/desktop
+        $('.item-container').not(active_item_container).find('.item-selected').addClass('item-blurred');
+        // update window-stack
+        window_stack.push(parseInt($(this).attr('data-id')));
+        // remove blurred class from items on this window
+        $(active_item_container).find('.item-blurred').removeClass('item-blurred');
+        //change window URL
+        const update_window_url = $(this).attr('data-update_window_url');
+        if(update_window_url === 'true' || update_window_url === null){
+            window.history.replaceState({window_id: $(this).attr('data-id')}, '', '/app/'+$(this).attr('data-app'));
+            document.title = $(this).attr('data-name');
+        }
+        $(`.taskbar .taskbar-item[data-app="${$(this).attr('data-app')}"]`).addClass('taskbar-item-active');
+    }else{
+        $('.window').find('.item-selected').addClass('item-blurred');
+        $('.desktop').find('.item-blurred').removeClass('item-blurred');
+    }
+
+    return this;
+}
+
+// hides a window
+$.fn.hideWindow = async function(options) {
+    $(this).each(async function() {
+        if($(this).hasClass('window')){
+            // get taskbar item location
+            const taskbar_item_pos = $(`.taskbar .taskbar-item[data-app="${$(this).attr('data-app')}"]`).position();
+
+            $(this).attr({
+                'data-orig-width': $(this).width(), 
+                'data-orig-height': $(this).height(), 
+                'data-orig-top': $(this).position().top, 
+                'data-orig-left': $(this).position().left, 
+                'data-is_minimized': true, 
+            })
+
+            $(this).css({
+                'transition': `top 0.2s, left 0.2s, bottom 0.2s, right 0.2s, width 0.2s, height 0.2s`,
+                width: `0`,
+                height: `0`,
+                top: 'calc(100% - 60px)',
+                left: taskbar_item_pos.left + 29,
+            });
+
+            // remove transitions a good while after setting css to make sure 
+            // it doesn't interfere with an ongoing animation
+            setTimeout(() => {
+                $(this).css({
+                    'transition': 'none', 
+                    'transform': 'none'
+                });
+            }, 250);
+
+            // update title and window URL
+            window.history.replaceState(null, document.title, '/');
+            document.title = 'Puter';
+        }
+    })
+    return this;
+};
+
+$(document).on('click', '.explore-table-headers-th', function(e){
+    let sort_by = 'name';
+    let sort_icon = `<img src="${window.icons['up-arrow.svg']}">`;
+
+    // current sort order
+    let sort_order = $(e.target).closest('.window').attr('data-sort_order') ?? 'asc';
+    
+    // flip sort order
+    if(sort_order === 'asc'){
+        sort_order = 'desc';
+        sort_icon = `<img src="${window.icons['down-arrow.svg']}">`;
+    }else if(sort_order === 'desc'){
+        sort_icon = `<img src="${window.icons['up-arrow.svg']}">`;
+        sort_order = 'asc';
+    }
+
+    // remove active class from all headers
+    $(e.target).closest('.window').find('.explore-table-headers-th').removeClass('explore-table-headers-th-active');
+    // remove icons from all headers
+    $(e.target).closest('.window').find('.header-sort-icon').html('');
+
+    // add active class to this header
+    $(e.target).addClass('explore-table-headers-th-active');
+
+    // set sort icon
+    $(e.target).closest('.window').find('.explore-table-headers-th-active > .header-sort-icon').html(sort_icon);
+
+    // set sort_by
+    if($(e.target).hasClass('explore-table-headers-th--name')){
+        sort_by = 'name';
+    }else if($(e.target).hasClass('explore-table-headers-th--modified')){
+        sort_by = 'modified';
+    }else if($(e.target).hasClass('explore-table-headers-th--size')){
+        sort_by = 'size';
+    }else if($(e.target).hasClass('explore-table-headers-th--type')){
+        sort_by = 'type';
+    }
+
+    // sort
+    sort_items($(e.target).closest('.window-body'), sort_by, sort_order); 
+    set_sort_by($(e.target).closest('.window').attr('data-uid'), sort_by, sort_order)
+})
+
+window.set_layout = function(item_uid, layout){
+    $.ajax({
+        url: api_origin + "/set_layout",
+        type: 'POST',
+        data: JSON.stringify({ 
+            item_uid: item_uid,
+            layout: layout,
+        }),
+        async: true,
+        contentType: "application/json",
+        headers: {
+            "Authorization": "Bearer "+auth_token
+        },
+        statusCode: {
+            401: function () {
+                logout();
+            },
+        },        
+        success: function (){ 
+            if(layout === 'details'){
+                let el_window = $(`.window[data-uid="${item_uid}"]`);
+                if(el_window.length > 0){
+                    let sort_by = el_window.attr('data-sort_by');
+                    let sort_order = el_window.attr('data-sort_order');
+                    update_details_layout_sort_visuals(el_window, sort_by, sort_order);
+                }
+            }    
+        }
+    })
+}
+
+window.update_details_layout_sort_visuals = function(el_window, sort_by, sort_order){
+    let sort_icon = '';
+    $(el_window).find('.explore-table-headers-th > .header-sort-icon').html('');
+
+    if(!sort_order || sort_order === 'asc')
+        sort_icon = `<img src="${window.icons['up-arrow.svg']}">`;
+    else if(sort_order === 'desc')
+        sort_icon = `<img src="${window.icons['down-arrow.svg']}">`;
+
+    if(!sort_by || sort_by === 'name'){
+        $(el_window).find('.explore-table-headers-th').removeClass('explore-table-headers-th-active');
+        $(el_window).find('.explore-table-headers-th--name').addClass('explore-table-headers-th-active');
+        $(el_window).find('.explore-table-headers-th--name > .header-sort-icon').html(sort_icon);
+    }else if(sort_by === 'size'){
+        $(el_window).find('.explore-table-headers-th').removeClass('explore-table-headers-th-active');
+        $(el_window).find('.explore-table-headers-th--size').addClass('explore-table-headers-th-active');
+        $(el_window).find('.explore-table-headers-th--size > .header-sort-icon').html(sort_icon);
+    }else if(sort_by === 'modified'){
+        $(el_window).find('.explore-table-headers-th').removeClass('explore-table-headers-th-active');
+        $(el_window).find('.explore-table-headers-th--modified').addClass('explore-table-headers-th-active');
+        $(el_window).find('.explore-table-headers-th--modified > .header-sort-icon').html(sort_icon);
+    }else if(sort_by === 'type'){
+        $(el_window).find('.explore-table-headers-th').removeClass('explore-table-headers-th-active');
+        $(el_window).find('.explore-table-headers-th--type').addClass('explore-table-headers-th-active');
+        $(el_window).find('.explore-table-headers-th--type > .header-sort-icon').html(sort_icon);
+    }
+}
+
+// This is a hack to fix the issue where the window scrolls to the bottom when an app scrolls.
+// this is due to an issue with iframes being able to hijack the scroll event for the parent object.
+// w3c is working on a fix for this, but it's not ready yet.
+// more info here: https://github.com/w3c/webappsec-permissions-policy/issues/171
+document.addEventListener('scroll', function (event) {
+    if($(event.target).hasClass('window-app') || $(event.target).hasClass('window-app-iframe') || $(event.target?.activeElement).hasClass('window-app-iframe')){
+        setTimeout(function(){ 
+            // scroll window back to top
+            $('.window-app').scrollTop(0);
+            // some times it's document that scrolls, so we need to check that too
+            $(document).scrollTop(0);
+        }, 1);
+    }
+}, true);
+
+export default UIWindow;

+ 110 - 0
src/UI/UIWindowChangePassword.js

@@ -0,0 +1,110 @@
+import UIWindow from './UIWindow.js'
+
+async function UIWindowChangePassword(){
+    const internal_id = window.uuidv4();
+    let h = '';
+    h += `<div class="change-password" style="padding: 20px; border-bottom: 1px solid #ced7e1;">`;
+        // error msg
+        h += `<div class="form-error-msg"></div>`;
+        // success msg
+        h += `<div class="form-success-msg"></div>`;
+        // current password
+        h += `<div style="overflow: hidden; margin-bottom: 20px;">`;
+            h += `<label for="current-password-${internal_id}">Current Password</label>`;
+            h += `<input id="current-password-${internal_id}" class="current-password" type="password" name="current-password" autocomplete="current-password" />`;
+        h += `</div>`;
+        // new password
+        h += `<div style="overflow: hidden; margin-top: 20px; margin-bottom: 20px;">`;
+            h += `<label for="new-password-${internal_id}">New Password</label>`;
+            h += `<input id="new-password-${internal_id}" type="password" class="new-password" name="new-password" autocomplete="off" />`;
+        h += `</div>`;
+        // confirm new password
+        h += `<div style="overflow: hidden; margin-top: 20px; margin-bottom: 20px;">`;
+            h += `<label for="confirm-new-password-${internal_id}">Confirm New Password</label>`;
+            h += `<input id="confirm-new-password-${internal_id}" type="password" name="confirm-new-password" class="confirm-new-password" autocomplete="off" />`;
+        h += `</div>`;
+
+        // Change Password
+        h += `<button class="change-password-btn button button-primary button-block button-normal">Change Password</button>`;
+    h += `</div>`;
+
+    const el_window = await UIWindow({
+        title: 'Change Password',
+        app: 'change-passowrd',
+        single_instance: true,
+        icon: null,
+        uid: null,
+        is_dir: false,
+        body_content: h,
+        draggable_body: false,
+        has_head: true,
+        selectable_body: false,
+        draggable_body: false,
+        allow_context_menu: false,
+        is_resizable: false,
+        is_droppable: false,
+        init_center: true,
+        allow_native_ctxmenu: false,
+        allow_user_select: false,
+        width: 350,
+        height: 'auto',
+        dominant: true,
+        show_in_taskbar: false,
+        onAppend: function(this_window){
+            $(this_window).find(`.current-password`).get(0).focus({preventScroll:true});
+        },
+        window_class: 'window-publishWebsite',
+        body_css: {
+            width: 'initial',
+            height: '100%',
+            'background-color': 'rgb(245 247 249)',
+            'backdrop-filter': 'blur(3px)',
+        }    
+    })
+
+    $(el_window).find('.change-password-btn').on('click', function(e){
+        const current_password = $(el_window).find('.current-password').val();
+        const new_password = $(el_window).find('.new-password').val();
+        const confirm_new_password = $(el_window).find('.confirm-new-password').val();
+
+        let data;
+
+        if(current_password === '' || new_password === '' || confirm_new_password === ''){
+            $(el_window).find('.form-error-msg').html('All fields are required.');
+            $(el_window).find('.form-error-msg').fadeIn();
+            return;
+        }
+        else if(new_password !== confirm_new_password){
+            $(el_window).find('.form-error-msg').html('`New Password` and `Confirm New Password` do not match.');
+            $(el_window).find('.form-error-msg').fadeIn();
+            return;
+        }
+        
+        $(el_window).find('.form-error-msg').hide();
+    
+        $.ajax({
+            url: api_origin + "/passwd",
+            type: 'POST',
+            async: true,
+            headers: {
+                "Authorization": "Bearer "+auth_token
+            },
+            contentType: "application/json",
+            data: JSON.stringify({ 
+                old_pass: current_password, 
+                new_pass: new_password,
+            }),				
+            success: function (data){
+                $(el_window).find('.form-success-msg').html('Password changed successfully.');
+                $(el_window).find('.form-success-msg').fadeIn();
+                $(el_window).find('input').val('');
+            },
+            error: function (err){
+                $(el_window).find('.form-error-msg').html(err.responseText);
+                $(el_window).find('.form-error-msg').fadeIn();
+            }
+        });	
+    })
+}
+
+export default UIWindowChangePassword

+ 111 - 0
src/UI/UIWindowChangeUsername.js

@@ -0,0 +1,111 @@
+import UIWindow from './UIWindow.js'
+import update_username_in_gui from '../helpers/update_username_in_gui.js'
+
+async function UIWindowChangeUsername(){
+    const internal_id = window.uuidv4();
+    let h = '';
+    h += `<div class="change-username" style="padding: 20px; border-bottom: 1px solid #ced7e1;">`;
+        // error msg
+        h += `<div class="form-error-msg"></div>`;
+        // success msg
+        h += `<div class="form-success-msg"></div>`;
+        // new username
+        h += `<div style="overflow: hidden; margin-top: 10px; margin-bottom: 30px;">`;
+            h += `<label for="confirm-new-username-${internal_id}">New Username</label>`;
+            h += `<input id="confirm-new-username-${internal_id}" type="text" name="new-username" class="new-username" autocomplete="off" />`;
+        h += `</div>`;
+
+        // Change Username
+        h += `<button class="change-username-btn button button-primary button-block button-normal">Change Username</button>`;
+    h += `</div>`;
+
+    const el_window = await UIWindow({
+        title: 'Change Username',
+        app: 'change-username',
+        single_instance: true,
+        icon: null,
+        uid: null,
+        is_dir: false,
+        body_content: h,
+        draggable_body: false,
+        has_head: true,
+        selectable_body: false,
+        draggable_body: false,
+        allow_context_menu: false,
+        is_resizable: false,
+        is_droppable: false,
+        init_center: true,
+        allow_native_ctxmenu: false,
+        allow_user_select: false,
+        width: 350,
+        height: 'auto',
+        dominant: true,
+        show_in_taskbar: false,
+        onAppend: function(this_window){
+            $(this_window).find(`.new-username`).get(0)?.focus({preventScroll:true});
+        },
+        window_class: 'window-publishWebsite',
+        body_css: {
+            width: 'initial',
+            height: '100%',
+            'background-color': 'rgb(245 247 249)',
+            'backdrop-filter': 'blur(3px)',
+        }    
+    })
+
+    $(el_window).find('.change-username-btn').on('click', function(e){
+        // hide previous error/success msg
+        $(el_window).find('.form-success-msg, .form-success-msg').hide();
+
+        const new_username = $(el_window).find('.new-username').val();
+
+        if(!new_username){
+            $(el_window).find('.form-error-msg').html('All fields are required.');
+            $(el_window).find('.form-error-msg').fadeIn();
+            return;
+        }
+
+        $(el_window).find('.form-error-msg').hide();
+
+        // disable button
+        $(el_window).find('.change-username-btn').addClass('disabled');
+        // disable input
+        $(el_window).find('.new-username').attr('disabled', true);
+    
+        $.ajax({
+            url: api_origin + "/change_username",
+            type: 'POST',
+            async: true,
+            headers: {
+                "Authorization": "Bearer "+auth_token
+            },
+            contentType: "application/json",
+            data: JSON.stringify({ 
+                new_username: new_username, 
+            }),				
+            success: function (data){
+                $(el_window).find('.form-success-msg').html('Username updated successfully.');
+                $(el_window).find('.form-success-msg').fadeIn();
+                $(el_window).find('input').val('');
+                // update auth data
+                update_username_in_gui(new_username);
+                // update username
+                window.user.username = new_username;
+                // enable button
+                $(el_window).find('.change-username-btn').removeClass('disabled');
+                // enable input
+                $(el_window).find('.new-username').attr('disabled', false);
+            },
+            error: function (err){
+                $(el_window).find('.form-error-msg').html(html_encode(err.responseJSON?.message));
+                $(el_window).find('.form-error-msg').fadeIn();
+                // enable button
+                $(el_window).find('.change-username-btn').removeClass('disabled');
+                // enable input
+                $(el_window).find('.new-username').attr('disabled', false);
+            }
+        });	
+    })
+}
+
+export default UIWindowChangeUsername

+ 55 - 0
src/UI/UIWindowClaimReferral.js

@@ -0,0 +1,55 @@
+import UIWindow from './UIWindow.js'
+import UIWindowSaveAccount from './UIWindowSaveAccount.js';
+
+async function UIWindowClaimReferral(options){
+    let h = '';
+
+    h += `<div>`;
+        h += `<div class="qr-code-window-close-btn generic-close-window-button disable-user-select"> &times; </div>`;
+        h += `<img src="${window.icons['present.svg']}" style="width: 70px; margin: 20px auto 20px; display: block; margin-bottom: 20px;">`;
+        h += `<h1 style="font-weight: 400; padding: 0 10px; font-size: 21px; text-align: center; margin-bottom: 0; color: #60626d; -webkit-font-smoothing: antialiased;">You have been referred to Puter by a friend!</h1>`;
+        h += `<p style="text-align: center; font-size: 16px; padding: 20px; font-weight: 400; margin: -10px 10px 0px 10px; -webkit-font-smoothing: antialiased; color: #5f626d;">Create an account and confirm your email address to receive 1 GB of free storage. Your friend will get 1 GB of free storage too.</p>`;
+        h += `<button class="button button-primary button-block create-account-ref-btn" style="display: block;">Create Account</button>`;
+    h += `</div>`;
+
+    const el_window = await UIWindow({
+        title: `Refer a friend!`,
+        icon: null,
+        uid: null,
+        is_dir: false,
+        body_content: h,
+        has_head: false,
+        selectable_body: false,
+        draggable_body: true,
+        allow_context_menu: false,
+        is_draggable: true,
+        is_resizable: false,
+        is_droppable: false,
+        init_center: true,
+        allow_native_ctxmenu: true,
+        allow_user_select: true,
+        onAppend: function(el_window){
+        },
+        width: 400,
+        dominant: true,
+        window_css: {
+            height: 'initial',
+        },
+        body_css: {
+            padding: '10px',
+            width: 'initial',
+            'max-height': 'calc(100vh - 200px)',
+            'background-color': 'rgb(241 246 251)',
+            'backdrop-filter': 'blur(3px)',
+            'padding': '10px 20px 20px 20px',
+            'height': 'initial',
+        }    
+    });
+
+    $(el_window).find('.create-account-ref-btn').on('click', function(e){    
+        UIWindowSaveAccount();
+        $(el_window).close();
+    })
+}
+
+export default UIWindowClaimReferral

+ 110 - 0
src/UI/UIWindowColorPicker.js

@@ -0,0 +1,110 @@
+import UIWindow from './UIWindow.js'
+
+async function UIWindowColorPicker(options){
+    // set sensible defaults
+    if(arguments.length > 0){
+        // if first argument is a string, then assume it is the default color
+        if(isString(arguments[0])){
+            options = {};
+            options.default = arguments[0];
+        }
+    }
+    options = options ?? {};
+
+    return new Promise(async (resolve) => {
+        let colorPicker;
+
+        let h = ``;
+        h += `<div>`;
+            h += `<div style="padding: 20px; border-bottom: 1px solid #ced7e1; width: 100%; box-sizing: border-box;">`;
+                    // picker
+                    h += `<div style="padding: 0; margin-bottom: 20px;">`;
+                        h += `<div class="picker"></div>`;
+                    h += `</div>`;
+
+                    // Select button
+                    h += `<button class="select-btn button button-primary button-block button-normal">Select</button>`
+                h += `</form>`;
+            h += `</div>`;
+        h += `</div>`;
+        
+        const el_window = await UIWindow({
+            title: 'Select color…',
+            app: 'color-picker',
+            single_instance: true,
+            icon: null,
+            uid: null,
+            is_dir: false,
+            body_content: h,
+            draggable_body: false,
+            has_head: true,
+            selectable_body: false,
+            draggable_body: false,
+            allow_context_menu: false,
+            is_draggable: true,
+            is_droppable: false,
+            is_resizable: false,
+            stay_on_top: false,
+            allow_native_ctxmenu: true,
+            allow_user_select: true,
+            ...options.window_options,
+            width: 350,
+            dominant: true,
+            on_close: async ()=>{
+                resolve(false)
+            },
+            onAppend: function(window){
+                colorPicker = new iro.ColorPicker($(window).find('.picker').get(0), {
+                    layout: [
+                        {
+                            component: iro.ui.Box,
+                            options: {
+                                layoutDirection: 'horizontal',
+                                width: 265,
+                                height: 265,
+                            }
+                        },
+                        {
+                            component: iro.ui.Slider,
+                            options: {
+                                sliderType: 'alpha',
+                                layoutDirection: 'horizontal',
+                                height: 265,
+                                width:265,
+                            }
+                        },
+                        {
+                            component: iro.ui.Slider,
+                            options: {
+                                sliderType: 'hue',
+                            }
+                        },
+                    ],
+                    // Set the initial color to pure red
+                    color: options.default ?? "#f00",
+                });    
+            },
+            window_class: 'window-login',
+            window_css:{
+                height: 'initial',
+            },
+            body_css: {
+                width: 'initial',
+                padding: '0',
+                'background-color': 'rgba(231, 238, 245, .95)',
+                'backdrop-filter': 'blur(3px)',
+            }    
+        })
+
+        $(el_window).find('.select-btn').on('click', function(e){            
+            resolve({color: colorPicker.color.hex8String});
+            $(el_window).close();
+        })  
+        $(el_window).find('.font-selector').on('click', function(e){
+            $(el_window).find('.font-selector').removeClass('font-selector-active');
+            $(this).addClass('font-selector-active');
+        }) 
+    }) 
+}
+
+export default UIWindowColorPicker

+ 73 - 0
src/UI/UIWindowConfirmDownload.js

@@ -0,0 +1,73 @@
+import UIWindow from './UIWindow.js'
+
+// todo do this using uid rather than item_path, since item_path is way mroe expensive on the DB
+async function UIWindowConfirmDownload(options){
+    return new Promise(async (resolve) => {
+        let h = '';
+        h += `<div>`;
+            // Confirm download
+            h +=`<div style="margin-bottom:20px; float:left; padding-top:3px; font-size:15px; overflow: hidden; width: calc(100% - 40px); text-overflow: ellipsis; white-space: nowrap;">`;
+                // Message
+                h += `<p style="font-weight:bold;">Do you want to download this file?</p>`;
+                h += `<div style="overflow:hidden; float:left; width: 100px; height: 100px; display:flex; display: flex; justify-content: center; align-items: center;">`;
+                    h += `<img style="float:left; margin-right: 7px; width: 60px; height: 60px; filter: drop-shadow(0px 0px 1px rgba(102, 102, 102, 1));" src="${html_encode((await item_icon({is_dir: options.is_dir === '1' || options.is_dir === 'true', type: options.type, name: options.name})).image)}" />`;
+                h += `</div>`;
+                // Item information
+                h += `<div  style="overflow:hidden;">`;
+                    // Name
+                    h += `<p style="text-overflow: ellipsis; overflow: hidden;"><span class="dl-conf-item-attr">Name:</span> ${options.name ?? options.url}</p>`;
+                    // Type
+                    h += `<p style="text-overflow: ellipsis; overflow: hidden;"><span class="dl-conf-item-attr">Type:</span> ${options.is_dir === '1' || options.is_dir === 'true' ? 'Folder' : options.type  ?? 'Unknown File Type'}</p>`;
+                    // Source
+                    h += `<p style="text-overflow: ellipsis; overflow: hidden;"><span class="dl-conf-item-attr">From:</span> ${options.source}</p>`;
+                h += `</div>`;
+            h += `</div>`;
+            // Download
+            h += `<button style="float:right; margin-top: 15px; margin-right: -2px; margin-left:10px;" class="button button-small button-primary btn-download-confirm">Download</button>`;
+            // Cancel
+            h += `<button style="float:right; margin-top: 15px;" class="button button-small btn-download-cancel">Cancel</button>`;
+        h +=`</div>`;
+
+        const el_window = await UIWindow({
+            title: `Upload`,
+            icon: window.icons[`app-icon-uploader.svg`],
+            uid: null,
+            is_dir: false,
+            body_content: h,
+            draggable_body: false,
+            has_head: false,
+            selectable_body: false,
+            draggable_body: true,
+            allow_context_menu: false,
+            is_resizable: false,
+            is_droppable: false,
+            init_center: true,
+            allow_native_ctxmenu: false,
+            allow_user_select: false,
+            window_class: 'window-upload-progress',
+            width: 450,
+            dominant: true,
+            window_css:{
+                height: 'initial',
+            },
+            body_css: {
+                padding: '22px',
+                width: 'initial',
+                'background-color': 'rgba(231, 238, 245, .95)',
+                'backdrop-filter': 'blur(3px)',
+            }    
+        });
+
+        $(el_window).find('.btn-download-confirm').on('click submit', function(e){
+            $(el_window).close();
+            resolve(true);
+        })
+
+        $(el_window).find('.btn-download-cancel').on('click submit', function(e){
+            $(el_window).close();
+            resolve(false);
+        })
+    })
+}
+
+export default UIWindowConfirmDownload

+ 63 - 0
src/UI/UIWindowCopyProgress.js

@@ -0,0 +1,63 @@
+import UIWindow from './UIWindow.js'
+
+// todo do this using uid rather than item_path, since item_path is way mroe expensive on the DB
+async function UIWindowCopyProgress(options){
+    let h = '';
+    h += `<div data-copy-operation-id="${options.operation_id}">`;
+        h += `<div>`;
+            // spinner
+            h +=`<svg style="float:left; margin-right: 7px;" xmlns="http://www.w3.org/2000/svg" height="24" width="24" viewBox="0 0 24 24"><title>circle anim</title><g fill="#212121" class="nc-icon-wrapper"><g class="nc-loop-circle-24-icon-f"><path d="M12 24a12 12 0 1 1 12-12 12.013 12.013 0 0 1-12 12zm0-22a10 10 0 1 0 10 10A10.011 10.011 0 0 0 12 2z" fill="#212121" opacity=".4"></path><path d="M24 12h-2A10.011 10.011 0 0 0 12 2V0a12.013 12.013 0 0 1 12 12z" data-color="color-2"></path></g><style>.nc-loop-circle-24-icon-f{--animation-duration:0.5s;transform-origin:12px 12px;animation:nc-loop-circle-anim var(--animation-duration) infinite linear}@keyframes nc-loop-circle-anim{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}</style></g></svg>`;
+            // Progress report
+            h +=`<div style="margin-bottom:20px; float:left; padding-top:3px; font-size:15px; overflow: hidden; width: calc(100% - 40px); text-overflow: ellipsis; white-space: nowrap;">`;
+                // msg
+                h += `<span class="copy-progress-msg">Copying </span>`;
+                h += `<span class="copy-from" style="font-weight:strong;"></span>`;
+            h += `</div>`;
+            // progress
+            h += `<div class="copy-progress-bar-container" style="clear:both; margin-top:20px; border-radius:3px;">`;
+                h += `<div class="copy-progress-bar"></div>`;
+            h += `</div>`;
+            // cancel
+            // h += `<button style="float:right; margin-top: 15px; margin-right: -2px;" class="button button-small copy-cancel-btn">Cancel</button>`;
+        h +=`</div>`;
+    h += `</div>`;
+
+    const el_window = await UIWindow({
+        title: `Copying`,
+        icon: window.icons[`app-icon-copying.svg`],
+        uid: null,
+        is_dir: false,
+        body_content: h,
+        draggable_body: false,
+        has_head: false,
+        selectable_body: false,
+        draggable_body: true,
+        allow_context_menu: false,
+        is_resizable: false,
+        is_droppable: false,
+        init_center: true,
+        allow_native_ctxmenu: false,
+        allow_user_select: false,
+        window_class: 'window-copy-progress',
+        width: 450,
+        dominant: true,
+        window_css:{
+            height: 'initial',
+        },
+        body_css: {
+            padding: '22px',
+            width: 'initial',
+            'background-color': 'rgba(231, 238, 245, .95)',
+            'backdrop-filter': 'blur(3px)',
+        }    
+    });
+
+    $(el_window).find('.copy-cancel-btn').on('click', function(e){
+        operation_cancelled[options.operation_id] = true;
+        $(el_window).close();
+    })
+
+    return el_window;
+}
+
+export default UIWindowCopyProgress

+ 189 - 0
src/UI/UIWindowDesktopBGSettings.js

@@ -0,0 +1,189 @@
+import UIWindow from './UIWindow.js'
+
+async function UIWindowDesktopBGSettings(){
+    return new Promise(async (resolve) => {
+        let h = '';
+        const original_background_css = $('body').attr('style');
+        let bg_url = window.desktop_bg_url, 
+            bg_color = window.desktop_bg_color, 
+            bg_fit = window.desktop_bg_fit;
+
+        h += `<div style="padding: 10px; border-bottom: 1px solid #ced7e1;">`;
+
+            // type
+            h += `<label>Background:</label>`;
+            h += `<select class="desktop-bg-type" style="width: 150px; margin-bottom: 20px;">`
+                h += `<option value="picture">Picture</option>`;
+                h += `<option value="color">Color</option>`;
+            h += `</select>`;
+
+            // Picture
+            h += `<div class="desktop-bg-settings-wrapper desktop-bg-settings-picture">`;
+                h += `<label>Image:</label>`;
+                h += `<button class="button button-default button-small browse">Browse</button>`;
+                h += `<label style="margin-top: 20px;">Fit:</label>`;
+                h += `<select class="desktop-bg-fit" style="width: 150px;">`
+                    h += `<option value="cover">Cover</option>`;
+                    h += `<option value="center">Center</option>`;
+                    h += `<option value="contain">Contain</option>`;
+                    h += `<option value="repeat">Repeat</option>`;
+                h += `</select>`;
+            h += `</div>`
+
+            // Color
+            h += `<div class="desktop-bg-settings-wrapper desktop-bg-settings-color">`;
+                h += `<label>Color:</label>`;
+                h += `<div class="desktop-bg-color-blocks">`;
+                    h += `<div class="desktop-bg-color-block" data-color="#4F7BB5" style="background-color: #4F7BB5"></div>`;
+                    h += `<div class="desktop-bg-color-block" data-color="#545554" style="background-color: #545554"></div>`;
+                    h += `<div class="desktop-bg-color-block" data-color="#F5D3CE" style="background-color: #F5D3CE"></div>`;
+                    h += `<div class="desktop-bg-color-block" data-color="#52A758" style="background-color: #52A758"></div>`;
+                    h += `<div class="desktop-bg-color-block" data-color="#ad3983" style="background-color: #ad3983"></div>`;
+                    h += `<div class="desktop-bg-color-block" data-color="#ffffff" style="background-color: #ffffff"></div>`;
+                    h += `<div class="desktop-bg-color-block" data-color="#000000" style="background-color: #000000"></div>`;
+                    h += `<div class="desktop-bg-color-block" data-color="#454545" style="background-color: #454545"></div>`;
+                    h += `<div class="desktop-bg-color-block desktop-bg-color-block-palette" data-color="" style="background-image: url(${window.icons['palette.svg']});
+                    background-repeat: no-repeat;
+                    background-size: contain;
+                    background-position: center;"><input type="color" style="width:25px; height: 25px; opacity:0;"></div>`;
+                h += `</div>`;
+            h += `</div>`;
+
+            h += `<div style="padding-top: 5px; overflow:hidden; margin-top: 25px; border-top: 1px solid #CCC;">`
+                h += `<button class="button button-primary apply" style="float:right;">Apply</button>`;
+                h += `<button class="button button-default cancel" style="float:right; margin-right: 10px;">Cancel</button>`;
+            h += `</div>`;
+
+        h += `</div>`;
+
+        const el_window = await UIWindow({
+            title: 'Change Desktop Background…',
+            icon: null,
+            uid: null,
+            is_dir: false,
+            body_content: h,
+            draggable_body: false,
+            has_head: true,
+            selectable_body: false,
+            draggable_body: false,
+            allow_context_menu: false,
+            is_resizable: false,
+            is_droppable: false,
+            init_center: true,
+            allow_native_ctxmenu: true,
+            allow_user_select: true,
+            onAppend: function(this_window){
+                $(this_window).find(`.access-recipient`).focus();
+            },
+            window_class: 'window-give-access',
+            width: 350,
+            window_css: {
+                height: 'initial',
+            },
+            body_css: {
+                width: 'initial',
+                height: '100%',
+                'background-color': 'rgb(245 247 249)',
+                'backdrop-filter': 'blur(3px)',
+            }    
+        })
+
+        if(window.desktop_bg_url !== undefined && window.desktop_bg_url !== null){
+            $(el_window).find('.desktop-bg-settings-wrapper').hide();
+            $(el_window).find('.desktop-bg-settings-picture').show();
+            $(el_window).find('.desktop-bg-type').val('picture');
+        }else if(window.desktop_bg_color !== undefined && window.desktop_bg_color !== null){
+            $(el_window).find('.desktop-bg-settings-wrapper').hide();
+            $(el_window).find('.desktop-bg-settings-color').show();
+            $(el_window).find('.desktop-bg-type').val('color');
+        }else{
+            $(el_window).find('.desktop-bg-settings-wrapper').hide();
+            $(el_window).find('.desktop-bg-settings-picture').show();
+            $(el_window).find('.desktop-bg-type').val('picture');
+        }
+
+        $(el_window).find('.desktop-bg-color-block:not(.desktop-bg-color-block-palette').on('click', async function(e){
+            window.set_desktop_background({color: $(this).attr('data-color')})
+        })
+        $(el_window).find('.desktop-bg-color-block-palette input').on('change', async function(e){
+            window.set_desktop_background({color: $(this).val()})
+        })
+        $(el_window).on('file_opened', function(e){
+            let selected_file = Array.isArray(e.detail) ? e.detail[0] : e.detail;
+            const fit = $(el_window).find('.desktop-bg-fit').val();
+            bg_url = selected_file.read_url;
+            bg_fit = fit;
+            bg_color = undefined;
+            window.set_desktop_background({url: bg_url, fit: bg_fit})
+        })
+
+        $(el_window).find('.desktop-bg-fit').on('change', function(e){
+            const fit = $(this).val();
+            bg_fit = fit;
+            window.set_desktop_background({fit: fit})
+        })
+
+        $(el_window).find('.desktop-bg-type').on('change', function(e){
+            const type = $(this).val();
+            if(type === 'picture'){
+                $(el_window).find('.desktop-bg-settings-wrapper').hide();
+                $(el_window).find('.desktop-bg-settings-picture').show();
+            }else if(type==='color'){
+                $(el_window).find('.desktop-bg-settings-wrapper').hide();
+                $(el_window).find('.desktop-bg-settings-color').show();
+            }
+        })
+
+        $(el_window).find('.apply').on('click', async function(e){
+            // /set-desktop-bg
+            try{
+                $.ajax({
+                    url: api_origin + "/set-desktop-bg",
+                    type: 'POST',
+                    data: JSON.stringify({ 
+                        url: window.desktop_bg_url,
+                        color: window.desktop_bg_color,
+                        fit: window.desktop_bg_fit,
+                    }),
+                    async: true,
+                    contentType: "application/json",
+                    headers: {
+                        "Authorization": "Bearer "+auth_token
+                    },
+                    statusCode: {
+                        401: function () {
+                            logout();
+                        },
+                    },
+                })
+                $(el_window).close();
+                resolve(true);    
+            }catch(err){
+            }
+        })
+
+        $(el_window).find('.browse').on('click', function(){
+            // open dialog
+            UIWindow({
+                path: '/' + window.user.username + '/Desktop',
+                // this is the uuid of the window to which this dialog will return
+                parent_uuid: $(el_window).attr('data-element_uuid'),
+                allowed_file_types: ['image/*'],
+                show_maximize_button: false,
+                show_minimize_button: false,
+                title: 'Open',
+                is_dir: true,
+                is_openFileDialog: true,
+                selectable_body: false,
+            });
+        })
+
+        $(el_window).find('.cancel').on('click', function(){
+            $('body').attr('style', original_background_css);
+            $(el_window).close();
+            resolve(true);
+        })
+    })
+}
+
+export default UIWindowDesktopBGSettings

+ 53 - 0
src/UI/UIWindowDownloadDirProg.js

@@ -0,0 +1,53 @@
+import UIWindow from './UIWindow.js'
+
+async function UIWindowDownloadDirProg(options){
+    options = options ?? {};
+
+    let h = '';
+    // Loading spinner
+    h +=`<svg style="height: 40px; width: 40px; padding: 10px; display: block; float: left;" xmlns="http://www.w3.org/2000/svg" height="24" width="24" viewBox="0 0 24 24"><title>circle anim</title><g fill="#212121" class="nc-icon-wrapper"><g class="nc-loop-circle-24-icon-f"><path d="M12 24a12 12 0 1 1 12-12 12.013 12.013 0 0 1-12 12zm0-22a10 10 0 1 0 10 10A10.011 10.011 0 0 0 12 2z" fill="#212121" opacity=".4"></path><path d="M24 12h-2A10.011 10.011 0 0 0 12 2V0a12.013 12.013 0 0 1 12 12z" data-color="color-2"></path></g><style>.nc-loop-circle-24-icon-f{--animation-duration:0.5s;transform-origin:12px 12px;animation:nc-loop-circle-anim var(--animation-duration) infinite linear}@keyframes nc-loop-circle-anim{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}</style></g></svg>`;
+    h += `<p style="text-align:left; padding-left:20px; padding-right:20px; overflow:hidden; width: 310px; text-overflow: ellipsis; white-space: nowrap; float:left; font-size:14px;" class="dir-dl-status">${options.defaultText ?? 'Preparing...'}</p>`;
+
+    const el_window = await UIWindow({
+        title: 'Instant Login!',
+        app: 'instant-login',
+        single_instance: true,
+        icon: null,
+        uid: null,
+        is_dir: false,
+        body_content: h,
+        draggable_body: false,
+        has_head: false,
+        selectable_body: false,
+        draggable_body: false,
+        allow_context_menu: false,
+        is_resizable: false,
+        is_droppable: false,
+        init_center: true,
+        allow_native_ctxmenu: false,
+        allow_user_select: false,
+        backdrop: false,
+        width: 460,
+        height: 'auto',
+        dominant: true,
+        show_in_taskbar: false,
+        draggable_body: true,
+        onAppend: function(this_window){
+        },
+        window_class: 'window-qr',
+        body_css: {
+            width: 'initial',
+            height: '100px',
+            'background-color': 'rgb(245 247 249)',
+            'backdrop-filter': 'blur(3px)',
+            'display': 'flex',
+            "flex-direction": 'row',
+            'justify-content': 'center',
+            'align-items': 'center',
+        }    
+    })       
+
+    return el_window;
+}
+
+export default UIWindowDownloadDirProg

+ 63 - 0
src/UI/UIWindowDownloadProgress.js

@@ -0,0 +1,63 @@
+import UIWindow from './UIWindow.js'
+
+// todo do this using uid rather than item_path, since item_path is way mroe expensive on the DB
+async function UIWindowDownloadProgress(options){
+    let h = '';
+    h += `<div data-download-operation-id="${options.operation_id}">`;
+        h += `<div>`;
+            // Spinner
+            h +=`<svg style="float:left; margin-right: 7px;" xmlns="http://www.w3.org/2000/svg" height="24" width="24" viewBox="0 0 24 24"><title>circle anim</title><g fill="#212121" class="nc-icon-wrapper"><g class="nc-loop-circle-24-icon-f"><path d="M12 24a12 12 0 1 1 12-12 12.013 12.013 0 0 1-12 12zm0-22a10 10 0 1 0 10 10A10.011 10.011 0 0 0 12 2z" fill="#212121" opacity=".4"></path><path d="M24 12h-2A10.011 10.011 0 0 0 12 2V0a12.013 12.013 0 0 1 12 12z" data-color="color-2"></path></g><style>.nc-loop-circle-24-icon-f{--animation-duration:0.5s;transform-origin:12px 12px;animation:nc-loop-circle-anim var(--animation-duration) infinite linear}@keyframes nc-loop-circle-anim{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}</style></g></svg>`;
+            // Progress report
+            h +=`<div style="margin-bottom:20px; float:left; padding-top:3px; font-size:15px; overflow: hidden; width: calc(100% - 40px); text-overflow: ellipsis; white-space: nowrap;">`;
+                // msg
+                h += `<span class="upload-progress-msg">Downloading <strong>${options.item_name ?? ''}</strong></span>`;
+            h += `</div>`;
+            // Progress
+            h += `<div class="download-progress-bar-container" style="clear:both; margin-top:20px; border-radius:3px;">`;
+                h += `<div class="download-progress-bar"></div>`;
+            h += `</div>`;
+            // Cancel
+            h += `<button style="float:right; margin-top: 15px; margin-right: -2px;" class="button button-small download-cancel-btn">Cancel</button>`;
+        h +=`</div>`;
+    h += `</div>`;
+
+    const el_window = await UIWindow({
+        title: `Upload`,
+        icon: window.icons[`app-icon-uploader.svg`],
+        uid: null,
+        is_dir: false,
+        body_content: h,
+        draggable_body: false,
+        has_head: false,
+        selectable_body: false,
+        draggable_body: true,
+        allow_context_menu: false,
+        is_resizable: false,
+        is_droppable: false,
+        init_center: true,
+        allow_native_ctxmenu: false,
+        allow_user_select: false,
+        window_class: 'window-upload-progress',
+        width: 450,
+        dominant: true,
+        window_css:{
+            height: 'initial',
+        },
+        body_css: {
+            padding: '22px',
+            width: 'initial',
+            'background-color': 'rgba(231, 238, 245, .95)',
+            'backdrop-filter': 'blur(3px)',
+        }    
+    });
+
+    // cancel download button clicked
+    $(el_window).find('.download-cancel-btn').on('click', function(){
+        operation_cancelled[options.operation_id] = true;
+        $(el_window).close();
+    })
+
+    return el_window;
+}
+
+export default UIWindowDownloadProgress

+ 258 - 0
src/UI/UIWindowEmailConfirmationRequired.js

@@ -0,0 +1,258 @@
+import UIWindow from './UIWindow.js'
+import UIAlert from './UIAlert.js'
+
+function UIWindowEmailConfirmationRequired(options){
+    return new Promise(async (resolve) => {
+        options = options ?? {};
+        let final_code = '';
+        let is_checking_code = false;
+
+        const submit_btn_txt = 'Confirm Email'
+        let h = '';
+        h += `<div class="qr-code-window-close-btn generic-close-window-button"> &times; </div>`;
+        h += `<div style="-webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; color: #3e5362;">`;
+            h += `<img src="${html_encode(window.icons['mail.svg'])}" style="display:block; margin:10px auto 10px;">`;
+            h += `<h3 style="text-align:center; font-weight: 500; font-size: 20px;">Confirm Your Email Address</h3>`;
+            h += `<form>`;
+                h += `<p style="text-align:center; padding: 0 20px;">To continue, please enter the 6-digit confirmation code sent to <strong style="font-weight: 500;">${window.user.email}</strong></p>`;
+                h += `<div class="error"></div>`;
+                h += `  <fieldset name="number-code" style="border: none; padding:0;" data-number-code-form>
+                <input class="digit-input" type="number" min='0' max='9' name='number-code-0' data-number-code-input='0' required />
+                <input class="digit-input" type="number" min='0' max='9' name='number-code-1' data-number-code-input='1' required />
+                <input class="digit-input" type="number" min='0' max='9' name='number-code-2' data-number-code-input='2' required />
+                <span class="email-confirm-code-hyphen">-</span>
+                <input class="digit-input" type="number" min='0' max='9' name='number-code-3' data-number-code-input='3' required />
+                <input class="digit-input" type="number" min='0' max='9' name='number-code-4' data-number-code-input='4' required />
+                <input class="digit-input" type="number" min='0' max='9' name='number-code-5' data-number-code-input='5' required />
+              </fieldset>`;
+                h += `<button type="submit" class="button button-block button-primary email-confirm-btn" style="margin-top:10px;" disabled>${submit_btn_txt}</button>`;
+            h += `</form>`;
+            h += `<div style="text-align:center; padding:10px; font-size:14px; margin-top:10px;">`;
+                h += `<span class="send-conf-email">Re-send Confirmation Code</span>`;
+                if(options.logout_in_footer){
+                    h += ` &bull; `;
+                    h += `<span class="conf-email-log-out">Log Out</span>`;
+                }
+            h += `</div>`;
+        h += `</div>`;
+
+        const el_window = await UIWindow({
+            title: null,
+            backdrop: options.backdrop ?? false,
+            icon: null,
+            uid: null,
+            is_dir: false,
+            body_content: h,
+            draggable_body: false,
+            has_head: false,
+            selectable_body: false,
+            draggable_body: true,
+            allow_context_menu: false,
+            is_draggable: options.is_draggable ?? true,
+            is_droppable: false,
+            is_resizable: false,
+            stay_on_top: options.stay_on_top ?? false,
+            allow_native_ctxmenu: true,
+            allow_user_select: true,
+            backdrop: true,
+            width: 390,
+            dominant: true,
+            onAppend: function(el_window){
+                $(el_window).find('.digit-input').first().focus();
+            },
+            window_class: 'window-item-properties',
+            window_css:{
+                height: 'initial',
+            },
+            body_css: {
+                padding: '30px',
+                width: 'initial',
+                height: 'initial',
+                'background-color': 'rgb(247 251 255)',
+                'backdrop-filter': 'blur(3px)',
+            }
+        })
+
+        $(el_window).find('.digit-input').first().focus();
+
+        $(el_window).find('.email-confirm-btn').on('click submit', function(e){
+            e.preventDefault();
+            e.stopPropagation();
+
+            $(el_window).find('.email-confirm-btn').prop('disabled', true);
+            $(el_window).find('.error').hide();
+            
+            // Check if already checking code to prevent multiple requests
+            if(is_checking_code)
+                return;
+            // Confirm button
+            is_checking_code = true;
+
+            // set animation
+            $(el_window).find('.email-confirm-btn').html(`<svg style="width:20px; margin-top: 5px;" xmlns="http://www.w3.org/2000/svg" height="24" width="24" viewBox="0 0 24 24"><title>circle anim</title><g fill="#fff" class="nc-icon-wrapper"><g class="nc-loop-circle-24-icon-f"><path d="M12 24a12 12 0 1 1 12-12 12.013 12.013 0 0 1-12 12zm0-22a10 10 0 1 0 10 10A10.011 10.011 0 0 0 12 2z" fill="#eee" opacity=".4"></path><path d="M24 12h-2A10.011 10.011 0 0 0 12 2V0a12.013 12.013 0 0 1 12 12z" data-color="color-2"></path></g><style>.nc-loop-circle-24-icon-f{--animation-duration:0.5s;transform-origin:12px 12px;animation:nc-loop-circle-anim var(--animation-duration) infinite linear}@keyframes nc-loop-circle-anim{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}</style></g></svg>`);
+
+            setTimeout(() => {
+                $.ajax({
+                    url: api_origin + "/confirm-email",
+                    type: 'POST',
+                    data: JSON.stringify({
+                        code: final_code,
+                    }),
+                    async: true,
+                    contentType: "application/json",
+                    headers: {
+                        "Authorization": "Bearer "+auth_token
+                    },
+                    statusCode: {
+                        401: function () {
+                            logout();
+                        },
+                    },        
+                    success: function (res){
+                        if(res.email_confirmed){
+                            $(el_window).close();
+                            refresh_user_data(window.auth_token)
+                            resolve(true);
+                        }else{
+                            $(el_window).find('.error').html('Invalid confirmation code.');
+                            $(el_window).find('.error').fadeIn();
+                            $(el_window).find('.digit-input').val('');
+                            $(el_window).find('.digit-input').first().focus();
+                            $(el_window).find('.email-confirm-btn').prop('disabled', false);
+                            $(el_window).find('.email-confirm-btn').html(submit_btn_txt);
+                        }
+                    },
+                    error: function(res){
+                        $(el_window).find('.error').html(res.responseJSON.error);
+                        $(el_window).find('.error').fadeIn();
+                        $(el_window).find('.digit-input').val('');
+                        $(el_window).find('.digit-input').first().focus();
+                        $(el_window).find('.email-confirm-btn').prop('disabled', false);
+                        $(el_window).find('.email-confirm-btn').html(submit_btn_txt);
+                    },
+                    complete: function(){
+                        is_checking_code = false;
+                    }
+                })
+            }, 1000);
+        })
+
+        // send email confirmation
+        $(el_window).find('.send-conf-email').on('click', function(e){
+            $.ajax({
+                url: api_origin + "/send-confirm-email",
+                type: 'POST',
+                async: true,
+                contentType: "application/json",
+                headers: {
+                    "Authorization": "Bearer "+auth_token
+                },
+                statusCode: {
+                    401: function () {
+                        logout();
+                    },
+                },        
+                success: async function (res){
+                    await UIAlert({
+                        message: `A new confirmation code has been sent to <strong>${window.user.email}</strong>.`,
+                        body_icon: window.icons['c-check.svg'],
+                        stay_on_top: true,
+                        backdrop: true,
+                    })
+                    $(el_window).find('.digit-input').first().focus();
+                },
+                complete: function(){
+                }
+            })
+        })
+
+        // logout
+        $(el_window).find('.conf-email-log-out').on('click', function(e){
+            logout();
+            $(el_window).close();
+        })
+
+        // Elements
+        const numberCodeForm = document.querySelector('[data-number-code-form]');
+        const numberCodeInputs = [...numberCodeForm.querySelectorAll('[data-number-code-input]')];
+
+        // Event listeners
+        numberCodeForm.addEventListener('input', ({ target }) => {
+            if(!target.value.length) { return target.value = null; }
+            const inputLength = target.value.length;
+            let currentIndex = Number(target.dataset.numberCodeInput);
+            if(inputLength === 2){
+                const inputValues = target.value.split('');
+                target.value = inputValues[0];
+            }
+            else if (inputLength > 1) {
+                const inputValues = target.value.split('');
+
+                inputValues.forEach((value, valueIndex) => {
+                    const nextValueIndex = currentIndex + valueIndex;
+
+                    if (nextValueIndex >= numberCodeInputs.length) { return; }
+
+                    numberCodeInputs[nextValueIndex].value = value;
+                });
+                currentIndex += inputValues.length - 2;
+            }
+
+            const nextIndex = currentIndex + 1;
+
+            if (nextIndex < numberCodeInputs.length) {
+                numberCodeInputs[nextIndex].focus();
+            }
+
+            // Concatenate all inputs into one string to create the final code
+            final_code = '';
+            for(let i=0; i< numberCodeInputs.length; i++){
+                final_code += numberCodeInputs[i].value;
+            }
+            // Automatically submit if 6 digits entered
+            if(final_code.length === 6){
+                $(el_window).find('.email-confirm-btn').prop('disabled', false);
+                $(el_window).find('.email-confirm-btn').trigger('click');
+            }
+        });
+
+        numberCodeForm.addEventListener('keydown', (e) => {
+            const { code, target } = e;
+
+            const currentIndex = Number(target.dataset.numberCodeInput);
+            const previousIndex = currentIndex - 1;
+            const nextIndex = currentIndex + 1;
+
+            const hasPreviousIndex = previousIndex >= 0;
+            const hasNextIndex = nextIndex <= numberCodeInputs.length - 1
+
+            switch (code) {
+                case 'ArrowLeft':
+                case 'ArrowUp':
+                    if (hasPreviousIndex) {
+                        numberCodeInputs[previousIndex].focus();
+                    }
+                    e.preventDefault();
+                    break;
+
+                case 'ArrowRight':
+                case 'ArrowDown':
+                    if (hasNextIndex) {
+                        numberCodeInputs[nextIndex].focus();
+                    }
+                    e.preventDefault();
+                    break;
+                case 'Backspace':
+                    if (!e.target.value.length && hasPreviousIndex) {
+                        numberCodeInputs[previousIndex].value = null;
+                        numberCodeInputs[previousIndex].focus();
+                    }
+                    break;
+                default:
+                    break;
+            }
+        });
+    })
+}
+
+export default UIWindowEmailConfirmationRequired

+ 80 - 0
src/UI/UIWindowFeedback.js

@@ -0,0 +1,80 @@
+import UIWindow from './UIWindow.js'
+
+async function UIWindowQR(options){
+    return new Promise(async (resolve) => {
+        options = options ?? {};
+
+        let h = '';
+        h += `<div style="padding: 20px; margin-top: 0;">`;
+            // success
+            h += `<div class="feedback-sent-success">`;
+                h += `<img src="${html_encode(window.icons['c-check.svg'])}" style="width:50px; height:50px; display: block; margin:10px auto;">`;
+                h += `<p style="text-align:center; margin-bottom:10px; color: #005300; padding: 10px;">Thank you for contacting us. If you have an email associated with your account, you will hear back from us as soon as possible.</p>`;
+            h+= `</div>`;
+            // form
+            h += `<div class="feedback-form">`;
+                h += `<p style="margin-top:0; font-size: 15px; -webkit-font-smoothing: antialiased;">Please use the form below to send us your feedback, comments, and bug reports.</p>`;
+                h += `<textarea class="feedback-message" style="width:100%; height: 200px; padding: 10px; box-sizing: border-box;"></textarea>`;
+                h += `<button class="button button-primary send-feedback-btn" style="float: right; margin-bottom: 15px; margin-top: 10px;">Send</button>`;
+            h += `</div>`;
+        h += `</div>`;
+
+        const el_window = await UIWindow({
+            title: 'Contact Us',
+            app: 'feedback',
+            single_instance: true,
+            icon: null,
+            uid: null,
+            is_dir: false,
+            body_content: h,
+            draggable_body: false,
+            has_head: true,
+            selectable_body: false,
+            draggable_body: false,
+            allow_context_menu: false,
+            is_resizable: false,
+            is_droppable: false,
+            init_center: true,
+            allow_native_ctxmenu: false,
+            allow_user_select: false,
+            width: 350,
+            height: 'auto',
+            dominant: true,
+            show_in_taskbar: false,
+            onAppend: function(this_window){
+                $(this_window).find('.feedback-message').get(0).focus({preventScroll:true});
+            },
+            window_class: 'window-feedback',
+            body_css: {
+                width: 'initial',
+                height: '100%',
+                'background-color': 'rgb(245 247 249)',
+                'backdrop-filter': 'blur(3px)',
+            }    
+        })
+
+        $(el_window).find('.send-feedback-btn').on('click', function(e){
+            const message = $(el_window).find('.feedback-message').val();
+            if(message)
+                $(this).prop('disabled', true);
+            $.ajax({
+                url: api_origin + "/contactUs",
+                type: 'POST',
+                async: true,
+                contentType: "application/json",
+                headers: {
+                    "Authorization": "Bearer "+auth_token
+                },    
+                data: JSON.stringify({ 
+                    message: message,
+                }),
+                success: async function (data){
+                    $(el_window).find('.feedback-form').hide();
+                    $(el_window).find('.feedback-sent-success').show(100);
+                }
+            })
+        })
+    })
+}
+
+export default UIWindowQR

+ 103 - 0
src/UI/UIWindowFontPicker.js

@@ -0,0 +1,103 @@
+import UIWindow from './UIWindow.js'
+
+let fontAvailable = new Set();
+const font_list = new Set([
+    // Windows 10
+    'Arial', 'Arial Black', 'Bahnschrift', 'Calibri', 'Cambria', 'Cambria Math', 'Candara', 'Comic Sans MS', 'Consolas', 'Constantia', 'Corbel', 'Courier New', 'Ebrima', 'Franklin Gothic Medium', 'Gabriola', 'Gadugi', 'Georgia', 'HoloLens MDL2 Assets', 'Impact', 'Ink Free', 'Javanese Text', 'Leelawadee UI', 'Lucida Console', 'Lucida Sans Unicode', 'Malgun Gothic', 'Marlett', 'Microsoft Himalaya', 'Microsoft JhengHei', 'Microsoft New Tai Lue', 'Microsoft PhagsPa', 'Microsoft Sans Serif', 'Microsoft Tai Le', 'Microsoft YaHei', 'Microsoft Yi Baiti', 'MingLiU-ExtB', 'Mongolian Baiti', 'MS Gothic', 'MV Boli', 'Myanmar Text', 'Nirmala UI', 'Palatino Linotype', 'Segoe MDL2 Assets', 'Segoe Print', 'Segoe Script', 'Segoe UI', 'Segoe UI Historic', 'Segoe UI Emoji', 'Segoe UI Symbol', 'SimSun', 'Sitka', 'Sylfaen', 'Symbol', 'Tahoma', 'Times New Roman', 'Trebuchet MS', 'Verdana', 'Webdings', 'Wingdings', 'Yu Gothic',
+    // macOS
+    'American Typewriter', 'Andale Mono', 'Arial', 'Arial Black', 'Arial Narrow', 'Arial Rounded MT Bold', 'Arial Unicode MS', 'Avenir', 'Avenir Next', 'Avenir Next Condensed', 'Baskerville', 'Big Caslon', 'Bodoni 72', 'Bodoni 72 Oldstyle', 'Bodoni 72 Smallcaps', 'Bradley Hand', 'Brush Script MT', 'Chalkboard', 'Chalkboard SE', 'Chalkduster', 'Charter', 'Cochin', 'Comic Sans MS', 'Copperplate', 'Courier', 'Courier New', 'Didot', 'DIN Alternate', 'DIN Condensed', 'Futura', 'Geneva', 'Georgia', 'Gill Sans', 'Helvetica', 'Helvetica Neue', 'Herculanum', 'Hoefler Text', 'Impact', 'Lucida Grande', 'Luminari', 'Marker Felt', 'Menlo', 'Microsoft Sans Serif', 'Monaco', 'Noteworthy', 'Optima', 'Palatino', 'Papyrus', 'Phosphate', 'Rockwell', 'Savoye LET', 'SignPainter', 'Skia', 'Snell Roundhand', 'Tahoma', 'Times', 'Times New Roman', 'Trattatello', 'Trebuchet MS', 'Verdana', 'Zapfino',
+].sort());
+
+// filter through available system fonts
+(async () => {
+    await document.fonts.ready;
+
+    for (const font of font_list.values()) {
+        if (document.fonts.check(`12px "${font}"`)) {
+            fontAvailable.add(font);
+        }
+    }
+})();
+
+async function UIWindowFontPicker(options){
+    // set sensible defaults
+    if(arguments.length > 0){
+        // if first argument is a string, then assume it is the default color
+        if(isString(arguments[0])){
+            options = {};
+            options.default = arguments[0];
+        }
+    }
+    options = options || {};
+
+    return new Promise(async (resolve) => {
+        let h = ``;
+        h += `<div>`;
+            h += `<div style="padding: 20px; border-bottom: 1px solid #ced7e1; width: 100%; box-sizing: border-box;">`;
+                    h += `<div class="font-list" style="margin-bottom: 10px; height: 200px; overflow-y: scroll; background-color: white; padding: 0 10px;">`;
+                        fontAvailable.forEach(element => {
+                            h += `<p class="font-selector disable-user-select ${options.default === element ? 'font-selector-active' : ''}" style="font-family: '${html_encode(element)}';" data-font-family="${html_encode(element)}">${element}</p>`; // 👉️ one, two, three, four
+                        });
+                    h += `</div>`;
+
+                    // Select
+                    h += `<button class="select-btn button button-primary button-block button-normal">Select</button>`
+                h += `</form>`;
+            h += `</div>`;
+        h += `</div>`;
+        
+        const el_window = await UIWindow({
+            title: 'Select font…',
+            app: 'font-picker',
+            single_instance: true,
+            icon: null,
+            uid: null,
+            is_dir: false,
+            body_content: h,
+            draggable_body: false,
+            has_head: true,
+            selectable_body: false,
+            draggable_body: false,
+            allow_context_menu: false,
+            is_draggable: true,
+            is_droppable: false,
+            is_resizable: false,
+            stay_on_top: false,
+            allow_native_ctxmenu: true,
+            allow_user_select: true,
+            ...options.window_options,
+            width: 350,
+            dominant: true,
+            on_close: ()=>{
+                resolve(false)
+            },
+            onAppend: function(window){
+                let active_font = $(window).find('.font-selector-active');
+                if(active_font.length > 0){
+                    scrollParentToChild($(window).find('.font-list').get(0), active_font.get(0));
+                }
+            },
+            window_class: 'window-login',
+            window_css:{
+                height: 'initial',
+            },
+            body_css: {
+                width: 'initial',
+                padding: '0',
+                'background-color': 'rgba(231, 238, 245, .95)',
+                'backdrop-filter': 'blur(3px)',
+            }    
+        })
+
+        $(el_window).find('.select-btn').on('click', function(e){
+            resolve({fontFamily: $(el_window).find('.font-selector-active').attr('data-font-family')});
+            $(el_window).close();
+        })  
+        $(el_window).find('.font-selector').on('click', function(e){
+            $(el_window).find('.font-selector').removeClass('font-selector-active');
+            $(this).addClass('font-selector-active');
+        }) 
+    }) 
+}
+
+export default UIWindowFontPicker

+ 100 - 0
src/UI/UIWindowGetCopyLink.js

@@ -0,0 +1,100 @@
+import UIWindow from './UIWindow.js'
+import UIPopover from './UIPopover.js'
+
+async function UIWindowGetCopyLink(options){
+    let h = '';
+    let copy_btn_text = 'Copy Link';
+    let copied_btn_text = 'Copied!';
+    const signature = await puter.fs.sign(null, {uid: options.uid, action: 'read'})
+    const url = `${gui_origin}/?name=${encodeURIComponent(options.name)}&is_dir=${encodeURIComponent(options.is_dir)}&download=${encodeURIComponent(signature.items.read_url)}`;
+
+    h += `<div>`;
+        h += `<p style="font-size: 15px; font-weight: 400; -webkit-font-smoothing: antialiased; color: #474a57;">Share the following link with anyone and they will be able to receive a copy of <strong>${html_encode(options.name)}</strong></p>`;
+        h += `<input type="text" style="margin-bottom:10px;" class="downloadable-link" readonly />`;
+        h += `<button class="button button-primary copy-downloadable-link" style="width:130px;">${copy_btn_text}</button>`
+        h += `<img class="share-copy-link-on-social" src="${window.icons['share-outline.svg']}">`;
+    h += `</div>`;
+
+    const el_window = await UIWindow({
+        title: `Get Copy Link`,
+        icon: null,
+        uid: null,
+        is_dir: false,
+        body_content: h,
+        draggable_body: false,
+        has_head: true,
+        selectable_body: false,
+        draggable_body: false,
+        allow_context_menu: false,
+        is_resizable: false,
+        is_droppable: false,
+        init_center: true,
+        allow_native_ctxmenu: true,
+        allow_user_select: true,
+        onAppend: function(el_window){
+        },
+        width: 500,
+        dominant: true,
+        window_css: {
+            height: 'initial',
+        },
+        body_css: {
+            padding: '10px',
+            width: 'initial',
+            'max-height': 'calc(100vh - 200px)',
+            'background-color': 'rgb(241 246 251)',
+            'backdrop-filter': 'blur(3px)',
+            'padding': '10px 20px 20px 20px',
+            'height': 'initial',
+        }    
+    });
+
+    $(el_window).find('.window-body .downloadable-link').val(url);
+
+    $(el_window).find('.window-body .share-copy-link-on-social').on('click', function(e){    
+        const social_links = socialLink({url: url, title: `Get a copy of '${options.name}' on Puter.com!`, description: `Get a copy of '${options.name}' on Puter.com!`});
+
+        let social_links_html = ``;
+        social_links_html += `<div style="padding: 10px;">`;
+            social_links_html += `<p style="margin: 0; text-align: center; margin-bottom: 6px; color: #484a57; font-weight: bold; font-size: 14px;">Share to</p>`
+            social_links_html += `<a class="copy-link-social-btn" target="_blank" href="${social_links.twitter}" style=""><svg viewBox="0 0 24 24" aria-hidden="true" style="opacity: 0.7;"><g><path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"></path></g></svg></a>`
+            social_links_html += `<a class="copy-link-social-btn" target="_blank" href="${social_links.whatsapp}" style=""><img src="${window.icons['logo-whatsapp.svg']}"></a>`
+            social_links_html += `<a class="copy-link-social-btn" target="_blank" href="${social_links.facebook}" style=""><img src="${window.icons['logo-facebook.svg']}"></a>`
+            social_links_html += `<a class="copy-link-social-btn" target="_blank" href="${social_links.linkedin}" style=""><img src="${window.icons['logo-linkedin.svg']}"></a>`
+            social_links_html += `<a class="copy-link-social-btn" target="_blank" href="${social_links.reddit}" style=""><img src="${window.icons['logo-reddit.svg']}"></a>`
+            social_links_html += `<a class="copy-link-social-btn" target="_blank" href="${social_links['telegram.me']}" style=""><img src="${window.icons['logo-telegram.svg']}"></a>`
+        social_links_html += '</div>';
+
+        UIPopover({
+            content: social_links_html,
+            snapToElement: this,
+            parent_element: this,
+            // width: 300,
+            height: 100,
+            position: 'bottom',
+        });    
+    })
+
+    $(el_window).find('.window-body .copy-downloadable-link').on('click', async function(e){
+        var copy_btn = this;
+        if (navigator.clipboard) {
+            // Get link text
+            const selected_text = $(el_window).find('.window-body .downloadable-link').val();
+            // copy selected text to clipboard
+            await navigator.clipboard.writeText(selected_text);
+        }
+        else{
+            // Get the text field
+            $(el_window).find('.window-body .downloadable-link').select();
+            // Copy the text inside the text field
+            document.execCommand('copy');
+        }
+
+        $(this).html(copied_btn_text);
+        setTimeout(function(){
+            $(copy_btn).html(copy_btn_text);
+        }, 1000);
+    });
+}
+
+export default UIWindowGetCopyLink

+ 226 - 0
src/UI/UIWindowItemProperties.js

@@ -0,0 +1,226 @@
+import UIWindow from './UIWindow.js'
+
+// todo do this using uid rather than item_path, since item_path is way mroe expensive on the DB
+async function UIWindowItemProperties(item_name, item_path, item_uid, left, top, width, height){
+    let h = '';
+    h += `<div class="item-props-tabview" style="display: flex; flex-direction: column; height: 100%;">`;
+        // tabs
+        h += `<div class="item-props-tab">`;
+            h += `<div class="item-props-tab-btn antialiased disable-user-select item-props-tab-selected" data-tab="general">General</div>`;
+            h += `<div class="item-props-tab-btn antialiased disable-user-select item-props-tab-btn-versions" data-tab="versions">Versions</div>`;
+        h += `</div>`;
+
+        h+= `<div class="item-props-tab-content item-props-tab-content-selected" data-tab="general" style="border-top-left-radius:0;">`;
+            h += `<table class="item-props-tbl">`;
+                h += `<tr><td class="item-prop-label">Name</td><td class="item-prop-val item-prop-val-name"></td></tr>`;
+                h += `<tr><td class="item-prop-label">Path</td><td class="item-prop-val item-prop-val-path"></td></tr>`;
+                h += `<tr class="item-prop-original-name"><td class="item-prop-label">Original Name</td><td class="item-prop-val item-prop-val-original-name"></td></tr>`;
+                h += `<tr class="item-prop-original-path"><td class="item-prop-label">Original Path</td><td class="item-prop-val item-prop-val-original-path"></td></tr>`;
+                h += `<tr><td class="item-prop-label">Shortcut to</td><td class="item-prop-val item-prop-val-shortcut-to"></td></tr>`;
+                h += `<tr><td class="item-prop-label">UID</td><td class="item-prop-val item-prop-val-uid"></td></tr>`;
+                h += `<tr><td class="item-prop-label">Type</td><td class="item-prop-val item-prop-val-type"></td></tr>`;
+                h += `<tr><td class="item-prop-label">Size</td><td class="item-prop-val item-prop-val-size"></td></tr>`;
+                h += `<tr><td class="item-prop-label">Modified</td><td class="item-prop-val item-prop-val-modified"></td></tr>`;
+                h += `<tr><td class="item-prop-label">Created</td><td class="item-prop-val item-prop-val-created"></td></tr>`;
+                h += `<tr><td class="item-prop-label">Versions</td><td class="item-prop-val item-prop-val-versions"></td></tr>`;
+                h += `<tr><td class="item-prop-label">Associated Websites</td><td class="item-prop-val item-prop-val-websites">`;
+                h += `</td></tr>`;
+                h += `<tr><td class="item-prop-label">Access Granted To</td><td class="item-prop-val item-prop-val-permissions"></td></tr>`;
+            h += `</table>`;
+        h += `</div>`;
+
+        h += `<div class="item-props-tab-content" data-tab="versions" style="padding: 20px;">`
+            h += `<div class="item-props-version-list">`;
+            h += `</div>`;
+        h += `</div>`;
+    h += `</div>`;
+
+    const el_window = await UIWindow({
+        title: `${item_name} properties`,
+        app: item_uid+'-account',
+        single_instance: true,
+        icon: null,
+        uid: null,
+        is_dir: false,
+        body_content: h,
+        draggable_body: false,
+        has_head: true,
+        selectable_body: false,
+        draggable_body: false,
+        allow_context_menu: false,
+        is_resizable: false,
+        is_droppable: false,
+        init_center: true,
+        allow_native_ctxmenu: true,
+        allow_user_select: true,
+        left: left,
+        top: top,
+        width: width,
+        height: height,
+        onAppend: function(el_window){
+        },
+        width: 450,
+        window_class: 'window-item-properties',
+        window_css:{
+            // height: 'initial',
+        },
+        body_css: {
+            padding: '10px',
+            width: 'initial',
+            height: 'calc(100% - 50px)',
+            'background-color': 'rgb(241 242 246)',
+            'backdrop-filter': 'blur(3px)',
+            'content-box': 'content-box',
+        }    
+    })
+
+    // item props tab click handler
+    $(el_window).find('.item-props-tab-btn').click(function(e){
+        // unselect all tabs
+        $(el_window).find('.item-props-tab-btn').removeClass('item-props-tab-selected');
+        // select this tab
+        $(this).addClass('item-props-tab-selected');
+        // unselect all tab contents
+        $(el_window).find('.item-props-tab-content').removeClass('item-props-tab-content-selected');
+        // select this tab content
+        $(el_window).find(`.item-props-tab-content[data-tab="${$(this).attr('data-tab')}"]`).addClass('item-props-tab-content-selected');
+    })
+
+
+    // /stat
+    puter.fs.stat({ 
+        uid: item_uid,
+        returnSubdomains: true,
+        returnPermissions: true,
+        returnVersions: true,
+        returnSize: true,
+        success: function (fsentry){
+            // hide versions tab if item is a directory
+            if(fsentry.is_dir){
+                $(el_window).find('[data-tab="versions"]').hide();
+            }
+            // name
+            $(el_window).find('.item-prop-val-name').html(fsentry.name);
+            // path
+            $(el_window).find('.item-prop-val-path').html(item_path);
+            // original name & path
+            if(fsentry.metadata){
+                try{
+                    let metadata = JSON.parse(fsentry.metadata);
+                    if(metadata.original_name){
+                        $(el_window).find('.item-prop-val-original-name').html(metadata.original_name);
+                        $(el_window).find('.item-prop-original-name').show();
+                    }
+                    if(metadata.original_path){
+                        $(el_window).find('.item-prop-val-original-path').html(metadata.original_path);
+                        $(el_window).find('.item-prop-original-path').show();
+                    }
+                }catch(e){}
+            }
+
+            // shortcut to
+            if(fsentry.shortcut_to && fsentry.shortcut_to_path){
+                $(el_window).find('.item-prop-val-shortcut-to').html(fsentry.shortcut_to_path);
+            }
+            // uid
+            $(el_window).find('.item-prop-val-uid').html(fsentry.id);
+            // type
+            $(el_window).find('.item-prop-val-type').html(fsentry.is_dir ? 'Directory' : (fsentry.type === null ? '-' : fsentry.type));
+            // size
+            $(el_window).find('.item-prop-val-size').html(fsentry.size === null || fsentry.size === undefined  ? '-' : byte_format(fsentry.size));
+            // modified
+            $(el_window).find('.item-prop-val-modified').html(fsentry.modified === 0 ? '-' : timeago.format(fsentry.modified*1000));
+            // created
+            $(el_window).find('.item-prop-val-created').html(fsentry.created === 0 ? '-' : timeago.format(fsentry.created*1000));
+            // subdomains
+            if(fsentry.subdomains && fsentry.subdomains.length > 0 ){
+                fsentry.subdomains.forEach(subdomain => {
+                    $(el_window).find('.item-prop-val-websites').append(`<p class="item-prop-website-entry" data-uuid="${subdomain.uuid}" style="margin-bottom:5px; margin-top:5px;"><a target="_blank" href="${subdomain.address}">${subdomain.address}</a> (<span class="disassociate-website-link" data-uuid="${subdomain.uuid}" data-subdomain="${extractSubdomain(subdomain.address)}">disassociate</span>)</p>`);
+                });
+            }
+            else{
+                $(el_window).find('.item-prop-val-websites').append('-');
+            }
+            // versions
+            if(fsentry.versions && fsentry.versions.length > 0 ){
+                fsentry.versions.reverse().forEach(version => {
+                    $(el_window).find('.item-props-version-list')
+                        .append(`<div class="item-prop-version-entry">${version.user? version.user.username : ''} &bull; ${timeago.format(version.timestamp*1000)}<p style="font-size:10px;">${version.id}</p></div>`);
+                });
+            }
+            else{
+                $(el_window).find('.item-props-version-list').append('-');
+            }
+
+            // owner
+            $(el_window).find('.item-prop-val-permissions').append(`<p class="item-prop-perm-entry" style="margin-bottom:5px; margin-top:5px;">${(fsentry.owner.email === undefined || fsentry.owner.email === null) ? fsentry.owner.username : fsentry.owner.email} (owner)</p>`);
+
+            // other users with access
+            if(fsentry.permissions && fsentry.permissions.length > 0 ){
+                fsentry.permissions.forEach(perm => {
+                    let h = ``;
+                    // username/email
+                    h += `<p class="item-prop-perm-entry" data-perm-uid="${perm.uid}" style="margin-bottom:5px; margin-top:5px;">${perm.email ?? perm.username} `;
+                    // remove
+                    h += `(<span class="remove-permission-link" data-perm-uid="${perm.uid}">remove</span>)`;
+                    $(el_window).find('.item-prop-val-permissions').append(h);
+                });
+            }
+            else{
+                $(el_window).find('.item-prop-val-permissions').append('-');
+            }
+
+            $(el_window).find(`.disassociate-website-link`).on('click', function(e){
+                puter.hosting.update(
+                    $(e.target).attr('data-subdomain'), 
+                    null).then(()=>{ 
+                        $(el_window).find(`.item-prop-website-entry[data-uuid="${$(e.target).attr('data-uuid')}"]`).remove();
+                        if($(el_window).find(`.item-prop-website-entry`).length === 0){
+                            $(el_window).find(`.item-prop-val-websites`).html('-');
+                            // remove the website badge from all instances of the dir
+                            $(`.item[data-uid="${item_uid}"]`).find('.item-has-website-badge').fadeOut(200);
+                        }
+                    }
+                )
+            })
+            
+            $(el_window).find('.remove-permission-link').on('click', function(e){
+                const el_remove_perm_link= this;
+                const perm_uid = $(el_remove_perm_link).attr('data-perm-uid');
+                $.ajax({
+                    url: api_origin + "/remove-perm",
+                    type: 'POST',
+                    async: true,
+                    contentType: "application/json",
+                    data: JSON.stringify({
+                        uid: perm_uid,
+                    }),
+                    headers: {
+                        "Authorization": "Bearer "+auth_token
+                    },
+                    statusCode: {
+                        401: function () {
+                            logout();
+                        },
+                    },        
+                    success: async function (res){
+                        $(el_window).find(`.item-prop-perm-entry[data-perm-uid="${perm_uid}"]`).remove();
+                        
+                        if($(el_window).find(`.item-prop-perm-entry`).length === 0){
+                            $(el_window).find(`.item-prop-val-permissions`).html('-');
+                            // todo is it better to combine the following two queriesinto one css selector?
+                            $(`.item[data-uid="${item_uid}"]`).find(`.item-is-shared`).fadeOut(200);
+                            // todo optim do this only if item is a directory
+                            // todo this has to be case-insensitive but the `i` selector doesn't work on ^=
+                            $(`.item[data-path^="${item_path}/"]`).find(`.item-is-shared`).fadeOut(200);
+                        }
+                    },
+                    complete: function(){
+                    }
+                })
+            })
+        }
+    })
+}
+
+export default UIWindowItemProperties

+ 171 - 0
src/UI/UIWindowLogin.js

@@ -0,0 +1,171 @@
+import UIWindow from './UIWindow.js'
+import UIWindowSignup from './UIWindowSignup.js'
+import UIWindowRecoverPassword from './UIWindowRecoverPassword.js'
+
+async function UIWindowLogin(options){
+    options = options ?? {};
+    options.reload_on_success = options.reload_on_success ?? false;
+    options.has_head = options.has_head ?? true;
+    options.send_confirmation_code = options.send_confirmation_code ?? false;
+
+    return new Promise(async (resolve) => {
+        const internal_id = window.uuidv4();
+        let h = ``;
+        h += `<div style="max-width: 500px; min-width: 340px;">`;
+            if(!options.has_head && options.show_close_button !== false)
+                h += `<div class="generic-close-window-button"> &times; </div>`;
+            h += `<div style="padding: 20px; border-bottom: 1px solid #ced7e1; width: 100%; box-sizing: border-box;">`;
+                // title
+                h += `<h1 class="login-form-title">Log In</h1>`;
+                // login form
+                h += `<form class="login-form">`;
+                    // error msg
+                    h += `<div class="login-error-msg"></div>`;
+                    // username/email
+                    h += `<div style="overflow: hidden;">`;
+                        h += `<label for="email_or_username-${internal_id}">Email or Username</label>`;
+                        h += `<input id="email_or_username-${internal_id}" class="email_or_username" type="text" name="email_or_username" spellcheck="false" autocorrect="off" autocapitalize="off" data-gramm_editor="false" autocomplete="username"/>`;
+                    h += `</div>`;
+                    // password
+                    h += `<div style="overflow: hidden; margin-top: 20px; margin-bottom: 20px;">`;
+                        h += `<label for="password-${internal_id}">Password</label>`;
+                        h += `<input id="password-${internal_id}" class="password" type="password" name="password" autocomplete="current-password" />`;
+                    h += `</div>`;
+                    // login
+                    h += `<button class="login-btn button button-primary button-block button-normal">Log in</button>`;
+                    // password recovery
+                    h += `<p style="text-align:center; margin-bottom: 0;"><span class="forgot-password-link">Forgot password?</span></p>`;
+                h += `</form>`;
+            h += `</div>`;
+            // create account link
+            if(options.show_signup_button === undefined || options.show_signup_button){
+                h += `<div class="c2a-wrapper" style="padding:20px;">`;
+                    h += `<button class="signup-c2a-clickable">Create Free Account</button>`;
+                h += `</div>`;
+            }
+        h += `</div>`;
+        
+        const el_window = await UIWindow({
+            title: null,
+            app: 'login',
+            single_instance: true,
+            icon: null,
+            uid: null,
+            is_dir: false,
+            body_content: h,
+            draggable_body: false,
+            has_head: true,
+            selectable_body: false,
+            draggable_body: false,
+            allow_context_menu: false,
+            is_draggable: options.is_draggable ?? true,
+            is_droppable: false,
+            is_resizable: false,
+            stay_on_top: false,
+            allow_native_ctxmenu: true,
+            allow_user_select: true,
+            ...options.window_options,
+            width: 350,
+            dominant: true,
+            on_close: ()=>{
+                resolve(false)
+            },
+            onAppend: function(this_window){
+                $(this_window).find(`.email_or_username`).get(0).focus({preventScroll:true});
+            },
+            window_class: 'window-login',
+            window_css:{
+                height: 'initial',
+            },
+            body_css: {
+                width: 'initial',
+                padding: '0',
+                'background-color': 'rgb(255 255 255)',
+                'backdrop-filter': 'blur(3px)',
+                'display': 'flex',
+                'flex-direction': 'column',
+                'justify-content': 'center',
+                'align-items': 'center',
+            }    
+        })
+
+        $(el_window).find('.forgot-password-link').on('click', function(e){
+            UIWindowRecoverPassword({
+                window_options: {
+                    backdrop: true,
+                    close_on_backdrop_click: false,
+                }
+            });
+        })
+
+        $(el_window).find('.login-btn').on('click', function(e){
+            const email_username = $(el_window).find('.email_or_username').val();
+            const password = $(el_window).find('.password').val();
+            let data;
+        
+            if(is_email(email_username)){
+                data = JSON.stringify({ 
+                    email: email_username, 
+                    password: password
+                })
+            }else{
+                data = JSON.stringify({ 
+                    username: email_username, 
+                    password: password
+                })
+            }
+        
+            $(el_window).find('.login-error-msg').hide();
+        
+            let headers = {};
+            if(window.custom_headers)
+                headers = window.custom_headers;
+    
+            $.ajax({
+                url: gui_origin + "/login",
+                type: 'POST',
+                async: false,
+                headers: headers,
+                contentType: "application/json",
+                data: data,				
+                success: function (data){
+                    update_auth_data(data.token, data.user);
+                    
+                    if(options.reload_on_success){
+                        window.onbeforeunload = null;
+                        window.location.replace('/');
+                    }else
+                        resolve(true);
+                    $(el_window).close();
+                },
+                error: function (err){
+                    $(el_window).find('.login-error-msg').html(err.responseText);
+                    $(el_window).find('.login-error-msg').fadeIn();
+                }
+            });	
+        })  
+
+        $(el_window).find('.login-form').on('submit', function(e){
+            e.preventDefault();
+            e.stopPropagation();
+            return false;
+        })
+
+        $(el_window).find('.signup-c2a-clickable').on('click', async function(e){
+            //destroy this window
+            $(el_window).close();
+            // create Signup window
+            const signup = await UIWindowSignup({
+                referrer: options.referrer,
+                show_close_button: options.show_close_button,
+                reload_on_success: options.reload_on_success,
+                window_options: options.window_options,
+                send_confirmation_code: options.send_confirmation_code,
+            });
+            if(signup)
+                resolve(true);
+        })
+    }) 
+}
+
+export default UIWindowLogin

+ 59 - 0
src/UI/UIWindowLoginInProgress.js

@@ -0,0 +1,59 @@
+import UIWindow from './UIWindow.js'
+
+async function UIWindowLoginInProgress(options){
+    return new Promise(async (resolve) => {
+        options = options ?? {};
+
+        let h = '';        
+        h += `<div class="login-progress">`;
+            h += `<h1 style="text-align: center;
+            font-size: 20px;
+            padding: 10px;
+            font-weight: 300; margin: -10px 10px 20px 10px;">Logging in as <strong>${options.user_info.email === null ? options.user_info.username : options.user_info.email}</strong></h1>`;
+            // spinner
+            h +=`<svg style="float:left; margin-right: 7px;" xmlns="http://www.w3.org/2000/svg" height="24" width="24" viewBox="0 0 24 24"><title>circle anim</title><g fill="#212121" class="nc-icon-wrapper"><g class="nc-loop-circle-24-icon-f"><path d="M12 24a12 12 0 1 1 12-12 12.013 12.013 0 0 1-12 12zm0-22a10 10 0 1 0 10 10A10.011 10.011 0 0 0 12 2z" fill="#212121" opacity=".4"></path><path d="M24 12h-2A10.011 10.011 0 0 0 12 2V0a12.013 12.013 0 0 1 12 12z" data-color="color-2"></path></g><style>.nc-loop-circle-24-icon-f{--animation-duration:0.5s;transform-origin:12px 12px;animation:nc-loop-circle-anim var(--animation-duration) infinite linear}@keyframes nc-loop-circle-anim{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}</style></g></svg>`;
+
+        h += `</div>`;
+
+        const el_window = await UIWindow({
+            title: 'Instant Login!',
+            app: 'change-passowrd',
+            single_instance: true,
+            icon: null,
+            uid: null,
+            is_dir: false,
+            body_content: h,
+            draggable_body: false,
+            has_head: false,
+            selectable_body: false,
+            draggable_body: false,
+            allow_context_menu: false,
+            is_resizable: false,
+            is_droppable: false,
+            init_center: true,
+            allow_native_ctxmenu: false,
+            allow_user_select: false,
+            width: 350,
+            height: 'auto',
+            dominant: true,
+            show_in_taskbar: false,
+            backdrop: true,
+            stay_on_top: true,
+            onAppend: function(this_window){
+            },
+            window_class: 'window-login-progress',
+            body_css: {
+                width: 'initial',
+                height: '100%',
+                'background-color': 'rgb(245 247 249)',
+                'backdrop-filter': 'blur(3px)',
+            }    
+        })
+
+        setTimeout(() => {
+            $(el_window).close();
+        }, 3000);
+    })
+}
+
+export default UIWindowLoginInProgress

+ 63 - 0
src/UI/UIWindowMoveProgress.js

@@ -0,0 +1,63 @@
+import UIWindow from './UIWindow.js'
+
+// todo do this using uid rather than item_path, since item_path is way mroe expensive on the DB
+async function UIWindowMoveProgress(options){
+    let h = '';
+    h += `<div data-move-operation-id="${options.operation_id}">`;
+        h += `<div>`;
+            // spinner
+            h +=`<svg style="float:left; margin-right: 7px;" xmlns="http://www.w3.org/2000/svg" height="24" width="24" viewBox="0 0 24 24"><title>circle anim</title><g fill="#212121" class="nc-icon-wrapper"><g class="nc-loop-circle-24-icon-f"><path d="M12 24a12 12 0 1 1 12-12 12.013 12.013 0 0 1-12 12zm0-22a10 10 0 1 0 10 10A10.011 10.011 0 0 0 12 2z" fill="#212121" opacity=".4"></path><path d="M24 12h-2A10.011 10.011 0 0 0 12 2V0a12.013 12.013 0 0 1 12 12z" data-color="color-2"></path></g><style>.nc-loop-circle-24-icon-f{--animation-duration:0.5s;transform-origin:12px 12px;animation:nc-loop-circle-anim var(--animation-duration) infinite linear}@keyframes nc-loop-circle-anim{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}</style></g></svg>`;
+            // Progress report
+            h +=`<div style="margin-bottom:20px; float:left; padding-top:3px; font-size:15px; overflow: hidden; width: calc(100% - 40px); text-overflow: ellipsis; white-space: nowrap;">`;
+                // msg
+                h += `<span class="move-progress-msg">Moving </span>`;
+                h += `<span class="move-from" style="font-weight:strong;"></span>`;
+            h += `</div>`;
+            // progress
+            h += `<div class="move-progress-bar-container" style="clear:both; margin-top:20px; border-radius:3px;">`;
+                h += `<div class="move-progress-bar"></div>`;
+            h += `</div>`;
+            // cancel
+            // h += `<button style="float:right; margin-top: 15px; margin-right: -2px;" class="button button-small move-cancel-btn">Cancel</button>`;
+        h +=`</div>`;
+    h += `</div>`;
+
+    const el_window = await UIWindow({
+        title: `moveing`,
+        icon: window.icons[`app-icon-moveing.svg`],
+        uid: null,
+        is_dir: false,
+        body_content: h,
+        draggable_body: false,
+        has_head: false,
+        selectable_body: false,
+        draggable_body: true,
+        allow_context_menu: false,
+        is_resizable: false,
+        is_droppable: false,
+        init_center: true,
+        allow_native_ctxmenu: false,
+        allow_user_select: false,
+        window_class: 'window-move-progress',
+        width: 450,
+        dominant: true,
+        window_css:{
+            height: 'initial',
+        },
+        body_css: {
+            padding: '22px',
+            width: 'initial',
+            'background-color': 'rgba(231, 238, 245, .95)',
+            'backdrop-filter': 'blur(3px)',
+        }    
+    });
+
+    $(el_window).find('.move-cancel-btn').on('click', function(e){
+        operation_cancelled[options.operation_id] = true;
+        $(el_window).close();
+    })
+
+    return el_window;
+}
+
+export default UIWindowMoveProgress

+ 178 - 0
src/UI/UIWindowMyWebsites.js

@@ -0,0 +1,178 @@
+import UIWindow from './UIWindow.js'
+import UIContextMenu from './UIContextMenu.js'
+import UIAlert from './UIAlert.js'
+
+async function UIWindowMyWebsites(options){
+    let h = '';
+    h += `<div>`;
+    h += `</div>`;
+
+    const el_window = await UIWindow({
+        title: `My Websites`,
+        app: 'my-websites',
+        single_instance: true,
+        icon: null,
+        uid: null,
+        is_dir: false,
+        body_content: h,
+        draggable_body: false,
+        has_head: true,
+        selectable_body: false,
+        draggable_body: false,
+        allow_context_menu: false,
+        is_resizable: false,
+        is_droppable: false,
+        init_center: true,
+        allow_native_ctxmenu: true,
+        allow_user_select: true,
+        width: 400,
+        dominant: true,
+        onAppend: function(el_window){
+        },
+        window_css:{
+        },
+        body_css: {
+            padding: '10px',
+            width: 'initial',
+            'background-color': 'rgba(231, 238, 245)',
+            'backdrop-filter': 'blur(3px)',
+            'padding-bottom': 0,
+            'height': '351px',
+            'box-sizing': 'border-box',
+        }    
+    });
+
+    // /sites
+    let init_ts = Date.now();
+    let loading = setTimeout(function(){
+        $(el_window).find('.window-body').html(`<p style="text-align: center;
+        margin-top: 40px;
+        margin-bottom: 50px;
+        -webkit-font-smoothing: antialiased;
+        -moz-osx-font-smoothing: grayscale;
+        color: #596c7c;">Loading...</p>`);
+    }, 1000);
+
+    puter.hosting.list().then(function (sites){
+        setTimeout(function(){
+            // clear loading
+            clearTimeout(loading);
+            // user has sites
+            if(sites.length > 0){
+                let h ='';
+                for(let i=0; i< sites.length; i++){
+                    h += `<div class="mywebsites-card" data-uuid="${sites[i].uid}">`;
+                        h += `<a class="mywebsites-address-link" href="https://${sites[i].subdomain}.puter.site" target="_blank">${sites[i].subdomain}.puter.site</a>`;
+                        h += `<img class="mywebsites-site-setting" data-site-uuid="${sites[i].uid}" src="${html_encode(window.icons['cog.svg'])}">`;
+                        // there is a directory associated with this site
+                        if(sites[i].root_dir){
+                            h += `<p class="mywebsites-dir-path" data-path="${html_encode(sites[i].root_dir.path)}" data-name="${sites[i].root_dir.name}" data-uuid="${sites[i].root_dir.id}">`;
+                                h+= `<img src="${html_encode(window.icons['folder.svg'])}">`;
+                                h+= `${sites[i].root_dir.path}`;
+                            h += `</p>`;
+                            h += `<p style="margin-bottom:0; margin-top: 20px; font-size: 13px;">`;
+                                h += `<span class="mywebsites-dis-dir" data-dir-uuid="${sites[i].root_dir.id}" data-site-uuid="${sites[i].uid}">`;
+                                h += `<img style="width: 16px; margin-bottom: -2px; margin-right: 4px;" src="${html_encode(window.icons['plug.svg'])}">Disassociate Folder</span>`;
+                            h += `</p>`;
+                        }
+                        h += `<p class="mywebsites-no-dir-notice" data-site-uuid="${sites[i].uid}" style="${sites[i].root_dir ? `display:none;` : `display:block;`}">No directory associated with this address.</p>`;
+                    h += `</div>`;
+                }
+                $(el_window).find('.window-body').html(h);
+            }
+            // has no sites
+            else{
+                $(el_window).find('.window-body').html(`<p style="text-align: center;
+                margin-top: 40px;
+                margin-bottom: 50px;
+                -webkit-font-smoothing: antialiased;
+                -moz-osx-font-smoothing: grayscale;
+                color: #596c7c;">You haven't published any websites!</p>`);
+            }
+        }, Date.now() - init_ts < 1000 ? 0 : 2000);
+    })
+}
+
+$(document).on('click', '.mywebsites-dir-path', function(e){
+    e = e.target;
+    UIWindow({
+        path: $(e).attr('data-path'),
+        title: $(e).attr('data-name'),
+        icon: window.icons['folder.svg'],
+        uid: $(e).attr('data-uuid'),
+        is_dir: true,
+        app: 'explorer',
+    });
+})
+
+$(document).on('click', '.mywebsites-site-setting', function(e){
+    const pos = e.target.getBoundingClientRect();
+    UIContextMenu({
+        parent_element: e.target,
+        position: {top: pos.top+25, left: pos.left-193},
+        items: [
+            //--------------------------------------------------
+            // Release Address
+            //--------------------------------------------------
+            {
+                html: `Release Address`,
+                onClick: async function(){
+                    const alert_resp = await UIAlert({
+                        message: `Are you sure you want to release this address?`,
+                        buttons:[
+                            {
+                                label: 'Yes, Release It',
+                                type: 'primary',
+                            },
+                            {
+                                label: 'Cancel'
+                            },
+                        ]
+                    })
+                    if(alert_resp !== 'Yes, Release It'){
+                        return;
+                    }
+                
+                    $.ajax({
+                        url: api_origin + "/delete-site",
+                        type: 'POST',
+                        data: JSON.stringify({ 
+                            site_uuid: $(e.target).attr('data-site-uuid'),
+                        }),
+                        async: false,
+                        contentType: "application/json",
+                        headers: {
+                            "Authorization": "Bearer "+auth_token
+                        },
+                        statusCode: {
+                            401: function () {
+                                logout();
+                            },
+                        },        
+                        success: function (){ 
+                            $(`.mywebsites-card[data-uuid="${$(e.target).attr('data-site-uuid')}"]`).fadeOut();
+                        }  
+                    })
+                }
+            }
+        ]
+    });
+})
+
+$(document).on('click', '.mywebsites-dis-dir', function(e){
+    puter.hosting.delete(
+        // dir
+        $(e.target).attr('data-dir-uuid'),
+        // hostname
+        $(e.target).attr('data-site-uuid'), 
+        // success
+        function (){ 
+            $(`.mywebsites-no-dir-notice[data-site-uuid="${$(e.target).attr('data-site-uuid')}"]`).show();
+            $(`.mywebsites-dir-path[data-uuid="${$(e.target).attr('data-dir-uuid')}"]`).remove();
+            // remove the website badge from all instances of the dir
+            $(`.item[data-uid="${$(e.target).attr('data-dir-uuid')}"]`).find('.item-has-website-badge').fadeOut(300);
+            $(e.target).hide();
+        }
+    )
+})
+export default UIWindowMyWebsites

+ 56 - 0
src/UI/UIWindowNewFolderProgress.js

@@ -0,0 +1,56 @@
+import UIWindow from './UIWindow.js'
+
+// todo do this using uid rather than item_path, since item_path is way mroe expensive on the DB
+async function UIWindowNewFolderProgress(options){
+    let h = '';
+    h += `<div data-newfolder-operation-id="${options.operation_id}">`;
+        h += `<div>`;
+            // spinner
+            h +=`<svg style="float:left; margin-right: 7px;" xmlns="http://www.w3.org/2000/svg" height="24" width="24" viewBox="0 0 24 24"><title>circle anim</title><g fill="#212121" class="nc-icon-wrapper"><g class="nc-loop-circle-24-icon-f"><path d="M12 24a12 12 0 1 1 12-12 12.013 12.013 0 0 1-12 12zm0-22a10 10 0 1 0 10 10A10.011 10.011 0 0 0 12 2z" fill="#212121" opacity=".4"></path><path d="M24 12h-2A10.011 10.011 0 0 0 12 2V0a12.013 12.013 0 0 1 12 12z" data-color="color-2"></path></g><style>.nc-loop-circle-24-icon-f{--animation-duration:0.5s;transform-origin:12px 12px;animation:nc-loop-circle-anim var(--animation-duration) infinite linear}@keyframes nc-loop-circle-anim{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}</style></g></svg>`;
+            // message
+            h +=`<div style="margin-bottom:20px; float:left; padding-top:3px; font-size:15px; overflow: hidden; width: calc(100% - 40px); text-overflow: ellipsis; white-space: nowrap;">`;
+                // text
+                h += `<span class="newfolder-progress-msg">Taking a little longer than usual. Please wait...</span>`;
+            h += `</div>`;
+        h +=`</div>`;
+    h += `</div>`;
+
+    const el_window = await UIWindow({
+        title: `Creating New Folder`,
+        icon: window.icons[`app-icon-newfolder.svg`],
+        uid: null,
+        is_dir: false,
+        body_content: h,
+        draggable_body: false,
+        has_head: false,
+        selectable_body: false,
+        draggable_body: true,
+        allow_context_menu: false,
+        is_resizable: false,
+        is_droppable: false,
+        init_center: true,
+        allow_native_ctxmenu: false,
+        allow_user_select: false,
+        window_class: 'window-newfolder-progress',
+        width: 450,
+        dominant: true,
+        window_css:{
+            height: 'initial',
+        },
+        body_css: {
+            padding: '22px',
+            width: 'initial',
+            'background-color': 'rgba(231, 238, 245, .95)',
+            'backdrop-filter': 'blur(3px)',
+        }    
+    });
+
+    $(el_window).find('.newfolder-cancel-btn').on('click', function(e){
+        operation_cancelled[options.operation_id] = true;
+        $(el_window).close();
+    })
+
+    return el_window;
+}
+
+export default UIWindowNewFolderProgress

+ 126 - 0
src/UI/UIWindowNewPassword.js

@@ -0,0 +1,126 @@
+import UIWindow from './UIWindow.js'
+import UIAlert from './UIAlert.js'
+import UIWindowLogin from './UIWindowLogin.js'
+
+async function UIWindowNewPassword(options){
+    return new Promise(async (resolve) => {
+        options = options ?? {};
+
+        const internal_id = window.uuidv4();
+        let h = '';
+        h += `<div class="change-password" style="padding: 20px; border-bottom: 1px solid #ced7e1;">`;
+            // error msg
+            h += `<div class="form-error-msg"></div>`;
+            // success msg
+            h += `<div class="form-success-msg"></div>`;
+            // new password
+            h += `<div style="overflow: hidden; margin-top: 20px; margin-bottom: 20px;">`;
+                h += `<label for="new-password-${internal_id}">New Password</label>`;
+                h += `<input class="new-password" id="new-password-${internal_id}" type="password" name="new-password" autocomplete="off" />`;
+            h += `</div>`;
+            // confirm new password
+            h += `<div style="overflow: hidden; margin-top: 20px; margin-bottom: 20px;">`;
+                h += `<label for="confirm-new-password-${internal_id}">Confirm New Password</label>`;
+                h += `<input class="confirm-new-password" id="confirm-new-password-${internal_id}" type="password" name="confirm-new-password" autocomplete="off" />`;
+            h += `</div>`;
+
+            // Change Password
+            h += `<button class="change-password-btn button button-primary button-block button-normal">Set New Password</button>`;
+        h += `</div>`;
+
+        const el_window = await UIWindow({
+            title: 'Set New Password',
+            app: 'change-passowrd',
+            single_instance: true,
+            icon: null,
+            uid: null,
+            is_dir: false,
+            body_content: h,
+            draggable_body: false,
+            has_head: true,
+            selectable_body: false,
+            draggable_body: false,
+            allow_context_menu: false,
+            is_resizable: false,
+            is_droppable: false,
+            init_center: true,
+            allow_native_ctxmenu: false,
+            allow_user_select: false,
+            width: 350,
+            height: 'auto',
+            dominant: true,
+            show_in_taskbar: false,
+            onAppend: function(this_window){
+                $(this_window).find(`.new-password`).get(0)?.focus({preventScroll:true});
+            },
+            window_class: 'window-publishWebsite',
+            body_css: {
+                width: 'initial',
+                height: '100%',
+                'background-color': 'rgb(245 247 249)',
+                'backdrop-filter': 'blur(3px)',
+            }    
+        })
+
+        $(el_window).find('.change-password-btn').on('click', function(e){
+            const new_password = $(el_window).find('.new-password').val();
+            const confirm_new_password = $(el_window).find('.confirm-new-password').val();
+
+            if(new_password === '' || confirm_new_password === ''){
+                $(el_window).find('.form-error-msg').html('All fields are required.');
+                $(el_window).find('.form-error-msg').fadeIn();
+                return;
+            }
+            else if(new_password !== confirm_new_password){
+                $(el_window).find('.form-error-msg').html('`New Password` and `Confirm New Password` do not match.');
+                $(el_window).find('.form-error-msg').fadeIn();
+                return;
+            }
+            
+            $(el_window).find('.form-error-msg').hide();
+        
+            $.ajax({
+                url: api_origin + "/set-pass-using-token",
+                type: 'POST',
+                async: true,
+                contentType: "application/json",
+                data: JSON.stringify({
+                    password: new_password,
+                    token: options.token,
+                    user_id: options.user,
+                }),                    
+                success: async function (data){
+                    $(el_window).close();
+                    await UIAlert({
+                        message: 'Password changed successfully.',
+                        body_icon: window.icons['c-check.svg'],
+                        stay_on_top: true,
+                        backdrop: true,
+                        buttons:[
+                            {
+                                label: 'Proceed to Login',
+                                type: 'primary',
+                            },
+                        ],
+                        window_options: {
+                            backdrop: true,
+                            close_on_backdrop_click: false,
+                        }
+                    })
+                    await UIWindowLogin({
+                        reload_on_success: true,
+                        window_options:{
+                            has_head: false
+                        }
+                    });
+                },
+                error: function (err){
+                    $(el_window).find('.form-error-msg').html(err.responseText);
+                    $(el_window).find('.form-error-msg').fadeIn();
+                }
+            });	
+        })
+    })
+}
+
+export default UIWindowNewPassword

+ 56 - 0
src/UI/UIWindowProgressEmptyTrash.js

@@ -0,0 +1,56 @@
+import UIWindow from './UIWindow.js'
+
+// todo do this using uid rather than item_path, since item_path is way mroe expensive on the DB
+async function UIWindowProgressEmptyTrash(options){
+    let h = '';
+    h += `<div data-newfolder-operation-id="${options.operation_id}">`;
+        h += `<div>`;
+            // spinner
+            h +=`<svg style="float:left; margin-right: 7px;" xmlns="http://www.w3.org/2000/svg" height="24" width="24" viewBox="0 0 24 24"><title>circle anim</title><g fill="#212121" class="nc-icon-wrapper"><g class="nc-loop-circle-24-icon-f"><path d="M12 24a12 12 0 1 1 12-12 12.013 12.013 0 0 1-12 12zm0-22a10 10 0 1 0 10 10A10.011 10.011 0 0 0 12 2z" fill="#212121" opacity=".4"></path><path d="M24 12h-2A10.011 10.011 0 0 0 12 2V0a12.013 12.013 0 0 1 12 12z" data-color="color-2"></path></g><style>.nc-loop-circle-24-icon-f{--animation-duration:0.5s;transform-origin:12px 12px;animation:nc-loop-circle-anim var(--animation-duration) infinite linear}@keyframes nc-loop-circle-anim{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}</style></g></svg>`;
+            // message
+            h +=`<div style="margin-bottom:20px; float:left; padding-top:3px; font-size:15px; overflow: hidden; width: calc(100% - 40px); text-overflow: ellipsis; white-space: nowrap;">`;
+                // text
+                h += `<span class="newfolder-progress-msg">Emptying the Trash...</span>`;
+            h += `</div>`;
+        h +=`</div>`;
+    h += `</div>`;
+
+    const el_window = await UIWindow({
+        title: `Creating New Folder`,
+        icon: window.icons[`app-icon-newfolder.svg`],
+        uid: null,
+        is_dir: false,
+        body_content: h,
+        draggable_body: false,
+        has_head: false,
+        selectable_body: false,
+        draggable_body: true,
+        allow_context_menu: false,
+        is_resizable: false,
+        is_droppable: false,
+        init_center: true,
+        allow_native_ctxmenu: false,
+        allow_user_select: false,
+        window_class: 'window-newfolder-progress',
+        width: 450,
+        dominant: true,
+        window_css:{
+            height: 'initial',
+        },
+        body_css: {
+            padding: '22px',
+            width: 'initial',
+            'background-color': 'rgba(231, 238, 245, .95)',
+            'backdrop-filter': 'blur(3px)',
+        }    
+    });
+
+    $(el_window).find('.newfolder-cancel-btn').on('click', function(e){
+        operation_cancelled[options.operation_id] = true;
+        $(el_window).close();
+    })
+
+    return el_window;
+}
+
+export default UIWindowProgressEmptyTrash

+ 116 - 0
src/UI/UIWindowPublishWebsite.js

@@ -0,0 +1,116 @@
+import UIWindow from './UIWindow.js'
+import UIWindowMyWebsites from './UIWindowMyWebsites.js'
+
+async function UIWindowPublishWebsite(target_dir_uid, target_dir_name, target_dir_path){
+    let h = '';
+    h += `<div class="window-publishWebsite-content" style="padding: 20px; border-bottom: 1px solid #ced7e1;">`;
+        // success
+        h += `<div class="window-publishWebsite-success">`;
+            h += `<img src="${html_encode(window.icons['c-check.svg'])}" style="width:80px; height:80px; display: block; margin:10px auto;">`;
+            h += `<p style="text-align:center;"><strong>${target_dir_name}</strong> has been published to:<p>`;
+            h += `<p style="text-align:center;"><a class="publishWebsite-published-link" target="_blank"></a><img class="publishWebsite-published-link-icon" src="${html_encode(window.icons['launch.svg'])}"></p>`;
+            h += `<button class="button button-normal button-block button-primary publish-window-ok-btn" style="margin-top:20px;">OK</button>`;
+        h+= `</div>`;
+        // form
+        h += `<form class="window-publishWebsite-form">`;
+            // error msg
+            h += `<div class="publish-website-error-msg"></div>`;
+            // subdomain
+            h += `<div style="overflow: hidden;">`;
+                h += `<label style="margin-bottom: 10px;">Pick a name for your website:</label>`;
+                h += `<div style="font-family: monospace;">https://<input class="publish-website-subdomain" style="width:235px;" type="text" autocomplete="subdomain" spellcheck="false" autocorrect="off" autocapitalize="off" data-gramm_editor="false"/>.${window.hosting_domain}</div>`;
+            h += `</div>`;
+            // uid
+            h += `<input class="publishWebsiteTargetDirUID" type="hidden" value="${target_dir_uid}"/>`;
+            // Publish
+            h += `<button class="publish-btn button button-action button-block button-normal">Publish</button>`
+        h += `</form>`;
+    h += `</div>`;
+
+    const el_window = await UIWindow({
+        title: 'Publish Website',
+        icon: null,
+        uid: null,
+        is_dir: false,
+        body_content: h,
+        draggable_body: false,
+        has_head: true,
+        selectable_body: false,
+        draggable_body: false,
+        allow_context_menu: false,
+        is_resizable: false,
+        is_droppable: false,
+        init_center: true,
+        allow_native_ctxmenu: true,
+        allow_user_select: true,
+        width: 450,
+        dominant: true,
+        onAppend: function(this_window){
+            $(this_window).find(`.publish-website-subdomain`).val(generate_identifier());
+            $(this_window).find(`.publish-website-subdomain`).get(0).focus({preventScroll:true});
+        },
+        window_class: 'window-publishWebsite',
+        window_css:{
+            height: 'initial'
+        },
+        body_css: {
+            width: 'initial',
+            height: '100%',
+            'background-color': 'rgb(245 247 249)',
+            'backdrop-filter': 'blur(3px)',
+        }    
+    })
+
+    $(el_window).find('.publish-btn').on('click', function(e){
+        // todo do some basic validation client-side
+
+        //Subdomain
+        let subdomain = $(el_window).find('.publish-website-subdomain').val();
+    
+        // disable 'Publish' button
+        $(el_window).find('.publish-btn').prop('disabled', true);
+
+        puter.hosting.create(
+            subdomain, 
+            target_dir_path).then((res)=>{
+                $(el_window).find('.window-publishWebsite-form').hide(100, function(){
+                    let url = 'https://' + subdomain + '.' + window.hosting_domain + '/';
+                    $(el_window).find('.publishWebsite-published-link').attr('href', url);
+                    $(el_window).find('.publishWebsite-published-link').text(url);
+                    $(el_window).find('.window-publishWebsite-success').show(100)
+                    $(`.item[data-uid="${target_dir_uid}"] .item-has-website-badge`).show();
+                });
+
+                // find all items whose path starts with target_dir_path
+                $(`.item[data-path^="${target_dir_path}"]`).each(function(){
+                    // show the link badge
+                    $(this).find('.item-has-website-url-badge').show();
+                    // update item's website_url attribute
+                    $(this).attr('data-website_url', url + $(this).attr('data-path').substring(target_dir_path.length));
+                })
+
+                update_sites_cache();
+            }).catch((err)=>{
+                $(el_window).find('.publish-website-error-msg').html(
+                    err.message + (
+                        err.code === 'subdomain_limit_reached' ? 
+                            ' <span class="manage-your-websites-link">Manage Your Subdomains</span>' : ''
+                    )
+                );
+                $(el_window).find('.publish-website-error-msg').fadeIn();
+                // re-enable 'Publish' button
+                $(el_window).find('.publish-btn').prop('disabled', false);
+            })
+    })
+
+    $(el_window).find('.publish-window-ok-btn').on('click', function(){
+        $(el_window).close();
+    })
+}
+
+$(document).on('click', '.manage-your-websites-link', async function(e){
+    UIWindowMyWebsites();
+})
+
+
+export default UIWindowPublishWebsite

+ 61 - 0
src/UI/UIWindowQR.js

@@ -0,0 +1,61 @@
+import UIWindow from './UIWindow.js'
+
+async function UIWindowQR(options){
+    return new Promise(async (resolve) => {
+        options = options ?? {};
+
+        let h = '';
+        // close button containing the multiplication sign
+        h += `<div class="qr-code-window-close-btn generic-close-window-button"> &times; </div>`;
+        h += `<div class="otp-qr-code">`;
+            h += `<h1 style="text-align: center; font-size: 16px; padding: 10px; font-weight: 400; margin: -10px 10px 20px 10px; -webkit-font-smoothing: antialiased; color: #5f626d;">Scan the code below to log into this session from other devices</h1>`;
+        h += `</div>`;
+
+        const el_window = await UIWindow({
+            title: 'Instant Login!',
+            app: 'instant-login',
+            single_instance: true,
+            icon: null,
+            uid: null,
+            is_dir: false,
+            body_content: h,
+            draggable_body: false,
+            has_head: false,
+            selectable_body: false,
+            draggable_body: false,
+            allow_context_menu: false,
+            is_resizable: false,
+            is_droppable: false,
+            init_center: true,
+            allow_native_ctxmenu: false,
+            allow_user_select: false,
+            backdrop: true,
+            width: 350,
+            height: 'auto',
+            dominant: true,
+            show_in_taskbar: false,
+            draggable_body: true,
+            onAppend: function(this_window){
+            },
+            window_class: 'window-qr',
+            body_css: {
+                width: 'initial',
+                height: '100%',
+                'background-color': 'rgb(245 247 249)',
+                'backdrop-filter': 'blur(3px)',
+            }    
+        })
+
+        // generate auth token QR code
+        new QRCode($(el_window).find('.otp-qr-code').get(0), {
+            text: window.gui_origin + '?auth_token=' + window.auth_token,
+            width: 155,
+            height: 155,
+            colorDark : "#000000",
+            colorLight : "#ffffff",
+            correctLevel : QRCode.CorrectLevel.H
+        });        
+    })
+}
+
+export default UIWindowQR

+ 110 - 0
src/UI/UIWindowRecoverPassword.js

@@ -0,0 +1,110 @@
+import UIWindow from './UIWindow.js'
+import UIAlert from './UIAlert.js'
+
+function UIWindowRecoverPassword(options){
+    return new Promise(async (resolve) => {
+        options = options ?? {};
+
+        let h = '';
+        h += `<div style="-webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; color: #3e5362;">`;
+            h += `<h3 style="text-align:center; font-weight: 400; font-size: 20px;">Recover Password</h3>`;
+            h += `<form class="pass-recovery-form">`;
+                h += `<p style="text-align:center; padding: 0 20px;"></p>`;
+                h += `<div class="error"></div>`;
+                h += `<label>Email or Username</label>`;
+                h += `<input class="pass-recovery-username-or-email" type="text"/>`;
+                h += `<button type="submit" class="send-recovery-email button button-block button-primary" style="margin-top:10px;">Send Recovery Email</button>`;
+            h += `</form>`;
+        h += `</div>`;
+
+        const el_window = await UIWindow({
+            title: null,
+            backdrop: options.backdrop ?? false,
+            icon: null,
+            uid: null,
+            is_dir: false,
+            body_content: h,
+            draggable_body: false,
+            has_head: options.has_head ?? true,
+            selectable_body: false,
+            draggable_body: true,
+            allow_context_menu: false,
+            is_draggable: options.is_draggable ?? true,
+            is_droppable: false,
+            is_resizable: false,
+            stay_on_top: options.stay_on_top ?? false,
+            allow_native_ctxmenu: true,
+            allow_user_select: true,
+            width: 350,
+            dominant: true,
+            ...options.window_options,
+            onAppend: function(el_window){
+                $(el_window).find('.pass-recovery-username-or-email').first().focus();
+            },
+            window_class: 'window-item-properties',
+            window_css:{
+                height: 'initial',
+            },
+            body_css: {
+                padding: '10px',
+                width: 'initial',
+                height: 'initial',
+                'background-color': 'rgba(231, 238, 245)',
+                'backdrop-filter': 'blur(3px)',
+            }
+        })
+        $(el_window).find('.pass-recovery-form').on('submit', function(e){
+            e.preventDefault();
+            e.stopPropagation();
+            return false;
+        })
+
+        // Send recovery email
+        $(el_window).find('.send-recovery-email').on('click', function(e){
+            let email, username;
+            let input = $(el_window).find('.pass-recovery-username-or-email').val();
+            if(is_email(input))
+                email = input;
+            else
+                username = input;
+
+            // todo validation before sending
+            $.ajax({
+                url: api_origin + "/send-pass-recovery-email",
+                type: 'POST',
+                async: true,
+                contentType: "application/json",
+                data: JSON.stringify({
+                    email: email,
+                    username: username,
+                }),    
+                statusCode: {
+                    401: function () {
+                        logout();
+                    },
+                },        
+                success: async function (res){
+                    $(el_window).close();
+                    await UIAlert({
+                        message: res.message,
+                        body_icon: window.icons['c-check.svg'],
+                        stay_on_top: true,
+                        backdrop: true,
+                        window_options: {
+                            backdrop: true,
+                            close_on_backdrop_click: false,
+                        }
+                    })           
+                },
+                error: function (err){
+                    $(el_window).find('.error').html(err.responseText);
+                    $(el_window).find('.error').fadeIn();
+                },
+                complete: function(){
+                }
+            })
+        })
+    })
+}
+
+export default UIWindowRecoverPassword

+ 102 - 0
src/UI/UIWindowRefer.js

@@ -0,0 +1,102 @@
+import UIWindow from './UIWindow.js'
+import UIPopover from './UIPopover.js'
+
+async function UIWindowRefer(options){
+    let h = '';
+    let copy_btn_text = 'Copy Link';
+    let copied_btn_text = 'Copied!';
+    const url = `${gui_origin}/?r=${user.referral_code}`;
+
+    h += `<div>`;
+        h += `<div class="qr-code-window-close-btn generic-close-window-button disable-user-select"> &times; </div>`;
+        h += `<img src="${window.icons['present.svg']}" style="width: 70px; margin: 20px auto 20px; display: block; margin-bottom: 20px;">`;
+        h += `<p style="text-align: center; font-size: 16px; padding: 20px; font-weight: 400; margin: -10px 10px 20px 10px; -webkit-font-smoothing: antialiased; color: #5f626d;">Get 1 GB for every friend who creates and confirms an account on Puter. Your friend will get 1 GB too!</p>`;
+        h += `<label style="font-weight: bold;">Invite link</label>`;
+        h += `<input type="text" style="margin-bottom:10px;" class="downloadable-link" readonly />`;
+        h += `<button class="button button-primary copy-downloadable-link" style="width:130px;">${copy_btn_text}</button>`
+        h += `<img class="share-copy-link-on-social" src="${window.icons['share-outline.svg']}">`;
+    h += `</div>`;
+
+    const el_window = await UIWindow({
+        title: `Refer a friend!`,
+        icon: null,
+        uid: null,
+        is_dir: false,
+        body_content: h,
+        has_head: false,
+        selectable_body: false,
+        draggable_body: true,
+        allow_context_menu: false,
+        is_draggable: true,
+        is_resizable: false,
+        is_droppable: false,
+        init_center: true,
+        allow_native_ctxmenu: true,
+        allow_user_select: true,
+        onAppend: function(el_window){
+        },
+        width: 500,
+        dominant: true,
+        window_css: {
+            height: 'initial',
+        },
+        body_css: {
+            padding: '10px',
+            width: 'initial',
+            'max-height': 'calc(100vh - 200px)',
+            'background-color': 'rgb(241 246 251)',
+            'backdrop-filter': 'blur(3px)',
+            'padding': '10px 20px 20px 20px',
+            'height': 'initial',
+        }    
+    });
+
+    $(el_window).find('.window-body .downloadable-link').val(url);
+
+    $(el_window).find('.window-body .share-copy-link-on-social').on('click', function(e){    
+        const social_links = socialLink({url: url, title: `Get 1 GB of free storage on Puter.com!`, description: `Get 1 GB of free storage on Puter.com!`});
+
+        let social_links_html = ``;
+        social_links_html += `<div style="padding: 10px;">`;
+            social_links_html += `<p style="margin: 0; text-align: center; margin-bottom: 6px; color: #484a57; font-weight: bold; font-size: 14px;">Share to</p>`
+            social_links_html += `<a class="copy-link-social-btn" target="_blank" href="${social_links.twitter}" style=""><svg viewBox="0 0 24 24" aria-hidden="true" style="opacity: 0.7;"><g><path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"></path></g></svg></a>`
+            social_links_html += `<a class="copy-link-social-btn" target="_blank" href="${social_links.whatsapp}" style=""><img src="${window.icons['logo-whatsapp.svg']}"></a>`
+            social_links_html += `<a class="copy-link-social-btn" target="_blank" href="${social_links.facebook}" style=""><img src="${window.icons['logo-facebook.svg']}"></a>`
+            social_links_html += `<a class="copy-link-social-btn" target="_blank" href="${social_links.linkedin}" style=""><img src="${window.icons['logo-linkedin.svg']}"></a>`
+            social_links_html += `<a class="copy-link-social-btn" target="_blank" href="${social_links.reddit}" style=""><img src="${window.icons['logo-reddit.svg']}"></a>`
+            social_links_html += `<a class="copy-link-social-btn" target="_blank" href="${social_links['telegram.me']}" style=""><img src="${window.icons['logo-telegram.svg']}"></a>`
+        social_links_html += '</div>';
+
+        UIPopover({
+            content: social_links_html,
+            snapToElement: this,
+            parent_element: this,
+            // width: 300,
+            height: 100,
+            position: 'bottom',
+        });    
+    })
+
+    $(el_window).find('.window-body .copy-downloadable-link').on('click', async function(e){
+        var copy_btn = this;
+        if (navigator.clipboard) {
+            // Get link text
+            const selected_text = $(el_window).find('.window-body .downloadable-link').val();
+            // copy selected text to clipboard
+            await navigator.clipboard.writeText(selected_text);
+        }
+        else{
+            // Get the text field
+            $(el_window).find('.window-body .downloadable-link').select();
+            // Copy the text inside the text field
+            document.execCommand('copy');
+        }
+
+        $(this).html(copied_btn_text);
+        setTimeout(function(){
+            $(copy_btn).html(copy_btn_text);
+        }, 1000);
+    });
+}
+
+export default UIWindowRefer

+ 75 - 0
src/UI/UIWindowRequestFiles.js

@@ -0,0 +1,75 @@
+import UIWindow from './UIWindow.js'
+
+async function UIWindowRequestFiles(options){
+    let h = '';
+    h += `<div>`;
+        h += `<h3 style="margin-bottom: 0;">File Request Link:</h3>`;
+        h += `<p style="word-break: break-all;" class="filereq-link"></p>`;
+    h += `</div>`;
+
+    const el_window = await UIWindow({
+        title: `Request Files`,
+        icon: null,
+        uid: null,
+        is_dir: false,
+        body_content: h,
+        draggable_body: false,
+        has_head: true,
+        selectable_body: false,
+        draggable_body: false,
+        allow_context_menu: false,
+        is_resizable: false,
+        is_droppable: false,
+        init_center: true,
+        allow_native_ctxmenu: true,
+        allow_user_select: true,
+        width: 400,
+        dominant: true,
+        onAppend: function(el_window){
+        },
+        window_class: 'window-item-properties',
+        window_css:{
+            height: 'initial',
+        },
+        body_css: {
+            padding: '10px',
+            width: 'initial',
+            'max-height': 'calc(100vh - 200px)',
+            'background-color': 'rgba(231, 238, 245)',
+            'backdrop-filter': 'blur(3px)',
+            'padding-bottom': 0,
+            'height': 'initial',
+        }    
+    });
+
+    //check if there is a fr token available
+    let stat = await puter.fs.stat(options.dir_path);
+    if(stat.file_request_url !== undefined && stat.file_request_url !== null && stat.file_request_url !== ''){
+        $(el_window).find('.filereq-link').html(stat.file_request_url);
+    }
+    // generate new fr url
+    else{
+        $.ajax({
+            url: api_origin + "/filereq",
+            type: 'POST',
+            data: JSON.stringify({ 
+                dir_path: options.dir_path
+            }),
+            async: true,
+            contentType: "application/json",
+            headers: {
+                "Authorization": "Bearer "+auth_token
+            },
+            statusCode: {
+                401: function (){
+                    logout();
+                },
+            },
+            success: function (filereq){
+                $(el_window).find('.filereq-link').html(filereq.url);
+            }
+        });         
+    }
+}
+
+export default UIWindowRequestFiles

+ 125 - 0
src/UI/UIWindowRequestPermission.js

@@ -0,0 +1,125 @@
+import UIWindow from './UIWindow.js'
+
+async function UIWindowRequestPermission(options){
+    options = options ?? {};
+    options.reload_on_success = options.reload_on_success ?? false;
+    return new Promise(async (resolve) => {
+        let drivers = [
+            {
+                name: 'puter-chat-completion',
+                human_name: 'AI Chat Completion',
+                description: 'This app wants to generate text using AI. This may incur costs on your behalf.',
+            },
+            {
+                name: 'puter-image-generation',
+                human_name: 'AI Image Generation',
+                description: 'This app wants to generate images using AI. This may incur costs on your behalf.',
+            },
+            {
+                name: 'puter-kvstore',
+                human_name: 'Puter Storage',
+                description: 'This app wants to securely store data in your Puter account. This app will not be able to access your personal data or data stored by other apps.',
+            }
+
+        ]
+
+        let parts = options.permission.split(":");
+        let driver_name = parts[1];
+        let action_name = parts[2];
+        
+        function findDriverByName(driverName) {
+            return drivers.find(driver => driver.name === driverName);
+        }
+        
+        let driver = findDriverByName(driver_name);
+
+        if(driver === undefined){
+            resolve(false);
+            return;
+        }
+
+        let h = ``;
+        h += `<div>`;
+            h += `<div style="padding: 20px; width: 100%; box-sizing: border-box;">`;
+                // title
+                h += `<h1 class="perm-title">"<span style="word-break: break-word;">${html_encode(options.app_uid ?? options.origin)}</span>" would Like to use ${html_encode(driver.human_name)}</h1>`;
+                // todo show the real description of action
+                h += `<p class="perm-description">${html_encode(driver.description)}</p>`;
+                // Allow/Don't Allow
+                h += `<button type="button" class="app-auth-allow button button-primary button-block" style="margin-top: 10px;">Allow</button>`;
+                h += `<button type="button" class="app-auth-dont-allow button button-default button-block" style="margin-top: 10px;">Don't Allow</button>`;
+            h += `</div>`;
+        h += `</div>`;
+        
+        const el_window = await UIWindow({
+            title: null,
+            app: 'request-authorization',
+            single_instance: true,
+            icon: null,
+            uid: null,
+            is_dir: false,
+            body_content: h,
+            draggable_body: false,
+            has_head: true,
+            selectable_body: false,
+            draggable_body: true,
+            allow_context_menu: false,
+            is_draggable: true,
+            is_droppable: false,
+            is_resizable: false,
+            stay_on_top: false,
+            allow_native_ctxmenu: true,
+            allow_user_select: true,
+            ...options.window_options,
+            width: 350,
+            dominant: true,
+            on_close: ()=>{
+                resolve(false)
+            },
+            onAppend: function(this_window){
+            },
+            window_class: 'window-login',
+            window_css:{
+                height: 'initial',
+            },
+            body_css: {
+                width: 'initial',
+                padding: '0',
+                'background-color': 'rgba(231, 238, 245, .95)',
+                'backdrop-filter': 'blur(3px)',
+            }
+        })
+
+        $(el_window).find('.app-auth-allow').on('click', async function(e){
+            $(this).addClass('disabled');
+
+            try{
+                const res = await fetch( window.api_origin + "/auth/grant-user-app", {
+                    "headers": {
+                    "Content-Type": "application/json",
+                    "Authorization": "Bearer " + window.auth_token,
+                    },
+                    "body": JSON.stringify({
+                        app_uid: options.app_uid,
+                        origin: options.origin,
+                        permission: options.permission 
+                    }),
+                    "method": "POST",
+                });
+            }catch(err){
+                console.error(err);
+                resolve(err);
+            }
+
+            resolve(true);
+        })  
+
+        $(el_window).find('.app-auth-dont-allow').on('click', function(e){
+            $(this).addClass('disabled');
+            $(el_window).close();
+            resolve(false);
+        })
+    }) 
+}
+
+export default UIWindowRequestPermission

+ 167 - 0
src/UI/UIWindowSaveAccount.js

@@ -0,0 +1,167 @@
+import UIWindow from './UIWindow.js'
+import UIWindowEmailConfirmationRequired from './UIWindowEmailConfirmationRequired.js'
+
+async function UIWindowSaveAccount(options){
+    const internal_id = window.uuidv4();
+    options = options ?? {};
+    options.reload_on_success = options.reload_on_success ?? false;
+    options.send_confirmation_code = options.send_confirmation_code ?? false;
+
+    return new Promise(async (resolve) => {
+        let h = '';
+        h += `<div>`;
+            // success
+            h += `<div class="save-account-success">`;
+                h += `<img src="${html_encode(window.icons['c-check.svg'])}" style="width:50px; height:50px; display: block; margin:10px auto;">`;
+                h += `<p style="text-align:center; margin-bottom:10px;">Thank you for creating an account. This session has been saved.</p>`;
+                h += `<button class="button button-action button-block save-account-success-ok-btn">OK</button>`
+            h+= `</div>`;
+    
+            // form
+            h += `<div class="save-account-form" style="padding: 20px; border-bottom: 1px solid #ced7e1; width: 100%; box-sizing: border-box;">`;
+                // title
+                h += `<h1 class="signup-form-title" style="margin-bottom:0;">Create Account</h1>`;
+                // description
+                h += `<p class="create-account-desc">${options.message ?? 'Create an account to save your current session and avoid losing your work.'}</p>`;
+                // signup form
+                h += `<form class="signup-form">`;
+                    // error msg
+                    h += `<div class="signup-error-msg"></div>`;
+                    // username
+                    h += `<div style="overflow: hidden;">`;
+                        h += `<label for="username-${internal_id}">Username</label>`;
+                        h += `<input id="username-${internal_id}" class="username" value="${options.default_username ?? ''}" type="text" autocomplete="username" spellcheck="false" autocorrect="off" autocapitalize="off" data-gramm_editor="false"/>`;
+                    h += `</div>`;
+                    // email
+                    h += `<div style="overflow: hidden; margin-top: 20px;">`;
+                        h += `<label for="email-${internal_id}">Email</label>`;
+                        h += `<input id="email-${internal_id}" class="email" type="email" autocomplete="email" spellcheck="false" autocorrect="off" autocapitalize="off" data-gramm_editor="false"/>`;
+                    h += `</div>`;
+                    // password
+                    h += `<div style="overflow: hidden; margin-top: 20px; margin-bottom: 20px;">`;
+                        h += `<label for="password-${internal_id}">Password</label>`;
+                        h += `<input id="password-${internal_id}" class="password" type="password" name="password" autocomplete="new-password" />`;
+                    h += `</div>`;
+                    // bot trap - if this value is submitted server will ignore the request
+                    h += `<input type="text" name="p102xyzname" class="p102xyzname" value="">`;
+                    // Create Account
+                    h += `<button class="signup-btn button button-primary button-block button-normal">Create Account</button>`
+                h += `</form>`;
+            h += `</div>`;
+        h += `</div>`;
+
+        const el_window = await UIWindow({
+            title: null,
+            icon: null,
+            uid: null,
+            app: 'save-account',
+            single_instance: true,
+            is_dir: false,
+            body_content: h,
+            has_head: true,
+            selectable_body: false,
+            draggable_body: true,
+            allow_context_menu: false,
+            is_draggable: true,
+            is_droppable: false,
+            is_resizable: false,
+            stay_on_top: false,
+            allow_native_ctxmenu: true,
+            allow_user_select: true,
+            width: 350,
+            dominant: true,
+            show_in_taskbar: false,
+            ...options.window_options,
+            onAppend: function(this_window){
+                if(options.default_username)
+                    $(this_window).find('.email').get(0).focus({preventScroll:true});
+                else
+                    $(this_window).find('.username').get(0).focus({preventScroll:true});
+            },
+            window_class: 'window-save-account',
+            window_css:{
+                height: 'initial',
+            },
+            on_close: ()=>{
+                resolve(false)
+            },
+            body_css: {
+                width: 'initial',
+                'background-color': 'rgba(231, 238, 245, .95)',
+                'backdrop-filter': 'blur(3px)',
+            }    
+        })
+
+        $(el_window).find('.signup-btn').on('click', function(e){
+            // todo do some basic validation client-side
+
+            //Username
+            let username = $(el_window).find('.username').val();
+        
+            //Email
+            let email = $(el_window).find('.email').val();
+        
+            //Password
+            let password = $(el_window).find('.password').val();
+            
+            // disable 'Create Account' button
+            $(el_window).find('.signup-btn').prop('disabled', true);
+
+            $.ajax({
+                url: api_origin + "/save_account",
+                type: 'POST',
+                async: true,
+                contentType: "application/json",
+                data: JSON.stringify({ 
+                    username: username, 
+                    email: email, 
+                    password: password,
+                    referrer: options.referrer,
+                    send_confirmation_code: options.send_confirmation_code,
+                }),
+                headers: {
+                    "Authorization": "Bearer "+auth_token
+                },        
+                success: async function (data){                    
+                    update_auth_data(data.token, data.user)
+
+                    //close this window
+                    if(data.user.email_confirmation_required){
+                        let is_verified = await UIWindowEmailConfirmationRequired({
+                            stay_on_top: true, 
+                            has_head: true
+                        });
+                        resolve(is_verified);
+                    }else{
+                        resolve(true);
+                    }
+
+                    $(el_window).find('.save-account-form').hide(100, ()=>{
+                        $(el_window).find('.save-account-success').show(100);
+                    })
+                },
+                error: function (err){
+                    $(el_window).find('.signup-error-msg').html(err.responseText);
+                    $(el_window).find('.signup-error-msg').fadeIn();
+                    // re-enable 'Create Account' button
+                    $(el_window).find('.signup-btn').prop('disabled', false);
+                }
+            });
+        })
+
+        $(el_window).find('.signup-form').on('submit', function(e){
+            e.preventDefault();
+            e.stopPropagation();
+            return false;
+        })
+            
+        $(el_window).find('.save-account-success-ok-btn').on('click', ()=>{
+            $(el_window).close();
+        })
+
+        //remove login window
+        $(el_window).find('.signup-c2a-clickable').parents('.window').close();
+    })
+}
+
+export default UIWindowSaveAccount

File diff suppressed because it is too large
+ 24 - 0
src/UI/UIWindowSelfhostedWaitlist.js


+ 138 - 0
src/UI/UIWindowSessionList.js

@@ -0,0 +1,138 @@
+import UIWindow from './UIWindow.js'
+import UIWindowLogin from './UIWindowLogin.js'
+import UIWindowSignup from './UIWindowSignup.js'
+
+async function UIWindowSessionList(options){
+    options = options ?? {};
+    options.reload_on_success = options.reload_on_success ?? true;
+
+    return new Promise(async (resolve) => {
+        let h = '';
+        h += `<div style="margin:10px;">`;
+            h += `<div class="loading">Signing in...</div>`
+            h += `<div style="overflow-y: scroll; max-width: 400px; margin: 0 auto;">`;
+            h += `<h1 style="text-align: center; font-size: 18px; font-weight: normal; color: #757575;"><img src="${icons['logo-white.svg']}" style="padding: 4px; background-color: blue; border-radius: 5px; width: 25px; box-sizing: border-box; margin-bottom: -6px; margin-right: 6px;">Sign in with Puter</h1>`
+            for (let index = 0; index < logged_in_users.length; index++) {
+                const l_user = logged_in_users[index];
+                h += `<div data-uuid="${l_user.uuid}" class="session-entry">${l_user.username}</div>`;
+            }
+            h += `</div>`;
+
+            h += `<div style="margin-top: 20px; margin-bottom: 20px; text-align:center;"><span class="login-c2a-session-list">Log Into Another Account</span> &bull; <span class="signup-c2a-session-list">Create Account</span></div>`;
+        h += `</div>`;
+
+        const el_window = await UIWindow({
+            title: 'Session List!',
+            app: 'session-list',
+            single_instance: true,
+            icon: null,
+            uid: null,
+            is_dir: false,
+            body_content: h,
+            has_head: false,
+            selectable_body: false,
+            draggable_body: options.draggable_body ?? true,
+            allow_context_menu: false,
+            is_resizable: false,
+            is_droppable: false,
+            init_center: true,
+            allow_native_ctxmenu: false,
+            allow_user_select: false,
+            width: 350,
+            height: 'auto',
+            dominant: true,
+            show_in_taskbar: false,
+            update_window_url: false,
+            cover_page: options.cover_page ?? false,
+            onAppend: function(this_window){
+            },
+            window_class: 'window-session-list',
+            body_css: {
+                width: 'initial',
+                height: '100%',
+                'background-color': 'rgb(245 247 249)',
+                'backdrop-filter': 'blur(3px)',
+                'display': 'flex',
+                'flex-direction': 'column',
+                'justify-content': 'center',
+            }    
+        })
+        $(el_window).find('.login-c2a-session-list').on('click', async function(e){
+            const login = await UIWindowLogin({
+                referrer: options.referrer, 
+                reload_on_success: options.reload_on_success,
+                window_options: options.window_options,
+                cover_page: options.cover_page ?? false,
+                has_head: options.has_head,
+                send_confirmation_code: options.send_confirmation_code,
+                window_options: {
+                    has_head: false,
+                    cover_page: options.cover_page ?? false,
+                }
+            });
+            if(login){
+                if(options.reload_on_success){
+                    // disable native browser exit confirmation
+                    window.onbeforeunload = null;            
+                    // refresh
+                    location.reload();
+                }else{
+                    resolve(login);
+                }
+            }
+        })
+        $(el_window).find('.signup-c2a-session-list').on('click', async function(e){
+            $('.signup-c2a-clickable').parents('.window').close();
+            // create Signup window
+            const signup = await UIWindowSignup({
+                referrer: options.referrer,
+                reload_on_success: options.reload_on_success,
+                window_options: options.window_options,
+                send_confirmation_code: options.send_confirmation_code,
+                window_options: {
+                    has_head: false,
+                    cover_page: options.cover_page ?? false,
+                }
+
+            });
+            if(signup){
+                if(options.reload_on_success){
+                    // disable native browser exit confirmation
+                    window.onbeforeunload = null;            
+                    // refresh
+                    location.reload();
+                }else{
+                    resolve(signup);
+                }
+            }
+        })
+
+        $(el_window).find('.session-entry').on('click', function(e){
+            $(el_window).find('.loading').css({display: 'flex'});
+
+            setTimeout(() => {
+                let selected_uuid = $(this).attr('data-uuid');
+                let selected_user;
+                for (let index = 0; index < window.logged_in_users.length; index++) {
+                    const l_user = logged_in_users[index];
+                    if(l_user.uuid === selected_uuid){
+                        selected_user = l_user;
+                    }
+                }
+
+                // new logged in user
+                update_auth_data(selected_user.auth_token, selected_user);
+                if(options.reload_on_success){
+                    // disable native browser exit confirmation
+                    window.onbeforeunload = null;            
+                    // refresh
+                    location.reload();
+                }else{
+                    resolve(true);
+                }
+            }, 500);
+        })
+    })
+}
+
+export default UIWindowSessionList

+ 186 - 0
src/UI/UIWindowSignup.js

@@ -0,0 +1,186 @@
+import UIWindow from './UIWindow.js'
+import UIWindowLogin from './UIWindowLogin.js'
+import UIWindowEmailConfirmationRequired from './UIWindowEmailConfirmationRequired.js'
+
+function UIWindowSignup(options){
+    options = options ?? {};
+    options.reload_on_success = options.reload_on_success ?? false;
+    options.has_head = options.has_head ?? true;
+    options.send_confirmation_code  = options.send_confirmation_code ?? false;
+
+    return new Promise(async (resolve) => {
+        const internal_id = window.uuidv4();
+        let h = '';
+        h += `<div style="margin: 0 auto; max-width: 500px; min-width: 400px;">`;
+            // logo
+            h += `<img src="${window.icons['logo-white.svg']}" style="width: 40px; height: 40px; margin: 0 auto; display: block; padding: 15px; background-color: blue; border-radius: 5px;">`;
+            // close button
+            if(!options.has_head && options.show_close_button !== false)
+                h += `<div class="generic-close-window-button"> &times; </div>`;
+
+            // Form
+            h += `<div style="padding: 20px; border-bottom: 1px solid #ced7e1;">`;
+                // title
+                h += `<h1 class="signup-form-title">Create Free Account</h1>`;
+                // signup form
+                h += `<form class="signup-form">`;
+                    // error msg
+                    h += `<div class="signup-error-msg"></div>`;
+                    // username
+                    h += `<div style="overflow: hidden;">`;
+                        h += `<label for="username-${internal_id}">Username</label>`;
+                        h += `<input id="username-${internal_id}" class="username" type="text" autocomplete="username" spellcheck="false" autocorrect="off" autocapitalize="off" data-gramm_editor="false"/>`;
+                    h += `</div>`;
+                    // email
+                    h += `<div style="overflow: hidden; margin-top: 20px;">`;
+                        h += `<label for="email-${internal_id}">Email</label>`;
+                        h += `<input id="email-${internal_id}" class="email" type="email" autocomplete="email" spellcheck="false" autocorrect="off" autocapitalize="off" data-gramm_editor="false"/>`;
+                    h += `</div>`;
+                    // password
+                    h += `<div style="overflow: hidden; margin-top: 20px; margin-bottom: 20px;">`;
+                        h += `<label for="password-${internal_id}">Password</label>`;
+                        h += `<input id="password-${internal_id}" class="password" type="password" name="password" autocomplete="new-password" />`;
+                    h += `</div>`;
+                    // bot trap - if this value is submitted server will ignore the request
+                    h += `<input type="text" name="p102xyzname" class="p102xyzname" value="">`;
+
+                    // terms and privacy
+                    h += `<p class="signup-terms">By clicking 'Create Free Account' you agree to Puter's <a href="https://puter.com/terms" target="_blank">Terms of Service</a> and <a href="https://puter.com/privacy" target="_blank">Privacy Policy</a>.</p>`;
+                    // Create Account
+                    h += `<button class="signup-btn button button-primary button-block button-normal">Create Free Account</button>`
+                h += `</form>`;
+            h += `</div>`;
+            // login link
+            // create account link
+            h += `<div class="c2a-wrapper" style="padding:20px;">`;
+                h += `<button class="login-c2a-clickable">Log In</button>`;
+            h += `</div>`;
+        h += `</div>`;
+
+        const el_window = await UIWindow({
+            title: null,
+            app: 'signup',
+            single_instance: true,
+            icon: null,
+            uid: null,
+            is_dir: false,
+            body_content: h,
+            draggable_body: false,
+            has_head: true,
+            selectable_body: false,
+            allow_context_menu: false,
+            is_draggable: false,
+            is_droppable: false,
+            is_resizable: false,
+            stay_on_top: false,
+            allow_native_ctxmenu: true,
+            allow_user_select: true,
+            ...options.window_options,
+            // width: 350,
+            dominant: false,
+            center: true,
+            onAppend: function(el_window){
+                $(el_window).find(`.username`).get(0).focus({preventScroll:true});
+            },
+            window_class: 'window-signup',
+            window_css:{
+                height: 'initial',
+            }, 
+            body_css: {
+                width: 'initial',
+                'background-color': 'white',
+                'backdrop-filter': 'blur(3px)',
+                'display': 'flex',
+                'flex-direction': 'column',
+                'justify-content': 'center',
+                'align-items': 'center',
+                padding: '30px 10px 10px 10px',
+            }    
+        })
+
+        $(el_window).find('.login-c2a-clickable').on('click', async function(e){
+            $('.login-c2a-clickable').parents('.window').close();
+            const login = await UIWindowLogin({
+                referrer: options.referrer, 
+                reload_on_success: options.reload_on_success,
+                window_options: options.window_options,
+                show_close_button: options.show_close_button,
+                send_confirmation_code: options.send_confirmation_code,
+            });
+            if(login)
+                resolve(true);
+        })
+
+        $(el_window).find('.signup-btn').on('click', function(e){
+            // todo do some basic validation client-side
+
+            //Username
+            let username = $(el_window).find('.username').val();
+        
+            //Email
+            let email = $(el_window).find('.email').val();
+        
+            //Password
+            let password = $(el_window).find('.password').val();
+            
+            //xyzname
+            let p102xyzname = $(el_window).find('.p102xyzname').val();
+
+            // disable 'Create Account' button
+            $(el_window).find('.signup-btn').prop('disabled', true);
+
+            let headers = {};
+            if(window.custom_headers)
+                headers = window.custom_headers;
+
+            $.ajax({
+                url: gui_origin + "/signup",
+                type: 'POST',
+                async: true,
+                headers: headers,
+                contentType: "application/json",
+                data: JSON.stringify({ 
+                    username: username,
+                    referral_code: window.referral_code,
+                    email: email, 
+                    password: password,
+                    referrer: options.referrer ?? window.referrerStr,
+                    send_confirmation_code: options.send_confirmation_code,
+                    p102xyzname: p102xyzname,
+                }),
+                success: async function (data){
+                    update_auth_data(data.token, data.user)
+                    
+                    //send out the login event
+                    if(options.reload_on_success){
+                        window.onbeforeunload = null;
+                        window.location.replace('/');
+                    }else if(options.send_confirmation_code){
+                        $(el_window).close();
+                        let is_verified = await UIWindowEmailConfirmationRequired({stay_on_top: true, has_head: true});
+                        resolve(is_verified);
+                    }else{
+                        resolve(true);
+                    }
+                },
+                error: function (err){
+                    $(el_window).find('.signup-error-msg').html(err.responseText);
+                    $(el_window).find('.signup-error-msg').fadeIn();
+                    // re-enable 'Create Account' button
+                    $(el_window).find('.signup-btn').prop('disabled', false);
+                }
+            });
+        })
+
+        $(el_window).find('.signup-form').on('submit', function(e){
+            e.preventDefault();
+            e.stopPropagation();
+            return false;
+        })
+            
+        //remove login window
+        $('.signup-c2a-clickable').parents('.window').close();
+    })
+}
+
+export default UIWindowSignup

+ 57 - 0
src/UI/UIWindowUploadProgress.js

@@ -0,0 +1,57 @@
+import UIWindow from './UIWindow.js'
+
+// todo do this using uid rather than item_path, since item_path is way mroe expensive on the DB
+async function UIWindowUploadProgress(options){
+    let h = '';
+    h += `<div data-upload-operation-id="${options.operation_id}">`;
+        h += `<div>`;
+            // spinner
+            h +=`<svg style="float:left; margin-right: 7px;" xmlns="http://www.w3.org/2000/svg" height="24" width="24" viewBox="0 0 24 24"><title>circle anim</title><g fill="#212121" class="nc-icon-wrapper"><g class="nc-loop-circle-24-icon-f"><path d="M12 24a12 12 0 1 1 12-12 12.013 12.013 0 0 1-12 12zm0-22a10 10 0 1 0 10 10A10.011 10.011 0 0 0 12 2z" fill="#212121" opacity=".4"></path><path d="M24 12h-2A10.011 10.011 0 0 0 12 2V0a12.013 12.013 0 0 1 12 12z" data-color="color-2"></path></g><style>.nc-loop-circle-24-icon-f{--animation-duration:0.5s;transform-origin:12px 12px;animation:nc-loop-circle-anim var(--animation-duration) infinite linear}@keyframes nc-loop-circle-anim{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}</style></g></svg>`;
+            // Progress report
+            h +=`<div style="margin-bottom:20px; float:left; padding-top:3px; font-size:15px; overflow: hidden; width: calc(100% - 40px); text-overflow: ellipsis; white-space: nowrap;">`;
+                // msg
+                h += `<span class="upload-progress-msg">Preparing for upload...</span>`;
+            h += `</div>`;
+            // progress
+            h += `<div class="upload-progress-bar-container" style="clear:both; margin-top:20px; border-radius:3px;">`;
+                h += `<div class="upload-progress-bar"></div>`;
+            h += `</div>`;
+            // cancel
+            h += `<button style="float:right; margin-top: 15px; margin-right: -2px;" class="button button-small upload-cancel-btn">Cancel</button>`;
+        h +=`</div>`;
+    h += `</div>`;
+
+    const el_window = await UIWindow({
+        title: `Upload`,
+        icon: window.icons[`app-icon-uploader.svg`],
+        uid: null,
+        is_dir: false,
+        body_content: h,
+        draggable_body: false,
+        has_head: false,
+        selectable_body: false,
+        draggable_body: true,
+        allow_context_menu: false,
+        is_resizable: false,
+        is_droppable: false,
+        init_center: true,
+        allow_native_ctxmenu: false,
+        allow_user_select: false,
+        window_class: 'window-upload-progress',
+        width: 450,
+        dominant: true,
+        window_css:{
+            height: 'initial',
+        },
+        body_css: {
+            padding: '22px',
+            width: 'initial',
+            'background-color': 'rgba(231, 238, 245, .95)',
+            'backdrop-filter': 'blur(3px)',
+        }    
+    });
+
+    return el_window;
+}
+
+export default UIWindowUploadProgress

+ 8 - 0
src/browserconfig.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<browserconfig>
+<msapplication>
+<tile>
+<square70x70logo src="./favicons/ms-icon-70x70.png"/>
+<square150x150logo src="./favicons/ms-icon-150x150.png"/>
+<square310x310logo src="./favicons/ms-icon-310x310.png"/>
+<TileColor>#ffffff</TileColor></tile></msapplication></browserconfig>

+ 349 - 0
src/css/normalize.css

@@ -0,0 +1,349 @@
+/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */
+
+/* Document
+   ========================================================================== */
+
+/**
+ * 1. Correct the line height in all browsers.
+ * 2. Prevent adjustments of font size after orientation changes in iOS.
+ */
+
+html {
+  line-height: 1.15; /* 1 */
+  -webkit-text-size-adjust: 100%; /* 2 */
+}
+
+/* Sections
+   ========================================================================== */
+
+/**
+ * Remove the margin in all browsers.
+ */
+
+body {
+  margin: 0;
+}
+
+/**
+ * Render the `main` element consistently in IE.
+ */
+
+main {
+  display: block;
+}
+
+/**
+ * Correct the font size and margin on `h1` elements within `section` and
+ * `article` contexts in Chrome, Firefox, and Safari.
+ */
+
+h1 {
+  font-size: 2em;
+  margin: 0.67em 0;
+}
+
+/* Grouping content
+   ========================================================================== */
+
+/**
+ * 1. Add the correct box sizing in Firefox.
+ * 2. Show the overflow in Edge and IE.
+ */
+
+hr {
+  box-sizing: content-box; /* 1 */
+  height: 0; /* 1 */
+  overflow: visible; /* 2 */
+}
+
+/**
+ * 1. Correct the inheritance and scaling of font size in all browsers.
+ * 2. Correct the odd `em` font sizing in all browsers.
+ */
+
+pre {
+  font-family: monospace, monospace; /* 1 */
+  font-size: 1em; /* 2 */
+}
+
+/* Text-level semantics
+   ========================================================================== */
+
+/**
+ * Remove the gray background on active links in IE 10.
+ */
+
+a {
+  background-color: transparent;
+}
+
+/**
+ * 1. Remove the bottom border in Chrome 57-
+ * 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.
+ */
+
+abbr[title] {
+  border-bottom: none; /* 1 */
+  text-decoration: underline; /* 2 */
+  text-decoration: underline dotted; /* 2 */
+}
+
+/**
+ * Add the correct font weight in Chrome, Edge, and Safari.
+ */
+
+b,
+strong {
+  font-weight: bolder;
+}
+
+/**
+ * 1. Correct the inheritance and scaling of font size in all browsers.
+ * 2. Correct the odd `em` font sizing in all browsers.
+ */
+
+code,
+kbd,
+samp {
+  font-family: monospace, monospace; /* 1 */
+  font-size: 1em; /* 2 */
+}
+
+/**
+ * Add the correct font size in all browsers.
+ */
+
+small {
+  font-size: 80%;
+}
+
+/**
+ * Prevent `sub` and `sup` elements from affecting the line height in
+ * all browsers.
+ */
+
+sub,
+sup {
+  font-size: 75%;
+  line-height: 0;
+  position: relative;
+  vertical-align: baseline;
+}
+
+sub {
+  bottom: -0.25em;
+}
+
+sup {
+  top: -0.5em;
+}
+
+/* Embedded content
+   ========================================================================== */
+
+/**
+ * Remove the border on images inside links in IE 10.
+ */
+
+img {
+  border-style: none;
+}
+
+/* Forms
+   ========================================================================== */
+
+/**
+ * 1. Change the font styles in all browsers.
+ * 2. Remove the margin in Firefox and Safari.
+ */
+
+button,
+input,
+optgroup,
+select,
+textarea {
+  font-family: inherit; /* 1 */
+  font-size: 100%; /* 1 */
+  line-height: 1.15; /* 1 */
+  margin: 0; /* 2 */
+}
+
+/**
+ * Show the overflow in IE.
+ * 1. Show the overflow in Edge.
+ */
+
+button,
+input { /* 1 */
+  overflow: visible;
+}
+
+/**
+ * Remove the inheritance of text transform in Edge, Firefox, and IE.
+ * 1. Remove the inheritance of text transform in Firefox.
+ */
+
+button,
+select { /* 1 */
+  text-transform: none;
+}
+
+/**
+ * Correct the inability to style clickable types in iOS and Safari.
+ */
+
+button,
+[type="button"],
+[type="reset"],
+[type="submit"] {
+  -webkit-appearance: button;
+}
+
+/**
+ * Remove the inner border and padding in Firefox.
+ */
+
+button::-moz-focus-inner,
+[type="button"]::-moz-focus-inner,
+[type="reset"]::-moz-focus-inner,
+[type="submit"]::-moz-focus-inner {
+  border-style: none;
+  padding: 0;
+}
+
+/**
+ * Restore the focus styles unset by the previous rule.
+ */
+
+button:-moz-focusring,
+[type="button"]:-moz-focusring,
+[type="reset"]:-moz-focusring,
+[type="submit"]:-moz-focusring {
+  outline: 1px dotted ButtonText;
+}
+
+/**
+ * Correct the padding in Firefox.
+ */
+
+fieldset {
+  padding: 0.35em 0.75em 0.625em;
+}
+
+/**
+ * 1. Correct the text wrapping in Edge and IE.
+ * 2. Correct the color inheritance from `fieldset` elements in IE.
+ * 3. Remove the padding so developers are not caught out when they zero out
+ *    `fieldset` elements in all browsers.
+ */
+
+legend {
+  box-sizing: border-box; /* 1 */
+  color: inherit; /* 2 */
+  display: table; /* 1 */
+  max-width: 100%; /* 1 */
+  padding: 0; /* 3 */
+  white-space: normal; /* 1 */
+}
+
+/**
+ * Add the correct vertical alignment in Chrome, Firefox, and Opera.
+ */
+
+progress {
+  vertical-align: baseline;
+}
+
+/**
+ * Remove the default vertical scrollbar in IE 10+.
+ */
+
+textarea {
+  overflow: auto;
+}
+
+/**
+ * 1. Add the correct box sizing in IE 10.
+ * 2. Remove the padding in IE 10.
+ */
+
+[type="checkbox"],
+[type="radio"] {
+  box-sizing: border-box; /* 1 */
+  padding: 0; /* 2 */
+}
+
+/**
+ * Correct the cursor style of increment and decrement buttons in Chrome.
+ */
+
+[type="number"]::-webkit-inner-spin-button,
+[type="number"]::-webkit-outer-spin-button {
+  height: auto;
+}
+
+/**
+ * 1. Correct the odd appearance in Chrome and Safari.
+ * 2. Correct the outline style in Safari.
+ */
+
+[type="search"] {
+  -webkit-appearance: textfield; /* 1 */
+  outline-offset: -2px; /* 2 */
+}
+
+/**
+ * Remove the inner padding in Chrome and Safari on macOS.
+ */
+
+[type="search"]::-webkit-search-decoration {
+  -webkit-appearance: none;
+}
+
+/**
+ * 1. Correct the inability to style clickable types in iOS and Safari.
+ * 2. Change font properties to `inherit` in Safari.
+ */
+
+::-webkit-file-upload-button {
+  -webkit-appearance: button; /* 1 */
+  font: inherit; /* 2 */
+}
+
+/* Interactive
+   ========================================================================== */
+
+/*
+ * Add the correct display in Edge, IE 10+, and Firefox.
+ */
+
+details {
+  display: block;
+}
+
+/*
+ * Add the correct display in all browsers.
+ */
+
+summary {
+  display: list-item;
+}
+
+/* Misc
+   ========================================================================== */
+
+/**
+ * Add the correct display in IE 10+.
+ */
+
+template {
+  display: none;
+}
+
+/**
+ * Add the correct display in IE 10.
+ */
+
+[hidden] {
+  display: none;
+}

File diff suppressed because it is too large
+ 2936 - 0
src/css/style.css


BIN
src/favicon.ico


BIN
src/favicons/android-icon-144x144.png


BIN
src/favicons/android-icon-192x192.png


BIN
src/favicons/android-icon-36x36.png


BIN
src/favicons/android-icon-48x48.png


BIN
src/favicons/android-icon-72x72.png


BIN
src/favicons/android-icon-96x96.png


BIN
src/favicons/apple-icon-114x114.png


BIN
src/favicons/apple-icon-120x120.png


Some files were not shown because too many files changed in this diff