--- /dev/null
+ 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/>.
+
--- /dev/null
+# Pnut connector
+
+With this addon to friendica you can give your users the possibility to post their *public* messages to pnut.io.
+
+No setup is needed for the admins to make it work for their users.
--- /dev/null
+Copyright (c) 2013, Josh Dolitsky
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of the Josh Dolitsky nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL TRAVIS RICHARDSON BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
--- /dev/null
+<?php
+
+namespace phpnut;
+
+/**
+ * phpnut.php
+ * pnut.io PHP library
+ * https://github.com/pnut-api/phpnut
+ *
+ * This class handles a lower level type of access to pnut.io. It's ideal
+ * for command line scripts and other places where you want full control
+ * over what's happening, and you're at least a little familiar with oAuth.
+ *
+ * Alternatively you can use the EZphpnut class which automatically takes
+ * care of a lot of the details like logging in, keeping track of tokens,
+ * etc. EZphpnut assumes you're accessing pnut.io via a browser, whereas
+ * this class tries to make no assumptions at all.
+ */
+class phpnut
+{
+ protected $_baseUrl = 'https://api.pnut.io/v1/';
+ protected $_authUrl = 'https://pnut.io/oauth/';
+
+ private $_authPostParams = [];
+
+ // stores the access token after login
+ private $_accessToken = null;
+
+ // stores the App access token if we have it
+ private $_appAccessToken = null;
+
+ // stores the user ID returned when fetching the auth token
+ private $_user_id = null;
+
+ // stores the username returned when fetching the auth token
+ private $_username = null;
+
+ // The total number of requests you're allowed within the alloted time period
+ private $_rateLimit = null;
+
+ // The number of requests you have remaining within the alloted time period
+ private $_rateLimitRemaining = null;
+
+ // The number of seconds remaining in the alloted time period
+ private $_rateLimitReset = null;
+
+ // The scope the user has
+ private $_scope = null;
+
+ // token scopes
+ private $_scopes = [];
+
+ // debug info
+ private $_last_request = null;
+ private $_last_response = null;
+
+ // ssl certification
+ private $_sslCA = null;
+
+ // the callback function to be called when an event is received from the stream
+ private $_streamCallback = null;
+
+ // the stream buffer
+ private $_streamBuffer = '';
+
+ // stores the curl handler for the current stream
+ private $_currentStream = null;
+
+ // stores the curl multi handler for the current stream
+ private $_multiStream = null;
+
+ // stores the number of failed connects, so we can back off multiple failures
+ private $_connectFailCounter = 0;
+
+ // stores the most recent stream url, so we can re-connect when needed
+ private $_streamUrl = null;
+
+ // keeps track of the last time we've received a packet from the api, if it's too long we'll reconnect
+ private $_lastStreamActivity = null;
+
+ // stores the headers received when connecting to the stream
+ private $_streamHeaders = null;
+
+ // response meta max_id data
+ private $_maxid = null;
+
+ // response meta min_id data
+ private $_minid = null;
+
+ // response meta more data
+ private $_more = null;
+
+ // response stream marker data
+ private $_last_marker = null;
+
+ // strip envelope response from returned value
+ private $_stripResponseEnvelope = true;
+
+ // if processing stream_markers or any fast stream, decrease $sleepFor
+ public $streamingSleepFor = 20000;
+
+ /**
+ * Constructs an phpnut PHP object with the specified client ID and
+ * client secret.
+ * @param string $client_id The client ID you received from pnut.io when
+ * creating your app.
+ * @param string $client_secret The client secret you received from
+ * pnut.io when creating your app.
+ */
+ public function __construct(?string $client_id_or_token=null, ?string $client_secret=null)
+ {
+ if (!$client_id_or_token) {
+ if (isset($_ENV['PNUT_ACCESS_TOKEN'])) {
+ $client_id_or_token = $_ENV['PNUT_ACCESS_TOKEN'];
+ } elseif (defined('PNUT_ACCESS_TOKEN')) {
+ $client_id_or_token = PNUT_ACCESS_TOKEN;
+ } elseif (defined('PNUT_CLIENT_ID') && defined('PNUT_CLIENT_SECRET')) {
+ $client_id_or_token = PNUT_CLIENT_ID;
+ $client_secret = PNUT_CLIENT_SECRET;
+ }
+ }
+
+ if (!$client_id_or_token) {
+ throw new phpnutException('You must specify your pnut access token or client ID and secret');
+ }
+
+ if ($client_id_or_token && $client_secret) {
+ $this->_clientId = $client_id_or_token;
+ $this->_clientSecret = $client_secret;
+ } else {
+ $this->_accessToken = $client_id_or_token;
+ }
+
+ // if the digicert certificate exists in the same folder as this file,
+ // remember that fact for later
+ if (file_exists(__DIR__ . '/DigiCertHighAssuranceEVRootCA.pem')) {
+ $this->_sslCA = __DIR__ . '/DigiCertHighAssuranceEVRootCA.pem';
+ }
+ }
+
+ /**
+ * Set whether or not to strip Envelope Response (meta) information
+ * This option will be deprecated in the future. Is it to allow
+ * a stepped migration path between code expecting the old behavior
+ * and new behavior. When not stripped, you still can use the proper
+ * method to pull the meta information. Please start converting your code ASAP
+ */
+ public function includeResponseEnvelope(): void
+ {
+ $this->_stripResponseEnvelope = false;
+ }
+
+ /**
+ * Construct the proper Auth URL for the user to visit and either grant
+ * or not access to your app. Usually you would place this as a link for
+ * the user to client, or a redirect to send them to the auth URL.
+ * Also can be called after authentication for additional scopes
+ * @param string $callbackUri Where you want the user to be directed
+ * after authenticating with pnut.io. This must be one of the URIs
+ * allowed by your pnut.io application settings.
+ * @param array $scope An array of scopes (permissions) you wish to obtain
+ * from the user. If you don't specify anything, you'll only receive
+ * access to the user's basic profile (the default).
+ */
+ public function getAuthUrl(?string $callback_uri=null, array|string|null $scope=null): string
+ {
+ if (empty($this->_clientId)) {
+ throw new phpnutException('You must specify your pnut client ID');
+ }
+
+ if (is_null($callback_uri)) {
+ if (defined('PNUT_REDIRECT_URI')) {
+ $callback_uri = PNUT_REDIRECT_URI;
+ } elseif (isset($_ENV['PNUT_REDIRECT_URI'])) {
+ $callback_uri = $_ENV['PNUT_REDIRECT_URI'];
+ } else {
+ throw new phpnutException('You must specify your pnut callback URI');
+ }
+ }
+
+ if (is_null($scope)) {
+ if (defined('PNUT_APP_SCOPE')) {
+ $scope = PNUT_APP_SCOPE;
+ } elseif (isset($_ENV['PNUT_APP_SCOPE'])) {
+ $scope = $_ENV['PNUT_APP_SCOPE'];
+ } else {
+ $scope = 'basic';
+ }
+ }
+
+ if (is_array($scope)) {
+ $scope = implode(',', $scope);
+ }
+
+ // construct an authorization url based on our client id and other data
+ $data = [
+ 'client_id'=>$this->_clientId,
+ 'response_type'=>'code',
+ 'redirect_uri'=>$callback_uri,
+ 'scope'=>$scope,
+ ];
+
+ $url = $this->_authUrl;
+ if ($this->_accessToken) {
+ $url .= 'authorize?';
+ } else {
+ $url .= 'authenticate?';
+ }
+ $url .= $this->buildQueryString($data);
+
+ // return the constructed url
+ return $url;
+ }
+
+ /**
+ * Call this after they return from the auth page, or anytime you need the
+ * token. For example, you could store it in a database and use
+ * setAccessToken() later on to return on behalf of the user.
+ */
+ public function getAccessToken(string $callback_uri)
+ {
+ // if there's no access token set, and they're returning from
+ // the auth page with a code, use the code to get a token
+ if (!$this->_accessToken && isset($_GET['code']) && $_GET['code'] !== '') {
+
+ if (empty($this->_clientId) || empty($this->_clientSecret)) {
+ throw new phpnutException('You must specify your Pnut client ID and client secret');
+ }
+
+ // construct the necessary elements to get a token
+ $data = [
+ 'client_id'=>$this->_clientId,
+ 'client_secret'=>$this->_clientSecret,
+ 'grant_type'=>'authorization_code',
+ 'redirect_uri'=>$callback_uri,
+ 'code'=>$_GET['code'],
+ ];
+
+ // try and fetch the token with the above data
+ $res = $this->httpReq(
+ 'post',
+ "{$this->_baseUrl}oauth/access_token",
+ $data
+ );
+
+ // store it for later
+ $this->_accessToken = $res['access_token'];
+ $this->_username = $res['username'];
+ $this->_user_id = $res['user_id'];
+ }
+
+ // return what we have (this may be a token, or it may be nothing)
+ return $this->_accessToken;
+ }
+
+ /**
+ * Check the scope of current token to see if it has required scopes
+ * has to be done after a check
+ */
+ public function checkScopes(array $app_scopes): int|array
+ {
+ if (count($this->_scopes) === 0) {
+ return -1; // _scope is empty
+ }
+ $missing = [];
+ foreach($app_scopes as $scope) {
+ if (!in_array($scope, $this->_scopes)) {
+ if ($scope === 'public_messages') {
+ // messages works for public_messages
+ if (in_array('messages', $this->_scopes)) {
+ // if we have messages in our scopes
+ continue;
+ }
+ }
+ $missing[] = $scope;
+ }
+ }
+ // identify the ones missing
+ if (count($missing) !== 0) {
+ // do something
+ return $missing;
+ }
+ return 0; // 0 missing
+ }
+
+ /**
+ * Set the access token (eg: after retrieving it from offline storage)
+ * @param string $token A valid access token you're previously received
+ * from calling getAccessToken().
+ */
+ public function setAccessToken(?string $token=null): void
+ {
+ $this->_accessToken = $token;
+ }
+
+ /**
+ * Deauthorize the current token (delete your authorization from the API)
+ * Generally this is useful for logging users out from a web app, so they
+ * don't get automatically logged back in the next time you redirect them
+ * to the authorization URL.
+ */
+ public function deauthorizeToken()
+ {
+ return $this->httpReq('delete', "{$this->_baseUrl}token");
+ }
+
+ /**
+ * Retrieve an app access token from the app.net API. This allows you
+ * to access the API without going through the user access flow if you
+ * just want to (eg) consume global. App access tokens are required for
+ * some actions (like streaming global). DO NOT share the return value
+ * of this function with any user (or save it in a cookie, etc). This
+ * is considered secret info for your app only.
+ * @return string The app access token
+ */
+ public function getAppAccessToken()
+ {
+ if (empty($this->_clientId) || empty($this->_clientSecret)) {
+ throw new phpnutException('You must specify your Pnut client ID and client secret');
+ }
+
+ // construct the necessary elements to get a token
+ $data = [
+ 'client_id'=>$this->_clientId,
+ 'client_secret'=>$this->_clientSecret,
+ 'grant_type'=>'client_credentials',
+ ];
+ // try and fetch the token with the above data
+ $res = $this->httpReq(
+ 'post',
+ "{$this->_baseUrl}oauth/access_token",
+ $data
+ );
+ // store it for later
+ $this->_appAccessToken = $res['access_token'];
+ $this->_accessToken = $res['access_token'];
+ $this->_username = null;
+ $this->_user_id = null;
+ return $this->_accessToken;
+ }
+
+ /**
+ * Returns the total number of requests you're allowed within the
+ * alloted time period.
+ * @see getRateLimitReset()
+ */
+ public function getRateLimit()
+ {
+ return $this->_rateLimit;
+ }
+
+ /**
+ * The number of requests you have remaining within the alloted time period
+ * @see getRateLimitReset()
+ */
+ public function getRateLimitRemaining()
+ {
+ return $this->_rateLimitRemaining;
+ }
+
+ /**
+ * The number of seconds remaining in the alloted time period.
+ * When this time is up you'll have getRateLimit() available again.
+ */
+ public function getRateLimitReset()
+ {
+ return $this->_rateLimitReset;
+ }
+
+ /**
+ * The scope the user has
+ */
+ public function getScope()
+ {
+ return $this->_scope;
+ }
+
+ /**
+ * Internal function, parses out important information pnut.io adds
+ * to the headers.
+ */
+ protected function parseHeaders(string $response)
+ {
+ // take out the headers
+ // set internal variables
+ // return the body/content
+ $this->_rateLimit = null;
+ $this->_rateLimitRemaining = null;
+ $this->_rateLimitReset = null;
+ $this->_scope = null;
+
+ $response = explode("\r\n\r\n", $response, 2);
+ $headers = $response[0];
+
+ if ($headers === 'HTTP/1.1 100 Continue') {
+ $response = explode("\r\n\r\n", $response[1], 2);
+ $headers = $response[0];
+ }
+
+ // this is not a good way to parse http headers
+ // it will not (for example) take into account multiline headers
+ // but what we're looking for is pretty basic, so we can ignore those shortcomings
+ $headers = explode("\r\n", $headers);
+ foreach ($headers as $header) {
+ $header = explode(': ', $header, 2);
+ if (count($header) < 2) {
+ continue;
+ }
+ list($k, $v) = $header;
+ switch ($k) {
+ case 'X-RateLimit-Remaining':
+ $this->_rateLimitRemaining = $v;
+ break;
+ case 'X-RateLimit-Limit':
+ $this->_rateLimit = $v;
+ break;
+ case 'X-RateLimit-Reset':
+ $this->_rateLimitReset = $v;
+ break;
+ case 'X-OAuth-Scopes':
+ $this->_scope = $v;
+ $this->_scopes = explode(',', $v);
+ break;
+ }
+ }
+ return $response[1] ?? null;
+ }
+
+ /**
+ * Internal function. Used to turn things like TRUE into 1, and then
+ * calls http_build_query.
+ */
+ protected function buildQueryString(array $array): string
+ {
+ foreach ($array as $k => &$v) {
+ if (is_array($v)) {
+ $v = implode(',', $v);
+ } elseif ($v === true) {
+ $v = '1';
+ }
+ elseif ($v === false) {
+ $v = '0';
+ }
+ unset($v);
+ }
+ return http_build_query($array);
+ }
+
+
+ /**
+ * Internal function to handle all
+ * HTTP requests (POST,PUT,GET,DELETE)
+ */
+ protected function httpReq(string $act, string $req, string|array $params=[], string $contentType='application/x-www-form-urlencoded')
+ {
+ $ch = curl_init($req);
+ $headers = [];
+ if($act !== 'get') {
+ curl_setopt($ch, CURLOPT_POST, true);
+ // if they passed an array, build a list of parameters from it
+ if (is_array($params) && $act !== 'post-raw') {
+ $params = $this->buildQueryString($params);
+ }
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
+ $headers[] = "Content-Type: {$contentType}";
+ }
+ if($act !== 'post' && $act !== 'post-raw') {
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, strtoupper($act));
+ }
+ if($act === 'get' && isset($params['access_token'])) {
+ $headers[] = "Authorization: Bearer {$params['access_token']}";
+ } elseif ($this->_accessToken) {
+ $headers[] = "Authorization: Bearer {$this->_accessToken}";
+ }
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($ch, CURLINFO_HEADER_OUT, true);
+ curl_setopt($ch, CURLOPT_HEADER, true);
+ if ($this->_sslCA) {
+ curl_setopt($ch, CURLOPT_CAINFO, $this->_sslCA);
+ }
+ $this->_last_response = curl_exec($ch);
+ $this->_last_request = curl_getinfo($ch, CURLINFO_HEADER_OUT);
+ $http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+ curl_close($ch);
+
+ if ($http_status === 0) {
+ throw new phpnutException("Unable to connect to {$req}");
+ }
+ if ($this->_last_request === false) {
+ if (!curl_getinfo($ch, CURLINFO_SSL_VERIFYRESULT)) {
+ throw new phpnutException('SSL verification failed, connection terminated.');
+ }
+ }
+ if ($this->_last_response) {
+ $response = $this->parseHeaders($this->_last_response);
+ if ($response) {
+ $response = json_decode($response, true);
+
+ if (isset($response['meta'])) {
+ if (isset($response['meta']['max_id'])) {
+ $this->_maxid = $response['meta']['max_id'];
+ $this->_minid = $response['meta']['min_id'];
+ }
+ if (isset($response['meta']['more'])) {
+ $this->_more = $response['meta']['more'];
+ }
+ if (isset($response['meta']['marker'])) {
+ $this->_last_marker = $response['meta']['marker'];
+ }
+ }
+
+ // look for errors
+ if (isset($response['error'])) {
+ if (is_array($response['error'])) {
+ throw new phpnutException(
+ $response['error']['message'],
+ $response['error']['code']
+ );
+ } else {
+ throw new phpnutException($response['error']);
+ }
+ }
+
+ // look for response migration errors
+ elseif (isset($response['meta'], $response['meta']['error_message'])) {
+ throw new phpnutException(
+ $response['meta']['error_message'],
+ $response['meta']['code']
+ );
+ }
+ }
+ }
+
+ if ($http_status < 200 || $http_status >= 300) {
+ throw new phpnutException("HTTP error {$http_status}");
+ }
+
+ // if we've received a migration response, handle it and return data only
+ elseif ($this->_stripResponseEnvelope && isset($response['meta'], $response['data'])) {
+ return $response['data'];
+ }
+
+ // else non response migration response, just return it
+ elseif (isset($response)) {
+ return $response;
+ }
+
+ else {
+ throw new phpnutException('No response');
+ }
+ }
+
+
+ /**
+ * Get max_id from last meta response data envelope
+ */
+ public function getResponseMaxID()
+ {
+ return $this->_maxid;
+ }
+
+ /**
+ * Get min_id from last meta response data envelope
+ */
+ public function getResponseMinID()
+ {
+ return $this->_minid;
+ }
+
+ /**
+ * Get more from last meta response data envelope
+ */
+ public function getResponseMore()
+ {
+ return $this->_more;
+ }
+
+ /**
+ * Get marker from last meta response data envelope
+ */
+ public function getResponseMarker()
+ {
+ return $this->_last_marker;
+ }
+
+ public function getLastRequest()
+ {
+ return $this->_last_request;
+ }
+
+ public function getLastResponse()
+ {
+ return $this->_last_response;
+ }
+
+ /**
+ * Fetch API configuration object
+ * @return array
+ */
+ public function getConfig()
+ {
+ return $this->httpReq('get', "{$this->_baseUrl}sys/config");
+ }
+
+ /**
+ * Fetch basic API statistics
+ * @return array
+ */
+ public function getStats()
+ {
+ return $this->httpReq('get', "{$this->_baseUrl}sys/stats");
+ }
+
+ /**
+ * Process user content, message or post text.
+ * Mentions and hashtags will be parsed out of the
+ * text, as will bare URLs. To create a link in the text without using a
+ * bare URL, include the anchor text in the object text and include a link
+ * entity in the function call.
+ * @param string $text The text of the user/message/post
+ * @param array $data An associative array of optional post data. This
+ * will likely change as the API evolves, as of this writing allowed keys are:
+ * reply_to, and raw. "raw" may be a complex object represented
+ * by an associative array.
+ * @param array $params An associative array of optional data to be included
+ * in the URL (such as 'include_raw')
+ * @return array An associative array representing the post.
+ */
+ public function processText(string $text, array $data=[], array $params=[])
+ {
+ $data['text'] = $text;
+ $json = json_encode($data);
+ $qs = '';
+ if (!empty($params)) {
+ $qs = '?' . $this->buildQueryString($params);
+ }
+ return $this->httpReq(
+ 'post',
+ $this->_baseUrl . 'text/process' . $qs,
+ $json,
+ 'application/json'
+ );
+ }
+
+ /**
+ * Create a new Post object. Mentions and hashtags will be parsed out of the
+ * post text, as will bare URLs. To create a link in a post without using a
+ * bare URL, include the anchor text in the post's text and include a link
+ * entity in the post creation call.
+ * @param string $text The text of the post
+ * @param array $data An associative array of optional post data. This
+ * will likely change as the API evolves, as of this writing allowed keys are:
+ * reply_to, is_nsfw, and raw. "raw" may be a complex object represented
+ * by an associative array.
+ * @param array $params An associative array of optional data to be included
+ * in the URL (such as 'include_raw')
+ * @return array An associative array representing the post.
+ */
+ public function createPost(string $text, array $data=[], array $params=[])
+ {
+ $data['text'] = $text;
+ $json = json_encode($data);
+ $qs = '';
+ if (!empty($params)) {
+ $qs = '?' . $this->buildQueryString($params);
+ }
+ return $this->httpReq(
+ 'post',
+ $this->_baseUrl . 'posts' . $qs,
+ $json,
+ 'application/json'
+ );
+ }
+
+ /**
+ * Create a new Post object. Mentions and hashtags will be parsed out of the
+ * post text, as will bare URLs. To create a link in a post without using a
+ * bare URL, include the anchor text in the post's text and include a link
+ * entity in the post creation call.
+ * @param integer $post_id The ID of the post to revise
+ * @param string $text The new text of the post
+ * @param array $data An associative array of optional post data. This
+ * will likely change as the API evolves, as of this writing allowed keys are:
+ * is_nsfw.
+ * @param array $params An associative array of optional data to be included
+ * in the URL (such as 'include_raw')
+ * @return array An associative array representing the post.
+ */
+ public function revisePost(int $post_id, string $text, array $data=[], array $params=[])
+ {
+ $data['text'] = $text;
+ $json = json_encode($data);
+ $qs = '';
+ if (!empty($params)) {
+ $qs = '?' . $this->buildQueryString($params);
+ }
+ return $this->httpReq(
+ 'put',
+ $this->_baseUrl . 'posts/' . urlencode($post_id) . $qs,
+ $json,
+ 'application/json'
+ );
+ }
+
+ /**
+ * Returns a specific Post.
+ * @param integer $post_id The ID of the post to retrieve
+ * @param array $params An associative array of optional general parameters.
+ * @return array An associative array representing the post
+ */
+ public function getPost(int $post_id, array $params=[])
+ {
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl . 'posts/' . urlencode($post_id) . '?'
+ . $this->buildQueryString($params)
+ );
+ }
+
+ /**
+ * Returns a list of Posts.
+ * @param array $post_ids The list of post IDs to retrieve
+ * @param array $params An associative array of optional general parameters.
+ * @return array An array of arrays representing the posts
+ */
+ public function getMultiplePosts(array $post_ids, array $params=[])
+ {
+ $params['ids'] = $post_ids;
+
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl . 'posts?' . $this->buildQueryString($params)
+ );
+ }
+
+ /**
+ * Delete a Post. The current user must be the same user who created the Post.
+ * It returns the deleted Post on success.
+ * @param integer $post_id The ID of the post to delete
+ * @param array An associative array representing the post that was deleted
+ */
+ public function deletePost(int $post_id)
+ {
+ return $this->httpReq(
+ 'delete',
+ $this->_baseUrl . 'posts/' . urlencode($post_id)
+ );
+ }
+
+ /**
+ * Retrieve the Posts that are 'in reply to' a specific Post.
+ * @param integer $post_id The ID of the post you want to retrieve replies for.
+ * @param array $params An associative array of optional general parameters.
+ * @return An array of associative arrays, each representing a single post.
+ */
+ public function getPostThread(int $post_id, array $params=[])
+ {
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl . 'posts/' . urlencode($post_id) . '/thread?'
+ . $this->buildQueryString($params)
+ );
+ }
+
+ /**
+ * Retrieve revisions of a post. Currently only one can be created.
+ * @param integer $post_id The ID of the post you want to retrieve previous revisions of.
+ * @param array $params An associative array of optional general parameters.
+ * @return An array of associative arrays, each representing a single post.
+ */
+ public function getPostRevisions(int $post_id, array $params=[])
+ {
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl . 'posts/' . urlencode($post_id) . '/revisions?'
+ . $this->buildQueryString($params)
+ );
+ }
+
+ /**
+ * Get the most recent Posts created by a specific User in reverse
+ * chronological order (most recent first).
+ * @param mixed $user_id Either the ID of the user you wish to retrieve posts by,
+ * or the string "me", which will retrieve posts for the user you're authenticated
+ * as.
+ * @param array $params An associative array of optional general parameters.
+ * @return An array of associative arrays, each representing a single post.
+ */
+ public function getUserPosts(string|int $user_id='me', array $params=[])
+ {
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl . 'users/' . urlencode($user_id) . '/posts?'
+ . $this->buildQueryString($params)
+ );
+ }
+
+ /**
+ * Get the most recent Posts mentioning by a specific User in reverse
+ * chronological order (newest first).
+ * @param mixed $user_id Either the ID of the user who is being mentioned, or
+ * the string "me", which will retrieve posts for the user you're authenticated
+ * as.
+ * @param array $params An associative array of optional general parameters.
+ * @return An array of associative arrays, each representing a single post.
+ */
+ public function getUserMentions(string|int $user_id='me', array $params=[])
+ {
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl . 'users/' . urlencode($user_id) . '/mentions?'
+ . $this->buildQueryString($params)
+ );
+ }
+
+ /**
+ * Get the currently authenticated user's recent messages
+ * @param array $params An associative array of optional general parameters.
+ * @return An array of associative arrays, each representing a single post.
+ */
+ public function getUserMessages(array $params=[])
+ {
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl . 'users/me/messages?'
+ . $this->buildQueryString($params)
+ );
+ }
+
+ /**
+ * Return the 20 most recent posts from the current User and
+ * the Users they follow.
+ * @param array $params An associative array of optional general parameters.
+ * @return An array of associative arrays, each representing a single post.
+ */
+ public function getUserStream(array $params=[])
+ {
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl . 'posts/streams/me?'
+ . $this->buildQueryString($params)
+ );
+ }
+
+ /**
+ * Retrieve a list of all public Posts on pnut.io, often referred to as the
+ * global stream.
+ * @param array $params An associative array of optional general parameters.
+ * @return An array of associative arrays, each representing a single post.
+ */
+ public function getPublicPosts(array $params=[])
+ {
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl . 'posts/streams/global?'
+ . $this->buildQueryString($params)
+ );
+ }
+
+ /**
+ * Retrieve a list of "explore" streams
+ * @return An array of associative arrays, each representing a single explore stream.
+ */
+ public function getPostExploreStreams()
+ {
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl . 'posts/streams/explore'
+ );
+ }
+
+ /**
+ * Retrieve a list of posts from an "explore" stream on pnut.io.
+ * @param string $slug [<description>]
+ * @param array $params An associative array of optional general parameters.
+ * @return An array of associative arrays, each representing a single post.
+ */
+ public function getPostExploreStream(string $slug, array $params=[])
+ {
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl . 'posts/streams/explore/' . urlencode($slug) . '?'
+ . $this->buildQueryString($params)
+ );
+ }
+
+ /**
+ * Bookmark a post
+ * @param integer $post_id The post ID to bookmark
+ */
+ public function bookmarkPost(int $post_id)
+ {
+ return $this->httpReq(
+ 'put',
+ $this->_baseUrl . 'posts/' . urlencode($post_id) . '/bookmark'
+ );
+ }
+
+ /**
+ * Unbookmark a post
+ * @param integer $post_id The post ID to unbookmark
+ */
+ public function unbookmarkPost(int $post_id)
+ {
+ return $this->httpReq(
+ 'delete',
+ $this->_baseUrl . 'posts/' . urlencode($post_id) . '/bookmark'
+ );
+ }
+
+ /**
+ * List the posts bookmarked by the current user
+ * @param array $params An associative array of optional general parameters.
+ * This will likely change as the API evolves, as of this writing allowed keys
+ * are: count, before_id, since_id, include_muted, include_deleted,
+ * and include_post_raw.
+ * See https://github.com/phpnut/api-spec/blob/master/resources/posts.md#general-parameters
+ * @return array An array of associative arrays, each representing a single
+ * user who has bookmarked a post
+ */
+ public function getBookmarked(string|int $user_id='me', array $params=[])
+ {
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl . 'users/' . urlencode($user_id) . '/bookmarks?'
+ . $this->buildQueryString($params)
+ );
+ }
+
+ /**
+ * List the interactions with a post (bookmark, repost, reply)
+ * @param integer $post_id the post ID to get interactions from
+ * @param array $params optional parameters like filters or excludes
+ * @return array An array of associative arrays, each representing one post interaction.
+ */
+ public function getPostInteractions(int $post_id, array $params=[])
+ {
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl . 'posts/' . urlencode($post_id) . '/interactions?'
+ . $this->buildQueryString($params)
+ );
+ }
+
+ /**
+ * List the bookmarks of a post
+ * @param integer $post_id the post ID to get stars from
+ * @return array An array of associative arrays, each representing one bookmark action.
+ */
+ public function getPostBookmarks(int $post_id)
+ {
+ return $this->getPostInteractions($post_id, ['filters'=>['bookmark']]);
+ }
+
+ /**
+ * Returns an array of User objects of users who reposted the specified post.
+ * @param integer $post_id the post ID to
+ * @return array An array of associative arrays, each representing a single
+ * user who reposted $post_id
+ */
+ public function getPostReposts(int $post_id)
+ {
+ return $this->getPostInteractions($post_id, ['filters'=>['repost']]);
+ }
+
+ /**
+ * Repost an existing Post object.
+ * @param integer $post_id The id of the post
+ * @return the reposted post
+ */
+ public function repost(int $post_id)
+ {
+ return $this->httpReq(
+ 'put',
+ $this->_baseUrl . 'posts/' . urlencode($post_id) . '/repost'
+ );
+ }
+
+ /**
+ * Delete a post that the user has reposted.
+ * @param integer $post_id The id of the post
+ * @return the un-reposted post
+ */
+ public function deleteRepost(int $post_id)
+ {
+ return $this->httpReq(
+ 'delete',
+ $this->_baseUrl . 'posts/' . urlencode($post_id) . '/repost'
+ );
+ }
+
+ /**
+ * Return Posts matching a specific #hashtag.
+ * @param string $hashtag The hashtag you're looking for.
+ * @param array $params An associative array of optional general parameters.
+ * This will likely change as the API evolves, as of this writing allowed keys
+ * are: count, before_id, since_id, include_muted, include_deleted,
+ * include_directed_posts, and include_raw.
+ * @return An array of associative arrays, each representing a single post.
+ */
+ public function searchHashtags(string $hashtag, array $params=[])
+ {
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl . 'posts/tags/' . urlencode($hashtag) . '?'
+ . $this->buildQueryString($params)
+ );
+ }
+
+ /**
+ * List the posts who match a specific search term
+ * @param array $params a list of filter, search query, and general Post parameters
+ * see: https://docs.pnut.io/resources/posts/search
+ * @param string $query The search query. Supports
+ * normal search terms. Searches post text.
+ * @return array An array of associative arrays, each representing one post.
+ * or false on error
+ */
+ public function searchPosts(array $params=[], string $query='', string $order='default')
+ {
+ if (!is_array($params)) {
+ return false;
+ }
+ if (!empty($query)) {
+ $params['q'] = $query;
+ }
+ if ($order === 'default') {
+ if (!empty($query)) {
+ $params['order'] = 'relevance';
+ } else {
+ $params['order'] = 'id';
+ }
+ }
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl . 'posts/search?' . $this->buildQueryString($params)
+ );
+ }
+
+ /**
+ * Return the 20 most recent posts for a stream using a valid Token
+ * @param array $params An associative array of optional general parameters.
+ * This will likely change as the API evolves, as of this writing allowed keys
+ * are: count, before_id, since_id, include_muted, include_deleted,
+ * and include_post_raw.
+ * @return An array of associative arrays, each representing a single post.
+ */
+ public function getUserPersonalStream(array $params=[])
+ {
+ if ($params['access_token']) {
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl . 'posts/streams/me?'
+ . $this->buildQueryString($params),
+ $params
+ );
+ } else {
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl . 'posts/streams/me?'
+ . $this->buildQueryString($params)
+ );
+ }
+ }
+
+ /**
+ * Return the 20 most recent Posts from the current User's personalized stream
+ * and mentions stream merged into one stream.
+ * @param array $params An associative array of optional general parameters.
+ * This will likely change as the API evolves, as of this writing allowed keys
+ * are: count, before_id, since_id, include_muted, include_deleted,
+ * include_directed_posts, and include_raw.
+ * @return An array of associative arrays, each representing a single post.
+ */
+ public function getUserUnifiedStream(array $params=[])
+ {
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl . 'posts/streams/unified?'
+ . $this->buildQueryString($params)
+ );
+ }
+
+ /**
+ * List User interactions
+ */
+ public function getMyActions(array $params=[])
+ {
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl . 'users/me/interactions?'
+ . $this->buildQueryString($params)
+ );
+ }
+
+ /**
+ * Returns a specific user object.
+ * @param mixed $user_id The ID of the user you want to retrieve, or the string "@-username", or the string
+ * "me" to retrieve data for the users you're currently authenticated as.
+ * @param array $params An associative array of optional general parameters.
+ * This will likely change as the API evolves, as of this writing allowed keys
+ * are: include_raw|include_user_raw.
+ * @return array An associative array representing the user data.
+ */
+ public function getUser(string|int $user_id='me', array $params=[])
+ {
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl . 'users/' . urlencode($user_id) . '?'
+ . $this->buildQueryString($params)
+ );
+ }
+
+ /**
+ * Returns multiple users request by an array of user ids
+ * @param array $params An associative array of optional general parameters.
+ * This will likely change as the API evolves, as of this writing allowed keys
+ * are: include_raw|include_user_raw.
+ * @return array An associative array representing the users data.
+ */
+ public function getUsers(array $user_arr, array $params=[])
+ {
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl . 'users?ids=' . implode(',', $user_arr)
+ . '&' . $this->buildQueryString($params)
+ );
+ }
+
+ /**
+ * Add the specified user ID to the list of users followed.
+ * Returns the User object of the user being followed.
+ * @param integer $user_id The user ID of the user to follow.
+ * @return array An associative array representing the user you just followed.
+ */
+ public function followUser(string|int $user_id)
+ {
+ return $this->httpReq(
+ 'put',
+ $this->_baseUrl . 'users/' . urlencode($user_id) . '/follow'
+ );
+ }
+
+ /**
+ * Removes the specified user ID to the list of users followed.
+ * Returns the User object of the user being unfollowed.
+ * @param integer $user_id The user ID of the user to unfollow.
+ * @return array An associative array representing the user you just unfollowed.
+ */
+ public function unfollowUser(string|int $user_id)
+ {
+ return $this->httpReq(
+ 'delete',
+ $this->_baseUrl . 'users/' . urlencode($user_id) . '/follow'
+ );
+ }
+
+ /**
+ * Returns an array of User objects the specified user is following.
+ * @param mixed $user_id Either the ID of the user being followed, or
+ * the string "me", which will retrieve posts for the user you're authenticated
+ * as.
+ * @return array An array of associative arrays, each representing a single
+ * user following $user_id
+ */
+ public function getFollowing(string|int $user_id='me', array $params=[])
+ {
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl . 'users/' . urlencode($user_id) . '/following?'
+ . $this->buildQueryString($params)
+ );
+ }
+
+ /**
+ * Returns an array of User ids the specified user is following.
+ * @param mixed $user_id Either the ID of the user being followed, or
+ * the string "me", which will retrieve posts for the user you're authenticated
+ * as.
+ * @return array user ids the specified user is following.
+ */
+ public function getFollowingIDs(string|int $user_id='me')
+ {
+ return $this->httpReq(
+ 'get',
+ "{$this->_baseUrl}users/{$user_id}/following?include_user=0"
+ );
+ }
+
+ /**
+ * Returns an array of User objects for users following the specified user.
+ * @param mixed $user_id Either the ID of the user being followed, or
+ * the string "me", which will retrieve posts for the user you're authenticated
+ * as.
+ * @return array An array of associative arrays, each representing a single
+ * user following $user_id
+ */
+ public function getFollowers(string|int $user_id='me', array $params=[])
+ {
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl . 'users/' . urlencode($user_id) . '/followers?'
+ . $this->buildQueryString($params)
+ );
+ }
+
+ /**
+ * Returns an array of User ids for users following the specified user.
+ * @param mixed $user_id Either the ID of the user being followed, or
+ * the string "me", which will retrieve posts for the user you're authenticated
+ * as.
+ * @return array user ids for users following the specified user
+ */
+ public function getFollowersIDs(string|int $user_id='me')
+ {
+ return $this->httpReq(
+ 'get',
+ "{$this->_baseUrl}users/{$user_id}/followers?include_user=0"
+ );
+ }
+
+ /**
+ * Retrieve a user's user ID by specifying their username.
+ * @param string $username The username of the user you want the ID of, without
+ * an @ symbol at the beginning.
+ * @return integer The user's user ID
+ */
+ public function getIdByUsername(string $username)
+ {
+ return $this->httpReq(
+ 'get',
+ "{$this->_baseUrl}users/@{$username}?include_user=0"
+ );
+ }
+
+ /**
+ * Mute a user
+ * @param integer $user_id The user ID to mute
+ */
+ public function muteUser(string|int $user_id)
+ {
+ return $this->httpReq(
+ 'put',
+ $this->_baseUrl . 'users/' . urlencode($user_id) . '/mute'
+ );
+ }
+
+ /**
+ * Unmute a user
+ * @param integer $user_id The user ID to unmute
+ */
+ public function unmuteUser(string|int $user_id)
+ {
+ return $this->httpReq(
+ 'delete',
+ $this->_baseUrl . 'users/' . urlencode($user_id) . '/mute'
+ );
+ }
+
+ /**
+ * List the users muted by the current user
+ * @return array An array of associative arrays, each representing one muted user.
+ */
+ public function getMuted()
+ {
+ return $this->httpReq(
+ 'get',
+ "{$this->_baseUrl}users/me/muted"
+ );
+ }
+
+ /**
+ * Get a user object by username
+ * @param string $name the @name to get
+ * @return array representing one user
+ */
+ public function getUserByName(string $name)
+ {
+ return $this->httpReq(
+ 'get',
+ "{$this->_baseUrl}users/@{$name}"
+ );
+ }
+
+ /**
+ * List the users who match a specific search term
+ * @param string $search The search query. Supports @username or #tag searches as
+ * well as normal search terms. Searches username, display name, bio information.
+ * Does not search posts.
+ * @return array An array of associative arrays, each representing one user.
+ */
+ public function searchUsers(array $params=[], string $query='')
+ {
+ if (!is_array($params)) {
+ return false;
+ }
+ if ($query === '') {
+ return false;
+ }
+ $params['q'] = $query;
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl . 'users/search?q=' . $this->buildQueryString($params)
+ );
+ }
+
+ /**
+ * Update Profile Data via JSON
+ * @data array containing user descriptors
+ */
+ public function updateUserData(array $data=[], array $params=[])
+ {
+ $json = json_encode($data);
+ return $this->httpReq(
+ 'put',
+ $this->_baseUrl . 'users/me?'
+ . $this->buildQueryString($params),
+ $json,
+ 'application/json'
+ );
+ }
+
+ /**
+ * Update a user image
+ * @image path reference to image
+ * @which avatar|cover
+ */
+ protected function updateUserImage(string $image, string $which='avatar')
+ {
+ $test = @getimagesize($image);
+ if ($test && array_key_exists('mime', $test)) {
+ $mimeType = $test['mime'];
+ }
+ $data = [
+ $which => new CurlFile($image, $mimeType)
+ ];
+ return $this->httpReq(
+ 'post-raw',
+ "{$this->_baseUrl}users/me/{$which}",
+ $data,
+ 'multipart/form-data'
+ );
+ }
+
+ public function updateUserAvatar($avatar)
+ {
+ return $this->updateUserImage('avatar', $avatar);
+ }
+
+ public function updateUserCover($cover)
+ {
+ return $this->updateUserImage('cover', $cover);
+ }
+
+ /**
+ * Returns a Client object
+ * @param string $client_id
+ * @return array An array representing the client
+ */
+ public function getClient(string $client_id, array $params=[])
+ {
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl . 'clients/' . urlencode($client_id) . '?'
+ . $this->buildQueryString($params)
+ );
+ }
+
+ /**
+ * Returns a list of truncated client details made by a user
+ * @param string $user_id
+ * @return array A list of arrays representing clients
+ */
+ public function getUserClients(string $user_id)
+ {
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl . 'users/' . urlencode($user_id) . '/clients'
+ );
+ }
+
+ /**
+ * update stream marker
+ */
+ public function updateStreamMarker(array $data=[])
+ {
+ $json = json_encode($data);
+ return $this->httpReq(
+ 'post',
+ "{$this->_baseUrl}markers",
+ $json,
+ 'application/json'
+ );
+ }
+
+ /**
+ * get a page of current user subscribed channels
+ */
+ public function getMyChannelSubscriptions(array $params=[])
+ {
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl . 'users/me/channels/subscribed?' . $this->buildQueryString($params)
+ );
+ }
+
+ /**
+ * get user channels
+ */
+ public function getMyChannels(array $params=[])
+ {
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl . 'users/me/channels?' . $this->buildQueryString($params)
+ );
+ }
+
+ /**
+ * create a channel
+ * note: you cannot create a channel with type=io.pnut.core.pm (see createMessage)
+ */
+ public function createChannel(array $data=[])
+ {
+ $json = json_encode($data);
+ return $this->httpReq(
+ 'post',
+ "{$this->_baseUrl}channels",
+ $json,
+ 'application/json'
+ );
+ }
+
+ /**
+ * get channelid info
+ */
+ public function getChannel(int $channelid, array $params=[])
+ {
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl . 'channels/' . $channelid . '?'
+ . $this->buildQueryString($params)
+ );
+ }
+
+ /**
+ * get an existing private message channel between multiple users
+ * @param mixed $users Can be a comma- or space-separated string, or an array.
+ * Usernames with @-symbol, or user ids.
+ */
+ public function getExistingPM(string|array $users, array $params=[])
+ {
+ if (is_string($users)) {
+ $users = explode(',', str_replace(' ', ',', $users));
+ }
+ foreach($users as $key=>$user) {
+ if (!is_numeric($user) && substr($user, 0, 1) !== '@') {
+ $users[$key] = "@{$user}";
+ }
+ }
+ $params['ids'] = $users;
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl . 'users/me/channels/existing_pm?'
+ . $this->buildQueryString($params)
+ );
+ }
+
+ /**
+ * get multiple channels' info by an array of channelids
+ */
+ public function getChannels(array $channels, array $params=[])
+ {
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl . 'channels?ids=' . implode(',', $channels) . '&'
+ . $this->buildQueryString($params)
+ );
+ }
+
+ /**
+ * update channelid
+ */
+ public function updateChannel(int $channelid, array $data=[])
+ {
+ $json = json_encode($data);
+ return $this->httpReq(
+ 'put',
+ "{$this->_baseUrl}channels/{$channelid}",
+ $json,
+ 'application/json'
+ );
+ }
+
+ /**
+ * subscribe from channelid
+ */
+ public function channelSubscribe(int $channelid)
+ {
+ return $this->httpReq(
+ 'put',
+ $this->_baseUrl.'channels/'.$channelid.'/subscribe'
+ );
+ }
+
+ /**
+ * unsubscribe from channelid
+ */
+ public function channelUnsubscribe(int $channelid)
+ {
+ return $this->httpReq(
+ 'delete',
+ $this->_baseUrl.'channels/'.$channelid.'/subscribe'
+ );
+ }
+
+ /**
+ * mute channelid
+ */
+ public function channelMute(int $channelid)
+ {
+ return $this->httpReq(
+ 'put',
+ $this->_baseUrl.'channels/'.$channelid.'/mute'
+ );
+ }
+
+ /**
+ * unmute channelid
+ */
+ public function channelUnmute(int $channelid)
+ {
+ return $this->httpReq(
+ 'delete',
+ $this->_baseUrl.'channels/'.$channelid.'/mute'
+ );
+ }
+
+ /**
+ * get all user objects subscribed to channelid
+ */
+ public function getChannelSubscriptions(int $channelid, array $params=[])
+ {
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl.'channels/'.$channelid.'/subscribers?'
+ . $this->buildQueryString($params)
+ );
+ }
+
+ /**
+ * get all user IDs subscribed to channelid
+ */
+ public function getChannelSubscriptionsById(int $channelid)
+ {
+ return $this->httpReq(
+ 'get',
+ "{$this->_baseUrl}channels/{$channelid}/subscribers?include_user=0"
+ );
+ }
+
+ /**
+ * Retrieve a list of "explore" streams
+ * @return An array of associative arrays, each representing a single explore stream.
+ */
+ public function getChannelExploreStreams()
+ {
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl . 'channels/streams/explore'
+ );
+ }
+
+ /**
+ * Retrieve a list of channels from an "explore" stream on pnut.io.
+ * @param string $slug [<description>]
+ * @param array $params An associative array of optional general parameters.
+ * @return An array of associative arrays, each representing a single channel.
+ */
+ public function getChannelExploreStream(string $slug, array $params=[])
+ {
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl . 'channels/streams/explore/' . urlencode($slug) . '?'
+ . $this->buildQueryString($params)
+ );
+ }
+
+ /**
+ * mark channel inactive
+ */
+ public function deleteChannel(int $channelid)
+ {
+ return $this->httpReq(
+ 'delete',
+ $this->_baseUrl.'channels/'.$channelid
+ );
+ }
+
+ /**
+ * List the channels that match a specific search term
+ * @param array $params a list of filter, search query, and general Channel parameters
+ * see: https://docs.pnut.io/resources/channels/search
+ * @param string $query The search query. Supports
+ * normal search terms. Searches common channel raw.
+ * @return array An array of associative arrays, each representing one channel.
+ * or false on error
+ */
+ public function searchChannels(array $params=[], string $query='', string $order='default')
+ {
+ if (!empty($query)) {
+ $params['q'] = $query;
+ }
+ if ($order === 'default') {
+ if (!empty($query)) {
+ $params['order'] = 'id';
+ } else {
+ $params['order'] = 'activity';
+ }
+ }
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl . 'channels/search?' . $this->buildQueryString($params)
+ );
+ }
+
+
+ /**
+ * get a page of messages in channelid
+ */
+ public function getMessages(int $channelid, array $params=[])
+ {
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl.'channels/'.$channelid.'/messages?'
+ . $this->buildQueryString($params)
+ );
+ }
+
+ /**
+ * get a page of messages in channelid in a thread
+ */
+ public function getMessageThread(int $channelid, int $messageid, array $params=[])
+ {
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl.'channels/'.$channelid.'/messages/'.$messageid.'/thread?'
+ . $this->buildQueryString($params)
+ );
+ }
+
+ /**
+ * get a page of sticky messages in channelid
+ */
+ public function getStickyMessages(int $channelid, array $params=[])
+ {
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl.'channels/'.$channelid.'/sticky_messages?'
+ . $this->buildQueryString($params)
+ );
+ }
+
+ /**
+ * sticky messsage
+ */
+ public function stickyMessage(int $channelid, int $messageid)
+ {
+ return $this->httpReq(
+ 'put',
+ $this->_baseUrl.'channels/'.$channelid.'/messages/'.$messageid.'/sticky'
+ );
+ }
+
+ /**
+ * unsticky messsage
+ */
+ public function unstickyMessage(int $channelid, int $messageid)
+ {
+ return $this->httpReq(
+ 'delete',
+ $this->_baseUrl.'channels/'.$channelid.'/messages/'.$messageid.'/sticky'
+ );
+ }
+
+ /**
+ * create message
+ * @param $channelid numeric or "pm" for auto-channel (type=io.pnut.core.pm)
+ * @param array $data array('text'=>'YOUR_MESSAGE') If a type=io.pnut.core.pm, then "destinations" key can be set to address as an array of people to send this PM too
+ * @param array $params query parameters
+ */
+ public function createMessage(string|int $channelid, array $data, array $params=[])
+ {
+ if (isset($data['destinations'])) {
+ if (is_string($data['destinations'])) {
+ $data['destinations'] = explode(',', str_replace(' ', ',', $data['destinations']));
+ }
+ foreach($data['destinations'] as $key=>$user) {
+ if (!is_numeric($user) && substr($user, 0,1 ) !== '@') {
+ $data['destinations'][$key] = "@{$user}";
+ }
+ }
+ }
+ $json = json_encode($data);
+ return $this->httpReq(
+ 'post',
+ $this->_baseUrl.'channels/'.$channelid.'/messages?'
+ . $this->buildQueryString($params),
+ $json,
+ 'application/json'
+ );
+ }
+
+ /**
+ * get message
+ */
+ public function getMessage(int $channelid, int $messageid, array $params=[])
+ {
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl.'channels/'.$channelid.'/messages/'.$messageid.'?'
+ . $this->buildQueryString($params)
+ );
+ }
+
+ /**
+ * Returns a list of Messages.
+ * @param array $message_ids The list of message IDs to retrieve
+ * @param array $params An associative array of optional general parameters.
+ * @return array An array of arrays representing the messages
+ */
+ public function getMultipleMessages(array $message_ids, array $params=[])
+ {
+ $params['ids'] = $message_ids;
+
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl . 'channels/messages?' . $this->buildQueryString($params)
+ );
+ }
+
+ /**
+ * delete messsage
+ */
+ public function deleteMessage(int $channelid, int $messageid)
+ {
+ return $this->httpReq(
+ 'delete',
+ $this->_baseUrl.'channels/'.$channelid.'/messages/'.$messageid
+ );
+ }
+
+ /**
+ * List the messages that match a specific search term
+ * @param array $params a list of filter, search query, and general Message parameters
+ * see: https://docs.pnut.io/resources/messages/search
+ * @param string $query The search query. Supports
+ * normal search terms. Searches common channel raw.
+ * @return array An array of associative arrays, each representing one channel.
+ * or false on error
+ */
+ public function searchMessages(array $params=[], string $query='', string $order='default')
+ {
+ if (!is_array($params)) {
+ return false;
+ }
+ if (!empty($query)) {
+ $params['q'] = $query;
+ }
+ if ($order === 'default') {
+ if (!empty($query)) {
+ $params['order'] = 'id';
+ } else {
+ $params['order'] = 'relevance';
+ }
+ }
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl . 'channels/messages/search?'
+ . $this->buildQueryString($params)
+ );
+ }
+
+ /**
+ * Upload a file to a user's file store
+ * @param string $file A string containing the path of the file to upload.
+ * @param array $data Additional data about the file you're uploading. At the
+ * moment accepted keys are: mime-type, kind, type, name, public and raw.
+ * - If you don't specify mime-type, phpnut will attempt to guess the mime type
+ * based on the file, however this isn't always reliable.
+ * - If you don't specify kind phpnut will attempt to determine if the file is
+ * an image or not.
+ * - If you don't specify name, phpnut will use the filename of the first
+ * parameter.
+ * - If you don't specify is_public, your file will be uploaded as a private file.
+ * - Type is REQUIRED.
+ * @param array $params An associative array of optional general parameters.
+ * This will likely change as the API evolves, as of this writing allowed keys
+ * are: include_raw|include_file_raw.
+ * @return array An associative array representing the file
+ */
+ public function createFile($file, array $data, array $params=[])
+ {
+ if (!$file) {
+ throw new PhpnutException('You must specify a path to a file');
+ }
+ if (!file_exists($file)) {
+ throw new PhpnutException('File path specified does not exist');
+ }
+ if (!is_readable($file)) {
+ throw new PhpnutException('File path specified is not readable');
+ }
+ if (!array_key_exists('type', $data) || !$data['type']) {
+ throw new PhpnutException('Type is required when creating a file');
+ }
+ if (!array_key_exists('name', $data)) {
+ $data['name'] = basename($file);
+ }
+ if (array_key_exists('mime-type', $data)) {
+ $mimeType = $data['mime-type'];
+ unset($data['mime-type']);
+ } else {
+ $mimeType = null;
+ }
+ if (!array_key_exists('kind', $data)) {
+ $test = @getimagesize($path);
+ if ($test && array_key_exists('mime', $test)) {
+ $data['kind'] = 'image';
+ if (!$mimeType) {
+ $mimeType = $test['mime'];
+ }
+ }
+ else {
+ $data['kind'] = 'other';
+ }
+ }
+ if (!$mimeType) {
+ $finfo = finfo_open(FILEINFO_MIME_TYPE);
+ $mimeType = finfo_file($finfo, $file);
+ finfo_close($finfo);
+ }
+ if (!$mimeType) {
+ throw new PhpnutException('Unable to determine mime type of file, try specifying it explicitly');
+ }
+ $data['content'] = new \CurlFile($file, $mimeType);
+ return $this->httpReq(
+ 'post-raw',
+ "{$this->_baseUrl}files",
+ $data,
+ 'multipart/form-data'
+ );
+ }
+
+ public function createFilePlaceholder($file, array $params=[])
+ {
+ $name = basename($file);
+ $data = [
+ 'raw' => $params['raw'],
+ 'kind' => $params['kind'],
+ 'name' => $name,
+ 'type' => $params['metadata']
+ ];
+ $json = json_encode($data);
+ return $this->httpReq(
+ 'post',
+ $this->_baseUrl.'files',
+ $json,
+ 'application/json'
+ );
+ }
+
+ public function updateFileContent(int $fileid, string $file)
+ {
+ $data = file_get_contents($file);
+ $finfo = finfo_open(FILEINFO_MIME_TYPE);
+ $mime = finfo_file($finfo, $file);
+ finfo_close($finfo);
+ return $this->httpReq(
+ 'put',
+ $this->_baseUrl.'files/'.$fileid.'/content',
+ $data,
+ $mime
+ );
+ }
+
+ /**
+ * Allows for file rename and annotation changes.
+ * @param integer $file_id The ID of the file to update
+ * @param array $params An associative array of file parameters.
+ * @return array An associative array representing the updated file
+ */
+ public function updateFile(int $file_id, array $params=[])
+ {
+ $data = [
+ 'raw' => $params['raw'],
+ 'name' => $params['name'],
+ ];
+ $json = json_encode($data);
+ return $this->httpReq(
+ 'put',
+ $this->_baseUrl.'files/'.urlencode($file_id),
+ $json,
+ 'application/json'
+ );
+ }
+
+ /**
+ * Returns a specific File.
+ * @param integer $file_id The ID of the file to retrieve
+ * @param array $params An associative array of optional general parameters.
+ * This will likely change as the API evolves, as of this writing allowed keys
+ * are: include_raw|include_file_raw.
+ * @return array An associative array representing the file
+ */
+ public function getFile(int $file_id, array $params=[])
+ {
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl.'files/'.urlencode($file_id).'?'
+ . $this->buildQueryString($params)
+ );
+ }
+
+ public function getFileContent(int $file_id, array $params=[])
+ {
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl.'files/'.urlencode($file_id).'/content?'
+ . $this->buildQueryString($params)
+ );
+ }
+
+ /** $file_key : derived_file_key */
+ public function getDerivedFileContent(int $file_id, string $file_key, array $params=[])
+ {
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl.'files/'.urlencode($file_id).'/content/'.urlencode($file_key).'?'.$this->buildQueryString($params)
+ );
+ }
+
+ /**
+ * Returns file objects.
+ * @param array $file_ids The IDs of the files to retrieve
+ * @param array $params An associative array of optional general parameters.
+ * This will likely change as the API evolves, as of this writing allowed keys
+ * are: include_raw|include_file_raw.
+ * @return array An associative array representing the file data.
+ */
+ public function getFiles(array $file_ids, array $params=[])
+ {
+ $ids = '';
+ foreach($file_ids as $id) {
+ $ids .= $id . ',';
+ }
+ $params['ids'] = substr($ids, 0, -1);
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl.'files?'.$this->buildQueryString($params)
+ );
+ }
+
+ /**
+ * Returns a user's file objects.
+ * @param array $params An associative array of optional general parameters.
+ * This will likely change as the API evolves, as of this writing allowed keys
+ * are: include_raw|include_file_raw|include_user_raw.
+ * @return array An associative array representing the file data.
+ */
+ public function getUserFiles(array $params=[])
+ {
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl.'users/me/files?'.$this->buildQueryString($params)
+ );
+ }
+
+ /**
+ * Delete a File. The current user must be the same user who created the File.
+ * It returns the deleted File on success.
+ * @param integer $file_id The ID of the file to delete
+ * @return array An associative array representing the file that was deleted
+ */
+ public function deleteFile(int $file_id)
+ {
+ return $this->httpReq(
+ 'delete',
+ $this->_baseUrl.'files/'.urlencode($file_id)
+ );
+ }
+
+ /**
+ * Create a poll
+ * @param array $data An associative array of the required parameters.
+ * @param array $params An associative array of optional general parameters.
+ * Allowed keys: include_raw,include_poll_raw, ...
+ * @return array An associative array representing the poll
+ */
+ public function createPoll(array $data, array $params=[])
+ {
+ $json = json_encode($data);
+ return $this->httpReq(
+ 'post',
+ $this->_baseUrl.'polls?'.$this->buildQueryString($params),
+ $json,
+ 'application/json'
+ );
+ }
+
+ /**
+ * Responds to a poll.
+ * @param integer $poll_id The ID of the poll to respond to
+ * @param array list of positions for the poll response
+ * @param array $params An associative array of optional general parameters.
+ */
+ public function respondToPoll(int $poll_id, array $positions, array $params=[])
+ {
+ $json = json_encode(['positions' => $positions]);
+ return $this->httpReq(
+ 'put',
+ $this->_baseUrl.'polls/'.urlencode($poll_id).'/response?'.$this->buildQueryString($params),
+ $json,
+ 'application/json'
+ );
+ }
+
+ /**
+ * Returns a specific Poll.
+ * @param integer $poll_id The ID of the poll to retrieve
+ * @param array $params An associative array of optional general parameters.
+ * @return array An associative array representing the poll
+ */
+ public function getPoll(int $poll_id, array $params=[])
+ {
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl.'polls/'.urlencode($poll_id).'?'.$this->buildQueryString($params)
+ );
+ }
+
+ /**
+ * Returns a list of Polls.
+ * @param array $poll_ids The list of poll IDs to retrieve
+ * @param array $params An associative array of optional general parameters.
+ * @return array An array of arrays representing the polls
+ */
+ public function getMultiplePolls(array $poll_ids, array $params=[])
+ {
+ $params['ids'] = $poll_ids;
+
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl . 'polls?' . $this->buildQueryString($params)
+ );
+ }
+
+ /**
+ * Returns a user's poll objects.
+ * @param array $params An associative array of optional general parameters.
+ * @return array An associative array representing the poll data.
+ */
+ public function getUserPolls(array $params=[])
+ {
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl.'users/me/polls?'.$this->buildQueryString($params)
+ );
+ }
+
+ /**
+ * Delete a Poll. The current user must be the same user who created the Poll.
+ * @param integer $poll_id The ID of the poll to delete
+ * @param array $params An associative array of optional general parameters.
+ * @return array An associative array representing the poll that was deleted
+ */
+ public function deletePoll(int $poll_id, array $params=[])
+ {
+ return $this->httpReq(
+ 'delete',
+ $this->_baseUrl.'polls/'.urlencode($poll_id).'?'.$this->buildQueryString($params)
+ );
+ }
+
+ /**
+ * List the polls that match a specific search term
+ * @param array $params a list of filter, search query, and general Poll parameters
+ * see: https://docs.pnut.io/resources/channels/search
+ * @param string $query The search query. Supports
+ * normal search terms.
+ * @return array An array of associative arrays, each representing one poll.
+ * or false on error
+ */
+ public function searchPolls(array $params=[], string $order='id')
+ {
+ $params['order'] = $order;
+
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl . 'polls/search?' . $this->buildQueryString($params)
+ );
+ }
+
+
+ /**
+ * Get Application Information
+ */
+ public function getAppTokenInfo()
+ {
+ // requires appAccessToken
+ if (!$this->_appAccessToken) {
+ $this->getAppAccessToken();
+ }
+ // ensure request is made with our appAccessToken
+ $params['access_token'] = $this->_appAccessToken;
+ return $this->httpReq(
+ 'get',
+ "{$this->_baseUrl}token",
+ $params
+ );
+ }
+
+ /**
+ * Get User Information
+ */
+ public function getUserTokenInfo()
+ {
+ return $this->httpReq(
+ 'get',
+ "{$this->_baseUrl}token"
+ );
+ }
+
+ /**
+ * Get Application Authorized User IDs
+ */
+ public function getAppUserIDs()
+ {
+ // requires appAccessToken
+ if (!$this->_appAccessToken) {
+ $this->getAppAccessToken();
+ }
+ // ensure request is made with our appAccessToken
+ $params['access_token'] = $this->_appAccessToken;
+ return $this->httpReq(
+ 'get',
+ "{$this->_baseUrl}apps/me/users/ids",
+ $params
+ );
+ }
+
+ /**
+ * Get Application Authorized User Tokens
+ */
+ public function getAppUserTokens()
+ {
+ // requires appAccessToken
+ if (!$this->_appAccessToken) {
+ $this->getAppAccessToken();
+ }
+ // ensure request is made with our appAccessToken
+ $params['access_token'] = $this->_appAccessToken;
+ return $this->httpReq(
+ 'get',
+ "{$this->_baseUrl}apps/me/users/tokens",
+ $params
+ );
+ }
+
+
+
+ /**
+ * Registers your function (or an array of object and method) to be called
+ * whenever an event is received via an open pnut.io stream. Your function
+ * will receive a single parameter, which is the object wrapper containing
+ * the meta and data.
+ * @param mixed A PHP callback (either a string containing the function name,
+ * or an array where the first element is the class/object and the second
+ * is the method).
+ */
+ public function registerStreamFunction($function): void
+ {
+ $this->_streamCallback = $function;
+ }
+
+ /**
+ * Opens a stream that's been created for this user/app and starts sending
+ * events/objects to your defined callback functions. You must define at
+ * least one callback function before opening a stream.
+ * @param mixed $stream Either a stream ID or the endpoint of a stream
+ * you've already created. This stream must exist and must be valid for
+ * your current access token. If you pass a stream ID, the library will
+ * make an API call to get the endpoint.
+ *
+ * This function will return immediately, but your callback functions
+ * will continue to receive events until you call closeStream() or until
+ * pnut.io terminates the stream from their end with an error.
+ *
+ * If you're disconnected due to a network error, the library will
+ * automatically attempt to reconnect you to the same stream, no action
+ * on your part is necessary for this. However if the pnut.io API returns
+ * an error, a reconnection attempt will not be made.
+ *
+ * Note there is no closeStream, because once you open a stream you
+ * can't stop it (unless you exit() or die() or throw an uncaught
+ * exception, or something else that terminates the script).
+ * @return boolean True
+ * @see createStream()
+ */
+ public function openStream($stream): bool
+ {
+ // if there's already a stream running, don't allow another
+ if ($this->_currentStream) {
+ throw new phpnutException('There is already a stream being consumed, only one stream can be consumed per phpnutStream instance');
+ }
+ // must register a callback (or the exercise is pointless)
+ if (!$this->_streamCallback) {
+ throw new phpnutException('You must define your callback function using registerStreamFunction() before calling openStream');
+ }
+ // if the stream is a numeric value, get the stream info from the api
+ if (is_numeric($stream)) {
+ $stream = $this->getStream($stream);
+ $this->_streamUrl = $stream['endpoint'];
+ }
+ else {
+ $this->_streamUrl = $stream;
+ }
+ // continue doing this until we get an error back or something...?
+ $this->httpStream(
+ 'get',
+ $this->_streamUrl
+ );
+ return true;
+ }
+
+ /**
+ * Close the currently open stream.
+ * @return true;
+ */
+ public function closeStream(): void
+ {
+ if (!$this->_lastStreamActivity) {
+ // never opened
+ return;
+ }
+ if (!$this->_multiStream) {
+ throw new phpnutException('You must open a stream before calling closeStream()');
+ }
+ curl_close($this->_currentStream);
+ curl_multi_remove_handle($this->_multiStream, $this->_currentStream);
+ curl_multi_close($this->_multiStream);
+ $this->_currentStream = null;
+ $this->_multiStream = null;
+ }
+
+ /**
+ * Retrieve all streams for the current access token.
+ * @return array An array of stream definitions.
+ */
+ public function getAllStreams()
+ {
+ return $this->httpReq(
+ 'get',
+ "{$this->_baseUrl}streams"
+ );
+ }
+
+ /**
+ * Returns a single stream specified by a stream ID. The stream must have been
+ * created with the current access token.
+ * @return array A stream definition
+ */
+ public function getStream(string $streamId)
+ {
+ return $this->httpReq(
+ 'get',
+ $this->_baseUrl.'streams/'.urlencode($streamId)
+ );
+ }
+
+ /**
+ * Creates a stream for the current app access token.
+ *
+ * @param array $objectTypes The objects you want to retrieve data for from the
+ * stream. At time of writing these can be 'post', 'bookmark', 'user_follow', 'mute', 'block', 'stream_marker', 'message', 'channel', 'channel_subscription', 'token', and/or 'user'.
+ * If you don't specify, a few standard events will be retrieved.
+ */
+ public function createStream(?array $objectTypes=null)
+ {
+ // default object types to everything
+ if (is_null($objectTypes)) {
+ $objectTypes = [
+ 'post',
+ 'bookmark',
+ 'user_follow',
+ ];
+ }
+ $data = [
+ 'object_types'=>$objectTypes,
+ 'type'=>'long_poll',
+ ];
+ $data = json_encode($data);
+ $response = $this->httpReq(
+ 'post',
+ "{$this->_baseUrl}streams",
+ $data,
+ 'application/json'
+ );
+ return $response;
+ }
+
+ /**
+ * Update stream for the current app access token
+ *
+ * @param string $streamId The stream ID to update. This stream must have been
+ * created by the current access token.
+ * @param array $data allows object_types, type, filter_id and key to be updated. filter_id/key can be omitted
+ */
+ public function updateStream(string $streamId, array $data)
+ {
+ // objectTypes is likely required
+ if (is_null($data['object_types'])) {
+ $data['object_types'] = [
+ 'post',
+ 'bookmark',
+ 'user_follow',
+ ];
+ }
+ // type can still only be long_poll
+ if (is_null($data['type'])) {
+ $data['type'] = 'long_poll';
+ }
+ $data = json_encode($data);
+ $response = $this->httpReq(
+ 'put',
+ $this->_baseUrl.'streams/'.urlencode($streamId),
+ $data,
+ 'application/json'
+ );
+ return $response;
+ }
+
+ /**
+ * Deletes a stream if you no longer need it.
+ *
+ * @param string $streamId The stream ID to delete. This stream must have been
+ * created by the current access token.
+ */
+ public function deleteStream(string $streamId)
+ {
+ return $this->httpReq(
+ 'delete',
+ $this->_baseUrl.'streams/'.urlencode($streamId)
+ );
+ }
+
+ /**
+ * Deletes all streams created by the current access token.
+ */
+ public function deleteAllStreams()
+ {
+ return $this->httpReq(
+ 'delete',
+ "{$this->_baseUrl}streams"
+ );
+ }
+
+ /**
+ * Internal function used to process incoming chunks from the stream. This is only
+ * public because it needs to be accessed by CURL. Do not call or use this function
+ * in your own code.
+ * @ignore
+ */
+ public function httpStreamReceive($ch, $data)
+ {
+ $this->_lastStreamActivity = time();
+ $this->_streamBuffer .= $data;
+ if (!$this->_streamHeaders) {
+ $pos = strpos($this->_streamBuffer, "\r\n\r\n");
+ if ($pos !== false) {
+ $this->_streamHeaders = substr($this->_streamBuffer, 0, $pos);
+ $this->_streamBuffer = substr($this->_streamBuffer, $pos+4);
+ }
+ } else {
+ $pos = strpos($this->_streamBuffer, "\r\n");
+ while ($pos !== false) {
+ $command = substr($this->_streamBuffer, 0, $pos);
+ $this->_streamBuffer = substr($this->_streamBuffer, $pos+2);
+ $command = json_decode($command, true);
+ if ($command) {
+ call_user_func($this->_streamCallback, $command);
+ }
+ $pos = strpos($this->_streamBuffer, "\r\n");
+ }
+ }
+ return strlen($data);
+ }
+
+ /**
+ * Opens a long lived HTTP connection to the pnut.io servers, and sends data
+ * received to the httpStreamReceive function. As a general rule you should not
+ * directly call this method, it's used by openStream().
+ */
+ protected function httpStream(string $act, $req, array $params=[], string $contentType='application/x-www-form-urlencoded'): void
+ {
+ if ($this->_currentStream) {
+ throw new phpnutException('There is already an open stream, you must close the existing one before opening a new one');
+ }
+ $headers = [];
+ $this->_streamBuffer = '';
+ if ($this->_accessToken) {
+ $headers[] = "Authorization: Bearer {$this->_accessToken}";
+ }
+ $this->_currentStream = curl_init($req);
+ curl_setopt($this->_currentStream, CURLOPT_HTTPHEADER, $headers);
+ curl_setopt($this->_currentStream, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($this->_currentStream, CURLINFO_HEADER_OUT, true);
+ curl_setopt($this->_currentStream, CURLOPT_HEADER, true);
+ if ($this->_sslCA) {
+ curl_setopt($this->_currentStream, CURLOPT_CAINFO, $this->_sslCA);
+ }
+ // every time we receive a chunk of data, forward it to httpStreamReceive
+ curl_setopt($this->_currentStream, CURLOPT_WRITEFUNCTION, array($this, 'httpStreamReceive'));
+ // curl_exec($ch);
+ // return;
+ $this->_multiStream = curl_multi_init();
+ $this->_lastStreamActivity = time();
+ curl_multi_add_handle($this->_multiStream, $this->_currentStream);
+ }
+
+ public function reconnectStream(): void
+ {
+ $this->closeStream();
+ $this->_connectFailCounter++;
+ // if we've failed a few times, back off
+ if ($this->_connectFailCounter > 1) {
+ $sleepTime = pow(2, $this->_connectFailCounter);
+ // don't sleep more than 60 seconds
+ if ($sleepTime > 60) {
+ $sleepTime = 60;
+ }
+ sleep($sleepTime);
+ }
+ $this->httpStream('get', $this->_streamUrl);
+ }
+
+ /**
+ * Process an open stream for x microseconds, then return. This is useful if you want
+ * to be doing other things while processing the stream. If you just want to
+ * consume the stream without other actions, you can call processForever() instead.
+ * @param float @microseconds The number of microseconds to process for before
+ * returning. There are 1,000,000 microseconds in a second.
+ *
+ * @return void
+ */
+ public function processStream($microseconds=null): void
+ {
+ if (!$this->_multiStream) {
+ throw new phpnutException('You must open a stream before calling processStream()');
+ }
+ $start = microtime(true);
+ $active = null;
+ $inQueue = null;
+ $sleepFor = 0;
+ do {
+ // if we haven't received anything within 5.5 minutes, reconnect
+ // keepalives are sent every 5 minutes (measured on 2013-3-12 by @ryantharp)
+ if (time()-$this->_lastStreamActivity >= 330) {
+ $this->reconnectStream();
+ }
+ curl_multi_exec($this->_multiStream, $active);
+ if (!$active) {
+ $httpCode = curl_getinfo($this->_currentStream, CURLINFO_HTTP_CODE);
+ // don't reconnect on 400 errors
+ if ($httpCode >= 400 && $httpCode <= 499) {
+ throw new phpnutException("Received HTTP error {$httpCode} check your URL and credentials before reconnecting");
+ }
+ $this->reconnectStream();
+ }
+ // sleep for a max of 2/10 of a second
+ $timeSoFar = (microtime(true)-$start)*1000000;
+ $sleepFor = $this->streamingSleepFor;
+ if ($timeSoFar+$sleepFor > $microseconds) {
+ $sleepFor = $microseconds - $timeSoFar;
+ }
+ if ($sleepFor > 0) {
+ usleep($sleepFor);
+ }
+ } while ($timeSoFar+$sleepFor < $microseconds);
+ }
+
+ /**
+ * Process an open stream forever. This function will never return, if you
+ * want to perform other actions while consuming the stream, you should use
+ * processFor() instead.
+ * @return void This function will never return
+ * @see processFor();
+ */
+ public function processStreamForever(): void
+ {
+ while (true) {
+ $this->processStream(600);
+ }
+ }
+}
--- /dev/null
+<?php
+
+namespace phpnut;
+
+class phpnutException extends \Exception {}
--- /dev/null
+<?php
+/**
+ * Name: Pnut Connector
+ * Description: Post to pnut.io
+ * Version: 0.1.1
+ * Author: Morgan McMillian <https://social.clacks.network/profile/spacenerdmo>
+ * Status: In Development
+ */
+
+require_once 'addon/pnut/lib/phpnut.php';
+require_once 'addon/pnut/lib/phpnutException.php';
+
+use Friendica\Content\Text\BBCode;
+use Friendica\Content\Text\Plaintext;
+use Friendica\Core\Config\Util\ConfigFileManager;
+use Friendica\Core\Hook;
+use Friendica\Core\Logger;
+use Friendica\Core\Renderer;
+use Friendica\Core\System;
+use Friendica\DI;
+use Friendica\Model\Item;
+use Friendica\Model\Photo;
+use Friendica\Object\Image;
+use Friendica\Network\HTTPClient\Client\HttpClientAccept;
+use Friendica\Network\HTTPClient\Client\HttpClientOptions;
+use Friendica\Util\DateTimeFormat;
+
+function pnut_install()
+{
+ Hook::register('load_config', __FILE__, 'pnut_load_config');
+ Hook::register('hook_fork', __FILE__, 'pnut_hook_fork');
+ Hook::register('post_local', __FILE__, 'pnut_post_local');
+ Hook::register('notifier_normal', __FILE__, 'pnut_post_hook');
+ Hook::register('jot_networks', __FILE__, 'pnut_jot_nets');
+ Hook::register('connector_settings', __FILE__, 'pnut_settings');
+ Hook::register('connector_settings_post', __FILE__, 'pnut_settings_post');
+}
+
+function pnut_module() {}
+
+function pnut_content()
+{
+ if (!DI::userSession()->getLocalUserId()) {
+ DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
+ return '';
+ }
+
+ if (isset(DI::args()->getArgv()[1])) {
+ switch (DI::args()->getArgv()[1]) {
+ case 'connect':
+ $o = pnut_connect();
+ break;
+
+ default:
+ $o = print_r(DI::args()->getArgv(), true);
+ break;
+ }
+ } else {
+ $o = pnut_connect();
+ }
+ return $o;
+}
+
+function pnut_connect()
+{
+ $client_id = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pnut', 'client_id');
+ $client_secret = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pnut', 'client_secret');
+ $callback_url = DI::baseUrl() . '/pnut/connect';
+
+ $nut = new phpnut\phpnut($client_id, $client_secret);
+
+ try {
+ $token = $nut->getAccessToken($callback_url);
+ Logger::debug('TOKEN', [$token]);
+ $o = DI::l10n()->t('You are now authenticated with pnut.io.');
+ DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pnut', 'access_token', $token);
+ } catch (phpnutException $e) {
+ $o = DI::l10n()->t('Error fetching token. Please try again.');
+ }
+
+ $o .= '<br /><a href="' . DI::baseUrl() . '/settings/connectors">' . DI::l10n()->t("return to the connector page").'</a>';
+
+ return $o;
+}
+
+function pnut_load_config(ConfigFileManager $loader)
+{
+ DI::app()->getConfigCache()->load($loader->loadAddonConfig('pnut'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
+}
+
+function pnut_settings(array &$data)
+{
+ if (!DI::userSession()->getLocalUserId()) {
+ return;
+ }
+
+ $redirectUri = DI::baseUrl() . '/pnut/connect';
+ $scope = ['write_post','files'];
+
+ $enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pnut', 'post') ?? false;
+ $def_enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pnut', 'post_by_default') ?? false;
+ $client_id = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pnut', 'client_id');
+ $client_secret = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pnut', 'client_secret');
+ $token = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pnut', 'access_token');
+
+ Logger::debug('CLIENT_ID', [$client_id]);
+ Logger::debug('CLIENT_SECRET', [$client_secret]);
+
+ if (!empty($client_id) && !empty($client_secret) && empty($token)) {
+ $nut = new phpnut\phpnut($client_id, $client_secret);
+ $authorize_url = $nut->getAuthUrl($redirectUri, $scope);
+ $authorize_text = DI::l10n()->t('Authenticate with pnut.io');
+ }
+
+ if (!empty($token)) {
+ $disconn_btn = DI::l10n()->t('Disconnect');
+ }
+
+ $t = Renderer::getMarkupTemplate('connector_settings.tpl', 'addon/pnut/');
+ $html = Renderer::replaceMacros($t, [
+ '$enable' => ['pnut', DI::l10n()->t('Enable Pnut Post Addon'), $enabled],
+ '$bydefault' => ['pnut_bydefault', DI::l10n()->t('Post to Pnut by default'), $def_enabled],
+ '$client_id' => ['pnut_client_id', DI::l10n()->t('Client ID'), $client_id],
+ '$client_secret' => ['pnut_client_secret', DI::l10n()->t('Client Secret'), $client_secret],
+ '$access_token' => ['pnut_access_token', DI::l10n()->t('Access Token'), $token, '', '', 'readonly'],
+ '$authorize_url' => $authorize_url ?? '',
+ '$authorize_text' => $authorize_text ?? '',
+ '$disconn_btn' => $disconn_btn ?? '',
+ ]);
+
+ $data = [
+ 'connector' => 'pnut',
+ 'title' => DI::l10n()->t('Pnut Import/Export'),
+ 'image' => 'addon/pnut/pnut.svg',
+ 'enabled' => $enabled,
+ 'html' => $html,
+ ];
+}
+
+function pnut_settings_post(array &$b)
+{
+ if (empty($_POST['pnut-submit']) && empty($_POST['pnut-disconnect'])) {
+ return;
+ }
+
+ if (!empty($_POST['pnut-disconnect'])) {
+ DI::pConfig()->delete(DI::userSession()->getLocalUserId(), 'pnut', 'post');
+ DI::pConfig()->delete(DI::userSession()->getLocalUserId(), 'pnut', 'post_by_default');
+ DI::pConfig()->delete(DI::userSession()->getLocalUserId(), 'pnut', 'client_id');
+ DI::pConfig()->delete(DI::userSession()->getLocalUserId(), 'pnut', 'client_secret');
+ DI::pConfig()->delete(DI::userSession()->getLocalUserId(), 'pnut', 'access_token');
+ } else {
+ DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pnut', 'post', intval($_POST['pnut']));
+ DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pnut', 'post_by_default', intval($_POST['pnut_bydefault']));
+ DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pnut', 'client_id', $_POST['pnut_client_id']);
+ DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pnut', 'client_secret', $_POST['pnut_client_secret']);
+ }
+}
+
+function pnut_jot_nets(array &$jotnets_fields)
+{
+ if (!DI::userSession()->getLocalUserId()) {
+ return;
+ }
+
+ if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pnut', 'post')) {
+ $jotnets_fields[] = [
+ 'type' => 'checkbox',
+ 'field' => [
+ 'pnut_enable',
+ DI::l10n()->t('Post to Pnut'),
+ DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pnut', 'post_by_default')
+ ]
+ ];
+ }
+}
+
+function pnut_hook_fork(array &$b)
+{
+ if ($b['name'] != 'notifier_normal') {
+ return;
+ }
+
+ $post = $b['data'];
+
+ if (($post['created'] !== $post['edited']) && !$post['deleted']) {
+ DI::logger()->info('Editing is not supported by the addon');
+ $b['execute'] = false;
+ return;
+ }
+
+ if (!strstr($post['postopts'] ?? '', 'pnut') || ($post['parent'] != $post['id']) || $post['private']) {
+ $b['execute'] = false;
+ return;
+ }
+}
+
+function pnut_post_local(array &$b)
+{
+ if ($b['edit']) {
+ return;
+ }
+
+ if (!DI::userSession()->getLocalUserId() || (DI::userSession()->getLocalUserId() != $b['uid'])) {
+ return;
+ }
+
+ if ($b['private'] || $b['parent']) {
+ return;
+ }
+
+ $pnut_post = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pnut', 'post'));
+ $pnut_enable = (($pnut_post && !empty($_REQUEST['pnut_enable'])) ? intval($_REQUEST['pnut_enable']) : 0);
+
+ // if API is used, default to the chosen settings
+ if ($b['api_source'] && intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pnut', 'post_by_default'))) {
+ $pnut_enable = 1;
+ }
+
+ if (!$pnut_enable) {
+ return;
+ }
+
+ if (strlen($b['postopts'])) {
+ $b['postopts'] .= ',';
+ }
+
+ $b['postopts'] .= 'pnut';
+}
+
+function pnut_post_hook(array &$b)
+{
+ /**
+ * Post to pnut.io
+ */
+ if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
+ return;
+ }
+
+ Logger::notice('PNUT post invoked', ['id' => $b['id'], 'guid' => $b['guid'], 'plink' => $b['plink']]);
+ Logger::debug('PNUT array', $b);
+
+ $token = DI::pConfig()->get($b['uid'], 'pnut', 'access_token');
+ $nut = new phpnut\phpnut($token);
+
+ $msgarr = Plaintext::getPost($b, 256, true, BBCode::EXTERNAL);
+ $text = $msgarr['text'];
+ $raw = [];
+
+ Logger::debug('PNUT msgarr', $msgarr);
+
+ if (count($msgarr['parts']) > 1) {
+ $tstamp = time();
+ $raw['nl.chimpnut.blog.post'][] = ['body' => $b['body'], 'tstamp' => $tstamp];
+ $text = Plaintext::shorten($text, 252 - strlen($b['plink']), $b['uid']);
+ $text .= "\n" . $b['plink'];
+ }
+
+ if ($msgarr['type'] == 'link') {
+ $text .= "\n[" . $msgarr['title'] . "](" . $msgarr['url'] . ")";
+ }
+
+ if ($msgarr['type'] == 'photo') {
+ $fileraw = ['type' => 'dev.mcmillian.friendica.image', 'kind' => 'image', 'is_public' => true];
+ foreach ($msgarr['images'] as $image) {
+ Logger::debug('PNUT image', $image);
+
+ if (!empty($image['id'])) {
+ $photo = Photo::selectFirst([], ['id' => $image['id']]);
+ Logger::debug('PNUT selectFirst');
+ } else {
+ $photo = Photo::createPhotoForExternalResource($image['url']);
+ Logger::debug('PNUT createPhotoForExternalResource');
+ }
+ $picturedata = Photo::getImageForPhoto($photo);
+
+ Logger::debug('PNUT photo', $photo);
+ $picurefile = System::getTempPath() . DIRECTORY_SEPARATOR . $photo['filename'];
+ file_put_contents($picurefile, $picturedata);
+ Logger::debug('PNUT got file?', ['filename' => $picurefile]);
+ $imagefile = $nut->createFile($picurefile, $fileraw);
+ Logger::debug('PNUT file', ['pnutimagefile' => $imagefile]);
+ unlink($picurefile);
+
+ $raw['io.pnut.core.oembed'][] = ['+io.pnut.core.file' => ['file_id' => $imagefile['id'], 'file_token' => $imagefile['file_token'], 'format' => 'oembed']];
+ }
+ }
+
+ $raw['io.pnut.core.crosspost'][] = ['canonical_url' => $b['plink']];
+ $nut->createPost($text, ['raw' => $raw]);
+
+ Logger::debug('PNUT post complete', ['id' => $b['id'], 'text' => $text, 'raw' => $raw]);
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg width="100%" height="100%" viewBox="0 0 662 577" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:1.41421;"><g><g><path d="M80.265,421.001l0,-20.71l49.893,0l1.647,14.827c3.766,-5.492 8.277,-9.728 13.533,-12.709c5.256,-2.981 11.375,-4.471 18.356,-4.471c15.768,0 28.006,6.158 36.714,18.474c8.708,12.316 13.062,28.516 13.062,48.599l0,2.471c0,18.827 -4.354,33.968 -13.062,45.421c-8.708,11.453 -20.867,17.18 -36.478,17.18c-6.668,0 -12.591,-1.235 -17.769,-3.707c-5.177,-2.471 -9.61,-6.099 -13.297,-10.884l0,36.831l16.592,3.53l0,20.71l-67.426,0l0,-20.71l16.592,-3.53l0,-127.792l-18.357,-3.53Zm98.844,44.01c0,-12.003 -2,-21.731 -6.001,-29.183c-4.001,-7.453 -10.12,-11.179 -18.357,-11.179c-5.177,0 -9.59,1.059 -13.238,3.177c-3.648,2.118 -6.53,5.139 -8.649,9.061l0,55.776c2.119,3.609 5.001,6.355 8.649,8.237c3.648,1.883 8.139,2.825 13.474,2.825c8.315,0 14.415,-3.256 18.298,-9.767c3.883,-6.511 5.824,-15.337 5.824,-26.476l0,-2.471Z" style="fill:#008c99;fill-rule:nonzero;"/><path d="M248.573,507.019l16.475,-3.53l0,-78.958l-18.24,-3.53l0,-20.71l50.246,0l1.53,18.239c4.236,-6.511 9.453,-11.571 15.65,-15.179c6.198,-3.609 13.14,-5.413 20.828,-5.413c12.866,0 22.907,4.04 30.124,12.12c7.217,8.08 10.826,20.749 10.826,38.008l0,55.423l16.474,3.53l0,20.593l-65.661,0l0,-20.593l14.709,-3.53l0,-55.306c0,-8.55 -1.726,-14.61 -5.177,-18.18c-3.452,-3.569 -8.669,-5.354 -15.651,-5.354c-4.55,0 -8.629,0.922 -12.238,2.765c-3.608,1.844 -6.628,4.452 -9.06,7.826l0,68.249l13.885,3.53l0,20.593l-64.72,0l0,-20.593Z" style="fill:#008c99;fill-rule:nonzero;"/><path d="M475.638,511.491c-4.08,5.962 -9.12,10.551 -15.121,13.768c-6.001,3.216 -12.846,4.824 -20.534,4.824c-13.414,0 -23.926,-4.295 -31.536,-12.885c-7.609,-8.59 -11.414,-21.946 -11.414,-40.067l0,-52.6l-14.003,-3.53l0,-20.71l48.363,0l0,77.075c0,9.257 1.549,15.905 4.648,19.945c3.099,4.041 7.708,6.061 13.827,6.061c5.413,0 10.1,-0.883 14.061,-2.648c3.962,-1.765 7.198,-4.295 9.708,-7.59l0,-68.603l-15.062,-3.53l0,-20.71l49.423,0l0,103.198l15.415,3.53l0,20.593l-45.539,0l-2.236,-16.121Z" style="fill:#008c99;fill-rule:nonzero;"/><path d="M570.792,369.108l0,31.183l22.358,0l0,24.123l-22.358,0l0,64.837c0,4.942 1.02,8.472 3.059,10.59c2.04,2.119 4.786,3.178 8.237,3.178c2.354,0 4.413,-0.098 6.178,-0.295c1.765,-0.196 3.746,-0.529 5.943,-1l2.941,24.829c-3.844,1.177 -7.648,2.059 -11.414,2.648c-3.765,0.588 -7.845,0.882 -12.238,0.882c-11.845,0 -20.965,-3.256 -27.358,-9.767c-6.394,-6.511 -9.591,-16.827 -9.591,-30.947l0,-64.955l-18.709,0l0,-24.123l18.709,0l0,-31.183l34.243,0Z" style="fill:#008c99;fill-rule:nonzero;"/></g><path d="M443.348,0.858c2.329,0.009 4.657,0.043 6.984,0.111c4.608,0.135 9.211,0.391 13.805,0.77c14.091,1.162 28.088,3.482 41.789,6.977c24.76,6.315 48.578,16.481 70.015,30.421c3.101,2.016 6.15,4.111 9.144,6.283c3.296,2.392 6.525,4.878 9.677,7.456c3.591,2.937 7.084,5.994 10.467,9.168c6.53,6.126 12.651,12.689 18.274,19.658c6.401,7.932 12.154,16.391 17.12,25.294c5.592,10.027 10.181,20.615 13.596,31.578c2.211,7.098 3.929,14.348 5.128,21.684c0.991,6.061 1.627,12.179 1.906,18.314c0.399,8.774 0.07,17.582 -0.989,26.302c-0.898,7.404 -2.324,14.742 -4.254,21.945c-2.722,10.153 -6.448,20.03 -11.058,29.475c-4.026,8.248 -8.724,16.163 -13.993,23.677c-1.806,2.576 -3.68,5.105 -5.617,7.584c-12.75,16.324 -28.197,30.468 -45.288,42.141c-3.069,2.096 -6.191,4.113 -9.363,6.051c-22.127,13.521 -46.566,23.142 -71.853,28.809c-18.425,4.129 -37.312,6.164 -56.192,6.161c-18.665,-0.002 -37.332,-1.985 -55.558,-6.02c-26.059,-5.769 -51.233,-15.733 -73.918,-29.832c-3.256,-2.023 -6.459,-4.131 -9.604,-6.323c-6.208,-4.325 -12.189,-8.977 -17.896,-13.945c-1.826,-1.59 -3.624,-3.212 -5.393,-4.866c-0.64,-0.599 -1.277,-1.203 -1.91,-1.811c-0.224,-0.215 -0.445,-0.438 -0.675,-0.647c-0.068,-0.062 -0.138,-0.121 -0.21,-0.179c-0.277,-0.216 -0.578,-0.4 -0.9,-0.543c-0.854,-0.376 -1.828,-0.459 -2.732,-0.229c-0.405,0.102 -0.789,0.267 -1.146,0.482c-0.17,0.105 -0.338,0.212 -0.507,0.318c-0.363,0.227 -0.727,0.452 -1.092,0.677c-3.555,2.18 -7.182,4.24 -10.881,6.167c-3.862,2.011 -7.798,3.875 -11.794,5.603c-0.046,0.289 -0.095,0.578 -0.146,0.866c-0.38,2.093 -0.885,4.16 -1.446,6.211c-0.58,2.118 -1.22,4.22 -1.888,6.311c-1.638,5.125 -3.444,10.195 -5.264,15.257c-1.325,3.674 -2.663,7.344 -3.991,11.018c-1.058,2.933 -2.111,5.868 -3.132,8.815c-0.743,2.141 -1.47,4.287 -2.164,6.445c-0.595,1.848 -1.168,3.704 -1.688,5.575c-0.407,1.462 -0.789,2.934 -1.077,4.424c-0.085,0.44 -0.155,0.882 -0.223,1.325l-0.041,0.237c-0.104,0.542 -0.233,1.078 -0.402,1.605c-0.354,1.107 -0.861,2.164 -1.5,3.134c-1.141,1.73 -2.703,3.171 -4.52,4.167c-1.725,0.946 -3.664,1.485 -5.629,1.565c-1.232,0.05 -2.471,-0.08 -3.666,-0.384c-1.411,-0.359 -2.758,-0.961 -3.967,-1.772c-0.844,-0.566 -1.619,-1.233 -2.306,-1.982c-0.318,-0.348 -0.61,-0.716 -0.898,-1.088c-0.292,-0.377 -0.579,-0.757 -0.862,-1.14c-1.209,-1.637 -2.35,-3.323 -3.455,-5.031c-1.985,-3.063 -3.859,-6.197 -5.691,-9.353c-2.217,-3.819 -4.368,-7.677 -6.501,-11.544c-2.228,-4.041 -4.433,-8.095 -6.652,-12.14c-0.572,-1.04 -1.144,-2.08 -1.718,-3.119c-1.471,-2.653 -2.95,-5.302 -4.476,-7.923c-1.153,-1.98 -2.33,-3.948 -3.592,-5.86l-0.058,-0.088c-0.499,-0.002 -0.997,-0.006 -1.496,-0.01c-0.547,-0.007 -1.095,-0.015 -1.642,-0.025c-2.902,-0.059 -5.801,-0.174 -8.698,-0.356c-6.056,-0.381 -12.095,-1.041 -18.09,-1.981c-16.809,-2.638 -33.276,-7.495 -48.768,-14.542c-8.731,-3.972 -17.147,-8.637 -25.119,-13.971c-9.506,-6.36 -18.379,-13.674 -26.367,-21.862c-6.067,-6.22 -11.621,-12.944 -16.538,-20.108c-5.049,-7.356 -9.424,-15.177 -13.001,-23.352c-3.016,-6.894 -5.461,-14.039 -7.28,-21.342c-1.765,-7.088 -2.939,-14.321 -3.503,-21.604c-0.953,-12.314 -0.165,-24.757 2.345,-36.851c2.104,-10.14 5.415,-20.02 9.789,-29.406c3.839,-8.236 8.493,-16.087 13.824,-23.443c4.642,-6.404 9.795,-12.435 15.368,-18.046c4.976,-5.01 10.286,-9.686 15.87,-14.007c11.334,-8.773 23.786,-16.079 36.909,-21.832c10.483,-4.595 21.397,-8.2 32.542,-10.802c17.274,-4.033 35.099,-5.65 52.819,-4.917c10.221,0.422 20.41,1.634 30.44,3.65c11.709,2.353 23.201,5.801 34.251,10.336c5.382,2.209 10.658,4.675 15.802,7.394c1.659,0.877 3.305,1.781 4.935,2.711c0.542,0.309 1.082,0.621 1.62,0.936c0.283,0.165 0.565,0.334 0.85,0.497c0.102,0.056 0.204,0.112 0.307,0.167c0.912,0.471 1.878,0.826 2.882,1.041c1.312,0.28 2.672,0.325 3.999,0.134c1.107,-0.16 2.19,-0.484 3.203,-0.959c0.65,-0.304 1.27,-0.672 1.85,-1.094c0.314,-0.229 0.614,-0.474 0.904,-0.732c0.34,-0.308 0.678,-0.619 1.017,-0.929c1.905,-1.723 3.836,-3.416 5.802,-5.07c3.964,-3.335 8.053,-6.522 12.253,-9.556c2.827,-2.043 5.705,-4.018 8.627,-5.922c21.205,-13.817 44.749,-23.938 69.231,-30.286c13.586,-3.523 27.468,-5.888 41.449,-7.112c4.623,-0.405 9.256,-0.685 13.894,-0.842c2.467,-0.083 4.934,-0.129 7.403,-0.146c0.729,-0.003 1.459,-0.004 2.188,-0.003Zm-1.386,20.833c-1.594,0.007 -3.188,0.025 -4.781,0.061c-3.161,0.071 -6.32,0.204 -9.475,0.4c-9.918,0.616 -19.799,1.85 -29.56,3.715c-23.779,4.543 -46.883,12.841 -67.895,24.902c-2.942,1.689 -5.842,3.451 -8.695,5.286c-6.263,4.027 -12.3,8.407 -18.056,13.129c-1.789,1.467 -3.55,2.968 -5.282,4.501c-0.574,0.508 -1.146,1.02 -1.714,1.536c-0.369,0.336 -0.737,0.674 -1.107,1.01l-0.247,0.219c-0.742,0.646 -1.506,1.265 -2.302,1.845c-1.566,1.141 -3.236,2.139 -4.982,2.98c-3.332,1.604 -6.939,2.625 -10.618,3.01c-3.678,0.384 -7.418,0.13 -11.01,-0.751c-2.199,-0.54 -4.34,-1.312 -6.377,-2.301c-0.591,-0.287 -1.174,-0.592 -1.747,-0.915c-0.287,-0.161 -0.571,-0.329 -0.855,-0.496c-0.379,-0.223 -0.759,-0.443 -1.139,-0.663c-0.477,-0.274 -0.955,-0.546 -1.434,-0.816c-2.027,-1.136 -4.077,-2.23 -6.152,-3.277c-4.206,-2.123 -8.507,-4.057 -12.885,-5.8c-10.988,-4.375 -22.449,-7.547 -34.11,-9.517c-9.207,-1.554 -18.538,-2.36 -27.874,-2.437c-9.349,-0.077 -18.704,0.573 -27.949,1.972c-10.535,1.594 -20.926,4.161 -30.976,7.702c-13.981,4.926 -27.312,11.743 -39.372,20.374c-6.059,4.336 -11.793,9.128 -17.107,14.35c-4.787,4.704 -9.231,9.758 -13.255,15.129c-4.501,6.007 -8.473,12.413 -11.806,19.14c-2.471,4.987 -4.587,10.15 -6.313,15.442c-1.687,5.174 -2.997,10.47 -3.909,15.834c-1.497,8.799 -1.918,17.78 -1.262,26.681c0.53,7.189 1.767,14.323 3.684,21.272c1.514,5.49 3.45,10.862 5.767,16.064c1.896,4.256 4.048,8.397 6.43,12.402c1.993,3.351 4.146,6.606 6.444,9.756c1.922,2.635 3.946,5.196 6.061,7.678c1.87,2.196 3.812,4.33 5.819,6.4c1.738,1.792 3.524,3.537 5.356,5.233c13.022,12.052 28.282,21.599 44.633,28.447c15.085,6.317 31.106,10.339 47.363,12.077c4.65,0.498 9.321,0.809 13.996,0.936c1.471,0.041 2.943,0.063 4.415,0.067c0.797,0.002 1.594,-0.007 2.39,-0.008c0.23,0.003 0.23,0.003 0.459,0.009c0.383,0.016 0.765,0.04 1.147,0.081c0.904,0.096 1.799,0.27 2.674,0.519c2.466,0.703 4.75,2.006 6.611,3.772c0.444,0.421 0.863,0.868 1.256,1.338c0.355,0.425 0.689,0.868 1.018,1.313c0.405,0.549 0.798,1.108 1.182,1.672c1.293,1.899 2.496,3.859 3.67,5.834c0.994,1.671 1.965,3.356 2.922,5.048c1.343,2.373 2.665,4.758 3.981,7.146c2.21,4.022 4.405,8.052 6.615,12.074c1.883,3.421 3.779,6.835 5.717,10.225l0.293,0.512l0.236,0.41c0.27,-0.802 0.545,-1.601 0.82,-2.401c0.975,-2.817 1.975,-5.625 2.983,-8.431c1.471,-4.077 2.957,-8.149 4.427,-12.227c0.977,-2.716 1.948,-5.435 2.891,-8.163c0.731,-2.118 1.447,-4.241 2.129,-6.375c0.536,-1.677 1.052,-3.361 1.524,-5.057c0.405,-1.454 0.786,-2.918 1.074,-4.401c0.09,-0.468 0.163,-0.937 0.235,-1.408l0.055,-0.321c0.079,-0.423 0.165,-0.845 0.267,-1.263c0.231,-0.936 0.529,-1.855 0.892,-2.747c0.677,-1.663 1.58,-3.233 2.676,-4.654c1.031,-1.337 2.233,-2.542 3.567,-3.577c0.845,-0.655 1.742,-1.241 2.681,-1.753c0.475,-0.258 0.961,-0.492 1.453,-0.715c0.563,-0.244 1.127,-0.486 1.689,-0.733c1.533,-0.676 3.058,-1.373 4.57,-2.096c3.11,-1.487 6.171,-3.075 9.177,-4.764c1.542,-0.867 3.07,-1.761 4.582,-2.681c0.431,-0.261 0.859,-0.525 1.287,-0.791c0.346,-0.215 0.69,-0.433 1.037,-0.647c0.233,-0.14 0.232,-0.139 0.466,-0.277c0.624,-0.357 1.258,-0.693 1.908,-0.999c1.44,-0.676 2.944,-1.215 4.486,-1.605c2.855,-0.724 5.835,-0.937 8.764,-0.63c3.015,0.316 5.968,1.184 8.675,2.551c1.662,0.839 3.229,1.865 4.663,3.052c0.347,0.287 0.686,0.583 1.016,0.888c0.18,0.165 0.355,0.334 0.53,0.503c0.281,0.271 0.562,0.541 0.844,0.81c0.285,0.271 0.57,0.542 0.856,0.812c1.439,1.35 2.896,2.681 4.376,3.987c3.14,2.77 6.375,5.432 9.694,7.984c2.883,2.217 5.829,4.352 8.831,6.403c2.701,1.844 5.447,3.622 8.235,5.331c20.228,12.399 42.593,21.201 65.725,26.393c16.956,3.805 34.333,5.671 51.708,5.673c17.348,0.002 34.703,-1.863 51.634,-5.657c22.696,-5.086 44.653,-13.646 64.582,-25.671c2.884,-1.74 5.725,-3.553 8.517,-5.437c15.397,-10.389 29.357,-22.982 40.893,-37.561c1.624,-2.053 3.2,-4.144 4.724,-6.273c5.008,-6.996 9.457,-14.396 13.232,-22.129c3.801,-7.788 6.917,-15.911 9.253,-24.258c1.883,-6.728 3.258,-13.598 4.1,-20.534c0.877,-7.229 1.177,-14.528 0.901,-21.806c-0.233,-6.186 -0.887,-12.356 -1.954,-18.454c-0.967,-5.526 -2.273,-10.993 -3.902,-16.362c-2.916,-9.61 -6.87,-18.896 -11.702,-27.698c-4.249,-7.74 -9.174,-15.104 -14.652,-22.027c-4.951,-6.258 -10.355,-12.156 -16.124,-17.667c-5.125,-4.896 -10.54,-9.487 -16.191,-13.764c-2.951,-2.233 -5.967,-4.381 -9.041,-6.442c-2.8,-1.878 -5.647,-3.684 -8.538,-5.417c-20.324,-12.187 -42.737,-20.78 -65.885,-25.773c-10.53,-2.271 -21.219,-3.801 -31.962,-4.601c-3.598,-0.268 -7.202,-0.454 -10.809,-0.56c-1.714,-0.05 -3.427,-0.079 -5.141,-0.095c-0.874,-0.006 -1.748,-0.008 -2.621,-0.007Z" style="fill:#767676;fill-rule:nonzero;"/><path d="M267.017,298.075c5.743,-3.668 13.259,-2.88 18.116,1.9c38.217,36.942 94.631,60.326 157.514,60.326c114.993,0 208.353,-78.197 208.353,-174.514c0,-96.317 -93.36,-174.513 -208.353,-174.513c-61.005,0 -115.922,22.007 -154.04,57.053c-7.063,6.468 -17.522,7.56 -25.769,2.692c-25.816,-15.241 -57.044,-24.13 -90.661,-24.13c-88.956,0 -161.177,62.238 -161.177,138.898c0,76.66 72.221,138.898 161.177,138.898c0.587,0 1.174,-0.003 1.759,-0.008c1.712,-0.015 3.334,0.763 4.393,2.107c7.296,9.258 24.677,45.814 34.622,58.435c0.584,0.74 1.552,1.062 2.462,0.818c0.91,-0.244 1.588,-1.007 1.723,-1.94c2.059,-14.22 19.017,-52.406 21.062,-66.532c0.477,-3.287 2.636,-6.087 5.694,-7.383c8.123,-3.478 15.854,-7.537 23.125,-12.107Z" style="fill:#fffefb;"/><g><path d="M412.356,310.721c-3.895,-0.398 -7.532,1.999 -8.703,5.735c-1.115,3.542 -2.29,7.066 -3.525,10.568c-0.297,0.836 -0.198,1.761 0.268,2.515c0.466,0.754 1.249,1.256 2.128,1.365c0,0.001 0.001,0.001 0.001,0.001c11.339,1.407 22.753,2.201 34.177,2.405c0.837,0.014 1.596,-0.49 1.907,-1.267c0.001,0 0.001,-0.001 0.001,-0.001c1.852,-4.626 3.586,-9.3 5.204,-14.013c0.001,-0.001 0.001,-0.001 0.001,-0.002c0.459,-1.337 0.248,-2.813 -0.568,-3.968c-0.816,-1.155 -2.137,-1.848 -3.551,-1.862c-0.438,-0.004 -0.877,-0.009 -1.315,-0.015c-8.691,-0.119 -17.377,-0.602 -26.025,-1.461Z" style="fill:#faf3d2;stroke:#e9e9e9;stroke-width:1px;"/><path d="M463.661,321.235c-0.874,2.638 -0.359,5.539 1.369,7.716c1.728,2.177 4.437,3.336 7.205,3.083c2.84,-0.257 5.677,-0.551 8.509,-0.884c6.407,-0.754 12.792,-1.702 19.14,-2.851c2.88,-0.527 5.264,-2.543 6.264,-5.295c0.601,-1.653 1.186,-3.312 1.758,-4.975c0.126,-0.369 0.252,-0.737 0.377,-1.106c0.886,-2.607 0.317,-5.489 -1.493,-7.565c-1.81,-2.075 -4.587,-3.03 -7.291,-2.507c0,0 0,0 0,0c-10.11,1.957 -20.325,3.362 -30.584,4.242c0,0 0,0 0,0c-1.282,0.11 -2.367,0.99 -2.739,2.221c-0.805,2.651 -1.643,5.291 -2.515,7.921Z" style="fill:#faf3d2;stroke:#e9e9e9;stroke-width:1px;"/><path d="M345.36,295.717c-0.889,-0.325 -1.874,-0.257 -2.711,0.186c-0.837,0.442 -1.447,1.219 -1.678,2.137c-0.573,2.265 -1.169,4.523 -1.788,6.776c-0.247,0.899 -0.498,1.797 -0.753,2.694c-1.196,4.223 1.127,8.643 5.283,10.053c0.454,0.154 0.909,0.308 1.364,0.46c7.815,2.612 15.748,4.872 23.761,6.794c1.011,0.242 2.024,0.48 3.037,0.712c4.09,0.938 8.233,-1.345 9.623,-5.304c0.258,-0.731 0.512,-1.463 0.764,-2.196c0.268,-0.783 0.534,-1.567 0.796,-2.352c0.741,-2.208 0.512,-4.626 -0.628,-6.657c-1.14,-2.03 -3.085,-3.484 -5.356,-4.001c-1.102,-0.25 -2.203,-0.507 -3.302,-0.771c-9.62,-2.308 -19.117,-5.138 -28.411,-8.531c0,0 -0.001,0 -0.001,0Z" style="fill:#faf3d2;stroke:#e9e9e9;stroke-width:1px;"/><path d="M532.071,307.161c-0.832,2.954 0.046,6.125 2.278,8.231c2.231,2.106 5.448,2.798 8.348,1.796c5.319,-1.842 10.582,-3.844 15.773,-6.019c3.188,-1.336 6.35,-2.737 9.48,-4.205c2.017,-0.949 3.563,-2.674 4.287,-4.783c2.056,-6.043 3.888,-12.16 5.504,-18.334c0.307,-1.186 -0.125,-2.439 -1.096,-3.185c-0.971,-0.745 -2.294,-0.837 -3.359,-0.234c-0.002,-0.001 -0.002,0 -0.003,0c-9.836,5.569 -20.134,10.307 -30.703,14.305c-1.283,0.486 -2.569,0.96 -3.859,1.423c-2.55,0.916 -4.487,3.026 -5.181,5.644c-0.267,1.007 -0.539,2.012 -0.815,3.016c-0.215,0.782 -0.433,1.564 -0.654,2.345Z" style="fill:#faf3d2;stroke:#e9e9e9;stroke-width:1px;"/><path d="M301.19,273.826c-0.376,-0.246 -0.855,-0.269 -1.253,-0.06c-0.397,0.209 -0.649,0.618 -0.658,1.067c-0.007,0.324 -0.013,0.648 -0.02,0.972c-0.112,5.474 -0.245,10.948 -0.407,16.421c-0.092,3.073 1.533,5.942 4.215,7.443c1.911,1.059 3.835,2.093 5.774,3.099c2.216,1.15 4.833,1.233 7.117,0.227c2.284,-1.006 3.989,-2.994 4.636,-5.404c0.736,-2.735 1.433,-5.481 2.094,-8.235c0.409,-1.714 -0.413,-3.485 -1.986,-4.279c0,-0.001 0,-0.001 -0.001,-0.001c-6.705,-3.384 -13.233,-7.124 -19.511,-11.249c0,0 0,0 0,-0.001Z" style="fill:#faf3d2;stroke:#e9e9e9;stroke-width:1px;"/><path d="M177.105,303.349c0.367,1.265 1.552,2.115 2.868,2.057c0.001,0 0.001,0 0.001,0c1.592,-0.071 3.184,-0.164 4.775,-0.271c1.87,-0.126 3.739,-0.272 5.606,-0.435c2.531,-0.222 5.061,-0.476 7.585,-0.765c2.404,-0.276 4.805,-0.584 7.199,-0.934c1.328,-0.193 2.653,-0.402 3.978,-0.62c1.646,-0.27 3.291,-0.554 4.933,-0.852c0,0 0,0 0,0c0.617,-0.112 1.161,-0.475 1.5,-1.004c0.339,-0.528 0.442,-1.174 0.286,-1.782c-1.183,-4.634 -2.269,-9.293 -3.26,-13.972c-0.502,-2.389 -2.802,-3.953 -5.207,-3.543c-0.001,0 -0.001,0 -0.001,0c-1.866,0.318 -3.736,0.62 -5.61,0.89c-2.071,0.299 -4.148,0.564 -6.227,0.802c-2.337,0.268 -4.678,0.503 -7.021,0.708c-2.404,0.211 -4.811,0.391 -7.221,0.53c-1.017,0.059 -2.035,0.11 -3.054,0.15c-0.769,0.029 -1.537,0.053 -2.306,0.058c-0.003,0 -0.006,0 -0.008,0c0,0 0,0 0,0c-0.003,-0.001 -0.005,-0.002 -0.008,-0.002c-0.284,-0.057 -0.361,-0.076 -0.646,-0.121c-0.282,-0.044 -0.567,-0.078 -0.852,-0.102c-0.631,-0.052 -1.267,-0.052 -1.898,-0.006c0,0 0,0 0,0c-0.078,0.006 -0.149,0.045 -0.196,0.108c-0.046,0.062 -0.063,0.142 -0.046,0.218c1.421,6.343 3.028,12.643 4.83,18.888Z" style="fill:#faf3d2;stroke:#e9e9e9;stroke-width:1px;"/><path d="M123.759,278.988c-2.546,-0.572 -5.207,0.208 -7.041,2.063c-1.835,1.855 -2.585,4.525 -1.985,7.064c0.496,2.09 1.009,4.175 1.544,6.256c0.785,3.03 3.219,5.355 6.283,5.999c4.186,0.872 8.396,1.628 12.623,2.27c3.322,0.504 6.653,0.939 9.993,1.304c2.666,0.292 5.308,-0.731 7.082,-2.743c1.773,-2.012 2.457,-4.761 1.832,-7.369c-0.374,-1.566 -0.738,-3.135 -1.092,-4.705c-0.767,-3.43 -3.623,-5.996 -7.114,-6.392c-7.434,-0.864 -14.823,-2.108 -22.124,-3.747c-0.001,0 -0.001,0 -0.001,0Z" style="fill:#faf3d2;stroke:#e9e9e9;stroke-width:1px;"/><path d="M471.336,294.34c-0.188,0.776 0.005,1.597 0.521,2.207c0.516,0.611 1.292,0.939 2.09,0.883c0,0 0,0 0.001,0c10.231,-0.721 20.439,-1.803 30.59,-3.273c1.837,-0.266 3.672,-0.545 5.505,-0.836c3.306,-0.526 5.966,-2.999 6.73,-6.258c0.719,-3.098 1.394,-6.206 2.026,-9.323c0.538,-2.664 -0.272,-5.422 -2.165,-7.372c-1.893,-1.951 -4.626,-2.842 -7.305,-2.383c-9.829,1.656 -19.727,2.907 -29.654,3.791c0,0 0,0 0,0c-2.196,0.196 -3.991,1.832 -4.389,4c-1.151,6.221 -2.466,12.413 -3.95,18.564Z" style="fill:#faf3d2;stroke:#e9e9e9;stroke-width:1px;"/><path d="M234.696,292.438c0.296,1.172 1.05,2.175 2.094,2.785c1.043,0.61 2.288,0.774 3.453,0.456c0,0.001 0.001,0.001 0.001,0.001c1.512,-0.413 3.019,-0.842 4.515,-1.31c0.534,-0.167 1.065,-0.341 1.592,-0.527c0.462,-0.162 0.922,-0.334 1.373,-0.525c0.216,-0.092 0.431,-0.187 0.643,-0.289c0.058,-0.028 0.116,-0.057 0.174,-0.086c0.064,-0.031 0.127,-0.064 0.19,-0.097c0.24,-0.127 0.48,-0.255 0.72,-0.381c0.007,-0.004 0.014,-0.007 0.021,-0.011c2.62,-1.351 5.378,-2.408 8.141,-3.425l0.007,-0.002c1.006,-0.369 1.684,-1.313 1.713,-2.383c0.005,-0.174 0.009,-0.347 0.014,-0.521c0.149,-5.635 0.27,-11.271 0.371,-16.907c0,0 0,0 0,0c0.014,-0.795 -0.367,-1.545 -1.016,-2.003c-0.65,-0.459 -1.485,-0.566 -2.229,-0.286c-0.209,0.079 -0.418,0.157 -0.628,0.235c-1.705,0.634 -3.42,1.244 -5.129,1.867c-0.004,0.001 -0.007,0.003 -0.01,0.004c-0.384,0.141 -0.768,0.282 -1.152,0.424c-0.006,0.002 -0.011,0.004 -0.016,0.006c-1.827,0.681 -3.645,1.385 -5.436,2.156c-1.474,0.634 -2.928,1.314 -4.354,2.051c-0.306,0.159 -0.625,0.293 -0.954,0.4c0,0 0,0 0,0c-0.003,0.001 -0.006,0.002 -0.009,0.003c-1.357,0.438 -2.731,0.825 -4.107,1.2c0,0 0,0 0,0c-2.033,0.554 -3.284,2.595 -2.855,4.659c0.877,4.187 1.834,8.357 2.873,12.506Z" style="fill:#faf3d2;stroke:#e9e9e9;stroke-width:1px;"/><path d="M389.106,295.278c9.436,1.167 20.099,1.996 20.099,1.996c10.874,0.82 21.779,1.23 32.684,1.248c0.516,0.001 1.033,0.001 1.549,0c3.773,-0.005 7.061,-2.57 7.983,-6.229c0.736,-2.952 1.432,-5.913 2.088,-8.884c0.538,-2.447 -0.067,-5.006 -1.644,-6.954c-1.576,-1.948 -3.953,-3.073 -6.458,-3.057c-3.297,0.02 -6.593,0.002 -9.889,-0.053c-7.034,-0.117 -14.065,-0.408 -21.084,-0.879c-0.069,-0.005 -0.137,-0.01 -0.205,-0.017l-19.61,-1.81c-0.068,-0.008 -0.137,-0.015 -0.206,-0.021c-1.823,-0.215 -3.645,-0.443 -5.464,-0.684c-7.909,-1.046 -15.785,-2.34 -23.609,-3.901c-3.827,-0.764 -7.641,-1.592 -11.439,-2.489c-1.49,-0.354 -3.06,-0.072 -4.334,0.778c-1.273,0.849 -2.137,2.19 -2.383,3.702c0,0 0,0 0,0c-0.617,3.789 -1.294,7.568 -2.031,11.336c-0.834,4.249 1.862,8.391 6.085,9.347c0,0.002 0,0.002 0.001,0.002c9.54,2.162 19.169,3.932 28.847,5.35c3.002,0.44 6.009,0.846 9.02,1.219Z" style="fill:#faf3d2;stroke:#e9e9e9;stroke-width:1px;"/><path d="M179.538,285.843c0.05,0.029 0.099,0.06 0.147,0.093c0.061,0.043 0.139,0.097 0.139,0.097c0,0 -0.002,-0.001 -0.006,-0.004c-0.072,-0.05 -0.145,-0.098 -0.22,-0.144c-0.026,-0.017 -0.053,-0.034 -0.075,-0.048c-0.001,0 -0.001,-0.001 -0.001,-0.002c0.001,0 0.001,0 0.002,0c0.005,0.003 0.009,0.005 0.014,0.008Z" style="fill:#faf3d2;stroke:#e9e9e9;stroke-width:1px;"/><path d="M170.873,277.894c0.022,0.106 0.115,0.182 0.223,0.183c0,0 0,0 0,0c0.18,0 0.36,0.001 0.54,0.001c0.198,0 0.647,0.003 0.899,-0.003c0.097,-0.002 0.193,-0.007 0.289,-0.01c0.018,-0.001 0.035,-0.002 0.053,-0.003c0,0 0,0 0,0c0.04,-0.002 0.08,-0.001 0.12,0.003l0.16,0.014c0.195,0.016 0.203,0.016 0.383,0.029c0.032,0.002 0.063,0.004 0.095,0.006c0.977,0.054 1.956,0.055 2.935,0.044c1.114,-0.012 2.228,-0.041 3.342,-0.077c3.225,-0.105 6.449,-0.272 9.67,-0.472c2.736,-0.171 5.471,-0.369 8.203,-0.598c2.389,-0.201 4.776,-0.425 7.159,-0.679c0,0 0.001,0 0.001,0c1.504,-0.161 2.875,-0.936 3.788,-2.142c0.913,-1.206 1.287,-2.735 1.033,-4.226c-0.805,-4.776 -1.514,-9.568 -2.131,-14.371c-0.335,-2.635 -2.716,-4.519 -5.357,-4.237c0,0 0,0 0,0c-4.335,0.462 -8.681,0.819 -13.031,1.105c-2.624,0.172 -5.25,0.318 -7.878,0.429c-1.026,0.043 -2.053,0.082 -3.081,0.11c-0.823,0.024 -1.647,0.041 -2.472,0.045c-0.004,0 -0.008,0 -0.012,0c0,0 0,0 0,0c-0.02,0 -0.041,-0.002 -0.061,-0.005c-0.002,-0.001 -0.004,-0.001 -0.006,-0.002c-0.062,-0.01 -0.124,-0.02 -0.186,-0.029c-0.04,-0.006 -0.087,-0.013 -0.126,-0.019c-0.068,-0.01 -0.137,-0.019 -0.205,-0.027c-0.38,-0.046 -0.76,-0.083 -1.142,-0.099c-0.488,-0.022 -0.975,-0.017 -1.462,0.009c-0.3,0.016 -0.598,0.043 -0.897,0.074c-0.004,0 -0.009,0.001 -0.014,0.001c-0.01,0.001 -0.028,0.003 -0.046,0.005c-0.037,0.005 -0.075,0.007 -0.112,0.006c-0.001,0.001 -0.001,0.001 -0.001,0.001c-1.21,-0.004 -2.362,0.519 -3.157,1.431c-0.795,0.912 -1.156,2.124 -0.988,3.322c0.96,6.759 2.114,13.491 3.472,20.181Z" style="fill:#faf3d2;stroke:#e9e9e9;stroke-width:1px;"/><path d="M109.865,208.992c-1.133,-0.14 -2.272,0.22 -3.12,0.985c-0.848,0.765 -1.321,1.861 -1.298,3.003c0,0.001 0,0.001 0,0.002c0.097,4.715 0.279,9.429 0.549,14.138c0.231,4.033 0.526,8.062 0.887,12.086c0.98,10.907 2.443,21.778 4.424,32.552c0.077,0.421 0.405,0.75 0.825,0.83c0,0 0.001,0 0.001,0c6.532,1.241 13.107,2.258 19.707,3.066c2.654,0.326 5.312,0.617 7.973,0.875c2.543,0.249 5.058,-0.697 6.808,-2.559c1.75,-1.863 2.537,-4.431 2.131,-6.955c-0.458,-2.86 -0.882,-5.726 -1.273,-8.596c-0.508,-3.771 -3.53,-6.704 -7.315,-7.099c-2.068,-0.216 -4.134,-0.453 -6.198,-0.713c-8.511,-1.07 -16.978,-2.517 -25.35,-4.391c-0.001,-0.001 -0.002,-0.001 -0.003,-0.001c-0.023,-0.006 -0.038,-0.029 -0.033,-0.053c0.004,-0.023 0.026,-0.039 0.05,-0.037c6.968,0.811 13.954,1.467 20.949,1.987c2.365,0.176 4.731,0.336 7.098,0.481c2.394,0.148 4.734,-0.755 6.408,-2.472c1.675,-1.718 2.519,-4.079 2.312,-6.469c-0.342,-3.946 -0.623,-7.897 -0.845,-11.851c-0.269,-4.8 -0.452,-9.605 -0.551,-14.412c0,0 0,0 0,0c-0.017,-0.822 -0.665,-1.492 -1.485,-1.537c-0.263,-0.014 -0.526,-0.028 -0.788,-0.043c-8.878,-0.496 -17.745,-1.216 -26.582,-2.198c-1.762,-0.196 -3.522,-0.402 -5.281,-0.619Z" style="fill:#faf3d2;stroke:#e9e9e9;stroke-width:1px;"/><path d="M253.15,165.338c1.702,0.194 3.406,-0.354 4.676,-1.503c1.27,-1.15 1.985,-2.79 1.962,-4.503c-0.083,-6.178 -0.181,-12.355 -0.295,-18.532c-0.152,-8.255 -0.332,-16.509 -0.549,-24.763c-0.182,-6.951 -0.391,-13.901 -0.639,-20.85c-0.141,-3.926 -0.293,-7.852 -0.466,-11.777c-0.038,-0.865 -0.582,-1.626 -1.388,-1.942c0,0 0,0 0,0c-1.202,-0.471 -2.409,-0.93 -3.619,-1.379c-2.022,-0.751 -4.263,-0.643 -6.204,0.297c-1.941,0.941 -3.414,2.634 -4.077,4.686c-0.001,0 -0.001,0 -0.001,0.001c-0.951,2.942 -1.859,5.899 -2.727,8.867c-0.589,2.022 0.507,4.151 2.495,4.846c0,0 0,0 0,0c3.667,1.281 7.293,2.677 10.87,4.192c1.167,0.495 2.33,1.002 3.487,1.523c0,0 0.001,0.001 0.002,0.001c0.071,0.034 0.105,0.116 0.077,0.19c-0.028,0.074 -0.107,0.114 -0.183,0.092c-0.285,-0.082 -0.57,-0.164 -0.855,-0.245c-4.579,-1.306 -9.195,-2.481 -13.839,-3.534c-2.133,-0.481 -4.264,0.817 -4.816,2.933c0,0 0,0.001 0,0.001c-1.601,6.14 -3.042,12.322 -4.331,18.536c-0.245,1.183 0.509,2.344 1.689,2.602c0.001,0 0.003,0 0.004,0.001c0.057,0.015 0.093,0.071 0.083,0.13c-0.011,0.058 -0.065,0.098 -0.124,0.091c-0.001,0 -0.001,0 -0.001,0c-1.233,-0.14 -2.366,0.691 -2.603,1.908c-0.395,2.029 -0.775,4.061 -1.138,6.095c-1.193,6.674 -2.218,13.378 -3.075,20.103c-0.274,2.171 0.327,4.361 1.67,6.089c1.342,1.727 3.317,2.85 5.488,3.121c2.181,0.272 4.359,0.56 6.536,0.866c3.927,0.552 7.846,1.162 11.754,1.838c0.045,0.008 0.09,0.014 0.136,0.019c0,0 0.001,0 0.001,0Z" style="fill:#faf3d2;stroke:#e9e9e9;stroke-width:1px;"/><path d="M427.59,224.129c-4.412,-0.09 -8.113,3.311 -8.396,7.715c-0.442,6.692 -1.055,13.372 -1.844,20.031c-0.279,2.309 0.43,4.629 1.953,6.386c1.523,1.758 3.717,2.791 6.042,2.844c5.996,0.134 11.994,0.196 17.991,0.191c2.406,-0.002 4.811,-0.015 7.216,-0.039c4.103,-0.041 7.551,-3.092 8.09,-7.159c0.65,-4.95 1.196,-9.913 1.643,-14.884c0.361,-4.024 0.656,-8.053 0.887,-12.086c0,-0.001 0,-0.001 0,-0.001c0.046,-0.793 -0.242,-1.568 -0.793,-2.14c-0.552,-0.571 -1.316,-0.886 -2.11,-0.869c-5.925,0.123 -11.851,0.176 -17.777,0.159c-4.301,-0.013 -8.602,-0.061 -12.902,-0.148Z" style="fill:#faf3d2;stroke:#e9e9e9;stroke-width:1px;"/><path d="M478.639,254.048c-0.203,1.604 0.316,3.216 1.418,4.4c1.102,1.185 2.673,1.818 4.288,1.731c0,0.001 0,0.001 0,0.001c10.51,-0.57 21.009,-1.363 31.482,-2.41c3.832,-0.388 6.884,-3.378 7.352,-7.201c0.458,-3.779 0.856,-7.565 1.197,-11.355c0.361,-4.024 0.656,-8.053 0.887,-12.086c0,-0.001 0,-0.001 0,-0.001c0.109,-1.903 -0.625,-3.757 -2.007,-5.07c-1.382,-1.312 -3.272,-1.95 -5.167,-1.742c-1.314,0.144 -2.628,0.284 -3.942,0.419c-8.518,0.879 -17.054,1.58 -25.601,2.12c-4.154,0.258 -7.464,3.572 -7.717,7.726c-0.493,7.843 -1.22,15.67 -2.19,23.468Z" style="fill:#faf3d2;stroke:#e9e9e9;stroke-width:1px;"/><path d="M360.797,219.576c-2.267,-0.276 -4.547,0.402 -6.296,1.871c-1.749,1.468 -2.811,3.597 -2.931,5.878c-0.366,6.686 -0.9,13.363 -1.609,20.021c-0.489,4.49 2.728,8.538 7.213,9.075c3.421,0.411 6.847,0.791 10.275,1.144c7.031,0.725 14.073,1.334 21.123,1.838c4.364,0.308 8.208,-2.845 8.759,-7.185c0.545,-4.326 1.011,-8.662 1.401,-13.004c0.361,-4.024 0.656,-8.053 0.887,-12.086c0,0 0,0 0,-0.001c0.129,-2.255 -1.586,-4.192 -3.841,-4.336c-7.129,-0.461 -14.251,-1.034 -21.362,-1.729c-4.545,-0.444 -9.085,-0.938 -13.619,-1.486Z" style="fill:#faf3d2;stroke:#e9e9e9;stroke-width:1px;"/><path d="M179.126,254.072c0.066,0.028 0.131,0.058 0.195,0.09c0.068,0.035 0.148,0.076 0.148,0.076c0,0 0,0 0,0c-0.085,-0.043 -0.17,-0.084 -0.257,-0.123c-0.03,-0.014 -0.061,-0.028 -0.087,-0.04c-0.001,-0.001 -0.001,-0.001 -0.001,-0.002c0.001,-0.001 0.001,-0.001 0.002,-0.001c0,0 0,0 0,0Z" style="fill:#faf3d2;stroke:#e9e9e9;stroke-width:1px;"/><path d="M178.967,213.337c0.065,0.017 0.129,0.035 0.192,0.055c0.014,0.005 0.028,0.009 0.04,0.013c0.001,0 0.001,0.001 0.001,0.001c0,0 -0.001,0 -0.001,0c-0.06,-0.017 -0.174,-0.049 -0.259,-0.074c-0.001,0 -0.001,0 -0.001,-0.001c0,-0.001 0.001,-0.001 0.001,-0.001c0.009,0.002 0.018,0.005 0.027,0.007Z" style="fill:#faf3d2;stroke:#e9e9e9;stroke-width:1px;"/><path d="M177.904,213.065c0.05,0.01 0.099,0.021 0.147,0.033c0.018,0.005 0.038,0.01 0.059,0.016c0.001,0 0.002,0.001 0.001,0.002c0,0.001 -0.001,0.001 -0.002,0.001c-0.072,-0.017 -0.149,-0.035 -0.193,-0.046c-0.026,-0.006 -0.051,-0.012 -0.077,-0.017c-0.014,-0.003 -0.026,-0.005 -0.026,-0.005c0.03,0.005 0.061,0.011 0.091,0.016Z" style="fill:#faf3d2;stroke:#e9e9e9;stroke-width:1px;"/><path d="M459.924,166.022c-0.202,-2.093 -1.957,-3.693 -4.06,-3.701c-3.505,-0.011 -7.01,-0.018 -10.515,-0.022c-0.002,0 -0.004,0 -0.006,0c-1.376,-0.001 -2.752,-0.001 -4.128,-0.001c-0.001,0 -0.002,0 -0.003,0c-4.765,0.003 -9.529,0.014 -14.294,0.034c-2.293,0.009 -4.479,0.974 -6.032,2.662c-1.553,1.687 -2.332,3.946 -2.151,6.232c0.128,1.606 0.247,3.212 0.356,4.82c0.697,10.201 1.03,20.427 0.986,30.653c-0.002,0.604 -0.006,1.208 -0.012,1.813c-0.001,0.184 0.071,0.362 0.2,0.494c0.13,0.131 0.306,0.206 0.491,0.207c0,0 0,0 0,0c11.768,0.068 23.537,0.081 35.305,0.039c0,0 0,0 0.001,0c3.18,-0.011 5.749,-2.597 5.74,-5.777c-0.013,-3.447 -0.07,-6.894 -0.172,-10.34c-0.267,-9.053 -0.838,-18.097 -1.706,-27.112c0,0 0,-0.001 0,-0.001Z" style="fill:#faf3d2;stroke:#e9e9e9;stroke-width:1px;"/><path d="M398.371,166.022c-0.188,-1.955 -1.844,-3.44 -3.808,-3.414c-9.284,0.121 -18.568,0.281 -27.851,0.482c-2.595,0.057 -5.19,0.116 -7.784,0.18c-2.261,0.055 -4.4,1.036 -5.916,2.714c-1.517,1.678 -2.277,3.905 -2.104,6.159c0.101,1.301 0.196,2.601 0.285,3.903c0.697,10.201 1.03,20.427 0.986,30.653c0,0 0,0 0,0c-0.004,0.797 0.63,1.45 1.426,1.471c9.366,0.246 18.733,0.444 28.101,0.603c3.388,0.058 6.776,0.11 10.164,0.157c2.222,0.031 4.362,-0.836 5.936,-2.405c1.573,-1.569 2.447,-3.707 2.422,-5.929c-0.027,-2.487 -0.077,-4.975 -0.151,-7.461c-0.267,-9.053 -0.838,-18.097 -1.706,-27.112c0,0 0,-0.001 0,-0.001Z" style="fill:#faf3d2;stroke:#e9e9e9;stroke-width:1px;"/><path d="M553.013,164.05c-2.341,-0.08 -4.606,0.839 -6.229,2.529c-1.623,1.69 -2.45,3.991 -2.275,6.327c0.079,1.046 0.155,2.093 0.226,3.14c0.697,10.201 1.03,20.427 0.986,30.653c0,0 0,0 0,0c-0.001,0.279 0.111,0.547 0.311,0.741c0.2,0.195 0.471,0.3 0.75,0.291c6.997,-0.224 13.993,-0.478 20.988,-0.769c4.721,-0.197 9.443,-0.41 14.163,-0.645c3.117,-0.156 5.552,-2.749 5.513,-5.87c0,0 0,0 0,0c-0.1,-7.832 -0.46,-15.66 -1.072,-23.469c-0.126,-1.607 -0.262,-3.214 -0.41,-4.82c-0.353,-3.865 -3.501,-6.879 -7.378,-7.064c0,0 -0.001,0 -0.001,0c-8.521,-0.406 -17.045,-0.749 -25.572,-1.044Z" style="fill:#faf3d2;stroke:#e9e9e9;stroke-width:1px;"/><path d="M299.79,198.32c0.017,4.39 3.47,7.997 7.855,8.204c3.695,0.174 7.391,0.336 11.087,0.488c1.671,0.068 3.342,0.135 5.013,0.199c2.263,0.088 4.461,-0.759 6.081,-2.342c1.619,-1.582 2.516,-3.761 2.481,-6.025c-0.03,-1.903 -0.072,-3.806 -0.128,-5.709c-0.267,-9.053 -0.838,-18.097 -1.706,-27.112c0,0 0,0 0,0c-0.103,-1.069 -1.021,-1.872 -2.094,-1.834c-6.754,0.246 -13.507,0.522 -20.258,0.838c-0.741,0.035 -1.483,0.07 -2.224,0.106c-3.552,0.17 -6.334,3.119 -6.297,6.675c0,0.001 0,0.001 0,0.001c0.091,8.837 0.155,17.674 0.19,26.511Z" style="fill:#faf3d2;stroke:#e9e9e9;stroke-width:1px;"/><path d="M163.749,206.794c0,0.058 0.047,0.104 0.104,0.104c0,0 0.001,0 0.001,0c2.077,0.007 4.155,0.01 6.233,0.012c0.747,0 1.495,0.002 2.242,0c0.014,0 0.028,0 0.041,0c0.293,-0.002 0.586,-0.007 0.879,-0.011c0.157,-0.001 0.156,-0.001 0.314,0.006l0.193,0.005c0.032,0.001 0.064,0.001 0.097,0.002c0.191,0.002 0.382,0.004 0.573,0.006c0.01,0 0.02,0 0.029,0c0.665,0.002 1.329,0.002 1.993,0.002c0.002,0 0.005,0 0.007,0c4.355,-0.007 8.71,-0.034 13.065,-0.066c4.517,-0.033 9.033,-0.075 13.549,-0.13c0,0 0.214,-0.003 0.472,-0.006c0.502,-0.006 0.905,-0.415 0.904,-0.917c0,0 0,0 0,0c-0.01,-4.42 0.051,-8.84 0.182,-13.258c0.185,-6.308 0.512,-12.611 0.978,-18.905c0.171,-2.273 -0.608,-4.516 -2.151,-6.195c-1.542,-1.679 -3.712,-2.644 -5.992,-2.665c-9.819,-0.091 -19.64,-0.126 -29.46,-0.111c0,0 -0.421,0 -0.899,0.001c-0.766,0.002 -1.406,0.584 -1.479,1.346c0,0 0,0.001 0,0.001c-0.868,9.015 -1.439,18.059 -1.706,27.112c-0.134,4.554 -0.191,9.111 -0.169,13.667Z" style="fill:#faf3d2;stroke:#e9e9e9;stroke-width:1px;"/><path d="M105.426,197.891c-0.082,4.537 3.518,8.287 8.054,8.391c7.377,0.165 14.755,0.294 22.133,0.391c4.544,0.058 8.279,-3.571 8.35,-8.115c0.025,-1.713 0.062,-3.425 0.108,-5.137c0.18,-6.565 0.513,-13.125 0.995,-19.674c0.173,-2.305 -0.63,-4.577 -2.213,-6.262c-1.582,-1.684 -3.8,-2.627 -6.111,-2.597c-4.228,0.053 -8.456,0.117 -12.684,0.192c-5.393,0.097 -10.786,0.21 -16.179,0.344c-0.33,0.008 -0.603,0.261 -0.635,0.591c0,0 0,0 0,0c-0.868,9.015 -1.439,18.059 -1.706,27.112c-0.047,1.588 -0.084,3.176 -0.112,4.764Z" style="fill:#faf3d2;stroke:#e9e9e9;stroke-width:1px;"/><path d="M108.323,156.08c-0.195,1.631 0.367,3.262 1.526,4.428c1.159,1.165 2.786,1.737 4.419,1.553c0,0 0,0 0,0c5.699,-0.644 11.411,-1.179 17.129,-1.615c2.685,-0.204 5.371,-0.387 8.058,-0.55c3.973,-0.239 7.208,-3.282 7.688,-7.234c0.975,-7.909 2.17,-15.792 3.587,-23.634c0,-0.001 0,-0.001 0,-0.002c0.299,-1.653 -0.172,-3.353 -1.279,-4.617c-1.107,-1.264 -2.729,-1.955 -4.408,-1.877c-2.133,0.099 -4.265,0.209 -6.397,0.332c-6.4,0.369 -12.794,0.848 -19.176,1.448c-3.668,0.349 -6.659,3.09 -7.326,6.713c-0.141,0.759 -0.279,1.518 -0.414,2.277c-1.351,7.558 -2.486,15.155 -3.407,22.778Z" style="fill:#faf3d2;stroke:#e9e9e9;stroke-width:1px;"/><path d="M179.162,121.951c-3.993,-0.045 -7.445,2.777 -8.193,6.7c-0.296,1.549 -0.582,3.099 -0.859,4.651c-1.297,7.256 -2.395,14.548 -3.296,21.864c-0.116,0.956 0.184,1.917 0.824,2.637c0.64,0.72 1.559,1.131 2.523,1.128c0,0 0,0 0,0c9.653,-0.035 19.307,0.175 28.948,0.65c4.321,0.22 8.077,-2.937 8.603,-7.232c0.968,-7.804 2.15,-15.582 3.548,-23.321c0,-0.001 0,-0.001 0,-0.001c0.265,-1.464 -0.11,-2.971 -1.029,-4.14c-0.919,-1.169 -2.294,-1.89 -3.779,-1.979c-6.063,-0.358 -12.132,-0.616 -18.203,-0.781c-3.028,-0.082 -6.058,-0.14 -9.087,-0.176Z" style="fill:#faf3d2;stroke:#e9e9e9;stroke-width:1px;"/><path d="M391.079,119.103c-0.879,-4.028 -4.599,-6.788 -8.709,-6.46c-5.795,0.465 -11.584,1.005 -17.365,1.622c-4.42,0.472 -8.835,0.99 -13.244,1.557c-2.251,0.292 -4.282,1.498 -5.615,3.336c-1.333,1.837 -1.849,4.143 -1.427,6.373c0.023,0.125 0.046,0.25 0.07,0.375c1.504,7.977 2.776,15.998 3.821,24.047c0,0.001 0,0.001 0,0.001c0.123,0.947 0.619,1.806 1.378,2.386c0.758,0.58 1.717,0.833 2.663,0.704c7.46,-1.015 14.94,-1.873 22.434,-2.597c4.131,-0.4 8.267,-0.758 12.405,-1.077c2.3,-0.177 4.421,-1.31 5.848,-3.123c1.426,-1.813 2.027,-4.141 1.658,-6.418c-0.312,-1.925 -0.638,-3.848 -0.977,-5.768c-0.884,-5.004 -1.863,-9.992 -2.94,-14.958Z" style="fill:#faf3d2;stroke:#e9e9e9;stroke-width:1px;"/><path d="M481.8,111.259c-2.538,-0.126 -4.993,0.925 -6.653,2.85c-1.659,1.925 -2.338,4.508 -1.84,7c0.32,1.597 0.632,3.196 0.933,4.797c1.226,6.502 2.298,13.033 3.218,19.586c0.213,1.525 1.479,2.686 3.017,2.765c0,0 0,0 0,0c11.822,0.61 23.63,1.516 35.402,2.764c0.001,0 0.001,0 0.001,0c1.571,0.167 3.131,-0.403 4.225,-1.543c1.094,-1.139 1.599,-2.721 1.369,-4.284c-0.552,-3.719 -1.155,-7.431 -1.809,-11.133c-0.851,-4.813 -1.789,-9.611 -2.817,-14.389c-0.764,-3.523 -3.728,-6.142 -7.318,-6.465c-0.291,-0.028 -0.583,-0.054 -0.874,-0.08c-8.938,-0.794 -17.892,-1.413 -26.854,-1.868Z" style="fill:#faf3d2;stroke:#e9e9e9;stroke-width:1px;"/><path d="M451.812,115.41c-0.685,-2.99 -3.34,-5.115 -6.407,-5.126c-0.001,-0.001 -0.001,-0.001 -0.001,-0.001c-0.001,0 -0.002,0 -0.004,0c-1.16,-0.004 -2.321,-0.005 -3.481,-0.005c-0.003,0 -0.005,0 -0.007,0c-4.116,0.006 -8.231,0.04 -12.346,0.108c-3.367,0.056 -6.734,0.133 -10.1,0.233c-2.429,0.072 -4.702,1.212 -6.212,3.114c-1.511,1.903 -2.106,4.375 -1.625,6.757c0.365,1.803 0.718,3.608 1.058,5.416c0.917,4.86 1.747,9.735 2.492,14.624c0.623,4.112 4.211,7.116 8.368,7.006c6.585,-0.167 13.171,-0.247 19.757,-0.241c1.57,0.001 3.139,0.007 4.709,0.018c2.435,0.017 4.753,-1.044 6.332,-2.898c1.579,-1.854 2.257,-4.311 1.854,-6.713c-0.204,-1.214 -0.413,-2.428 -0.627,-3.641c-1.104,-6.246 -2.355,-12.466 -3.76,-18.651Z" style="fill:#faf3d2;stroke:#e9e9e9;stroke-width:1px;"/><path d="M531.669,82.333c-0.914,-0.2 -1.866,0.098 -2.502,0.785c-0.636,0.687 -0.861,1.659 -0.591,2.556c0,0 0,0.001 0,0.001c1.97,6.547 3.753,13.151 5.362,19.796c0,0.001 0,0.001 0,0.001c0.501,2.066 2.1,3.688 4.159,4.218c5.757,1.49 11.471,3.145 17.127,4.983c6.852,2.226 13.619,4.721 20.252,7.534c0,0 0,0 0,0c0.495,0.21 1.066,0.123 1.476,-0.225c0.409,-0.348 0.588,-0.897 0.461,-1.419c-0.961,-3.931 -1.995,-7.843 -3.107,-11.734c-1.095,-3.829 -2.266,-7.637 -3.521,-11.417c-0.071,-0.213 -0.143,-0.427 -0.214,-0.641c-0.821,-2.453 -2.746,-4.379 -5.199,-5.201c-2.426,-0.811 -4.863,-1.59 -7.31,-2.34c-6.008,-1.84 -12.071,-3.498 -18.174,-4.991c-2.732,-0.668 -5.472,-1.303 -8.219,-1.906Z" style="fill:#faf3d2;stroke:#e9e9e9;stroke-width:1px;"/><path d="M185.89,93.769c-3.829,-0.144 -7.253,2.369 -8.262,6.066c-0.375,1.366 -0.74,2.734 -1.097,4.104c-1.085,4.161 -2.097,8.342 -3.037,12.538c-0.117,0.52 0.009,1.065 0.34,1.483c0.331,0.417 0.834,0.663 1.367,0.668c0.001,0 0.001,0 0.001,0c8.368,0.08 16.734,0.488 25.068,1.245c1.691,0.154 3.38,0.322 5.068,0.504c4.187,0.452 8.04,-2.325 8.937,-6.439c0.954,-4.35 1.98,-8.684 3.081,-12.999c0.277,-1.079 0.077,-2.226 -0.549,-3.148c-0.626,-0.922 -1.617,-1.531 -2.723,-1.673c0,0 0,0 0,0c-9.358,-1.195 -18.768,-1.97 -28.194,-2.349Z" style="fill:#faf3d2;stroke:#e9e9e9;stroke-width:1px;"/><path d="M472.608,74.051c-2.699,-0.177 -5.313,0.982 -6.994,3.101c-1.682,2.119 -2.216,4.928 -1.431,7.517c0.1,0.336 0.201,0.671 0.302,1.006c0.764,2.538 1.499,5.085 2.207,7.639c0.93,3.356 3.868,5.766 7.341,6.021c6.992,0.524 13.971,1.229 20.925,2.124c1.889,0.243 3.775,0.499 5.66,0.771c2.787,0.398 5.583,-0.653 7.418,-2.787c1.835,-2.135 2.454,-5.058 1.642,-7.753c-0.475,-1.583 -0.962,-3.163 -1.461,-4.739c-0.561,-1.773 -1.137,-3.542 -1.729,-5.305c-0.859,-2.555 -3.094,-4.402 -5.766,-4.762c0,-0.001 0,-0.001 0,-0.001c-9.336,-1.261 -18.715,-2.199 -28.114,-2.832Z" style="fill:#faf3d2;stroke:#e9e9e9;stroke-width:1px;"/><path d="M298.125,99.187c0.004,0.121 0.074,0.231 0.183,0.286c0.108,0.055 0.238,0.047 0.338,-0.022c0,0 0,0 0,0c1.754,-1.196 3.53,-2.36 5.325,-3.495c3.054,-1.93 6.163,-3.772 9.32,-5.529c1.229,-0.682 1.808,-2.135 1.384,-3.476c0,0 0,0 0,0c-1.894,-5.987 -3.96,-11.919 -6.232,-17.773c0,0 0,0 0,0c-0.013,-0.035 -0.041,-0.062 -0.076,-0.075c-0.034,-0.013 -0.073,-0.011 -0.105,0.007c-2.252,1.176 -4.484,2.39 -6.695,3.642c-2.696,1.53 -4.306,4.443 -4.166,7.54c0.075,1.697 0.148,3.394 0.217,5.091c0.189,4.6 0.356,9.202 0.507,13.804Z" style="fill:#faf3d2;stroke:#e9e9e9;stroke-width:1px;"/><path d="M440.007,74.803c-0.381,-1.045 -1.38,-1.735 -2.492,-1.723c0,0 -0.001,0 -0.001,0c-3.393,0.039 -6.787,0.115 -10.178,0.231c-5.798,0.197 -11.591,0.507 -17.376,0.933c-2.495,0.186 -4.77,1.495 -6.184,3.559c-1.415,2.063 -1.816,4.657 -1.09,7.051c0.081,0.274 0.164,0.547 0.246,0.821c0.747,2.483 1.467,4.974 2.161,7.472c1.049,3.776 4.611,6.292 8.52,6.018c4.401,-0.305 8.806,-0.538 13.214,-0.702c3.196,-0.119 6.393,-0.202 9.591,-0.248c1.612,-0.024 3.223,-0.037 4.834,-0.043c0.005,0 0.009,0 0.014,0c0.677,-0.002 1.355,-0.003 2.032,-0.002l0.007,0c0.986,0.002 1.916,-0.461 2.509,-1.249c0.593,-0.788 0.78,-1.81 0.504,-2.757c-0.704,-2.413 -1.434,-4.817 -2.192,-7.213c-1.29,-4.077 -2.659,-8.129 -4.119,-12.148Z" style="fill:#faf3d2;stroke:#e9e9e9;stroke-width:1px;"/><path d="M121.51,91.92c-0.078,0.263 -0.011,0.548 0.177,0.748c0.188,0.2 0.468,0.285 0.735,0.223c0.001,0 0.001,0 0.001,0c12.127,-2.807 24.503,-4.518 36.929,-5.212c0,0 0,0 0,0c0.678,-0.038 1.258,-0.497 1.452,-1.147c1.081,-3.626 2.219,-7.234 3.42,-10.822c0,0 0,-0.001 0,-0.001c0.729,-2.18 0.328,-4.58 -1.072,-6.403c-1.399,-1.824 -3.613,-2.834 -5.907,-2.694c-1.285,0.078 -2.569,0.164 -3.852,0.261c-6.587,0.496 -13.156,1.256 -19.68,2.289c-2.945,0.473 -5.404,2.501 -6.43,5.302c-1.282,3.513 -2.494,7.051 -3.643,10.609c-0.735,2.274 -1.445,4.557 -2.13,6.847Z" style="fill:#faf3d2;stroke:#e9e9e9;stroke-width:1px;"/><path d="M190.073,66.808c-0.865,-0.061 -1.669,0.447 -1.986,1.253c0,0 0,0 0,0.001c-2.204,5.603 -4.216,11.281 -6.067,17.011c0,0 -0.001,0 -0.001,0c-0.186,0.576 -0.093,1.206 0.252,1.705c0.344,0.498 0.901,0.807 1.506,0.836c7.007,0.354 13.998,1.031 20.941,2.044c2.555,0.373 5.103,0.791 7.642,1.256c4.126,0.756 8.162,-1.707 9.375,-5.723c0.962,-3.174 1.967,-6.336 3.019,-9.481c0,0 0,-0.001 0,-0.001c0.308,-0.92 0.208,-1.927 -0.273,-2.769c-0.482,-0.842 -1.3,-1.438 -2.249,-1.639c-2.504,-0.528 -5.017,-1.014 -7.538,-1.458c-8.147,-1.437 -16.369,-2.444 -24.621,-3.035Z" style="fill:#faf3d2;stroke:#e9e9e9;stroke-width:1px;"/><path d="M522.68,48.323c-1.658,-0.433 -3.417,0.113 -4.537,1.409c-1.12,1.295 -1.407,3.115 -0.739,4.692c-0.002,0.002 -0.002,0.002 -0.002,0.003c1.994,4.712 3.849,9.483 5.584,14.297c0,0 0,0 0,0c0.409,1.134 1.332,2.005 2.487,2.348c2.524,0.753 5.037,1.543 7.536,2.373c8.082,2.683 16.03,5.774 23.778,9.307c2.864,1.306 5.7,2.672 8.505,4.101c0.34,0.174 0.751,0.119 1.035,-0.137c0.283,-0.255 0.378,-0.66 0.239,-1.015c0,-0.001 0,-0.002 -0.001,-0.002c-1.067,-2.732 -2.189,-5.442 -3.378,-8.123c-1.14,-2.572 -2.341,-5.117 -3.623,-7.622c-0.998,-1.948 -2.044,-3.873 -3.161,-5.757c-0.97,-1.635 -1.992,-3.243 -3.113,-4.78c-0.001,-0.002 -0.003,-0.004 -0.004,-0.006c0,0 0,0 0,0c-0.182,-0.247 -0.403,-0.463 -0.654,-0.638c-0.527,-0.367 -1.059,-0.726 -1.589,-1.089c-0.553,-0.381 -1.15,-0.692 -1.778,-0.928c-2.022,-0.757 -4.053,-1.49 -6.093,-2.198c-6.747,-2.342 -13.586,-4.417 -20.492,-6.235Z" style="fill:#faf3d2;stroke:#e9e9e9;stroke-width:1px;"/><path d="M369.378,53c-1.597,-3.344 -5.356,-5.068 -8.932,-4.097c-0.001,0 -0.001,0 -0.001,0c-9.079,2.467 -18.038,5.379 -26.816,8.765c0,0 -0.001,0.001 -0.001,0.001c-3.996,1.541 -6.023,5.999 -4.558,10.024c0.125,0.343 0.25,0.687 0.374,1.031c0.433,1.2 0.858,2.403 1.276,3.609c0.734,2.109 2.292,3.83 4.318,4.77c2.026,0.94 4.346,1.017 6.43,0.215c2.894,-1.115 5.809,-2.172 8.743,-3.174c5.297,-1.81 10.654,-3.443 16.058,-4.904c2.331,-0.628 4.27,-2.246 5.305,-4.427c1.034,-2.181 1.06,-4.706 0.071,-6.908c-0.492,-1.106 -0.995,-2.206 -1.508,-3.302c-0.251,-0.535 -0.504,-1.07 -0.759,-1.603Z" style="fill:#faf3d2;stroke:#e9e9e9;stroke-width:1px;"/><path d="M449.58,38.283c-0.812,-0.017 -1.574,0.392 -2.01,1.078c-0.435,0.686 -0.48,1.549 -0.119,2.277c0.067,0.135 0.134,0.269 0.201,0.404c2.012,4.069 3.89,8.204 5.659,12.385c0.381,0.899 0.756,1.8 1.126,2.703c0.622,1.517 2.064,2.537 3.701,2.619c0,0 0,0 0.001,0c13.879,0.696 27.715,2.333 41.36,4.974c0,0 0,0 0.001,0c0.153,0.03 0.31,-0.027 0.408,-0.148c0.099,-0.12 0.124,-0.285 0.064,-0.429c-1.325,-3.212 -2.718,-6.396 -4.191,-9.543c-1.969,-4.206 -4.078,-8.349 -6.381,-12.383c0,0 0,0 0,0c-0.258,-0.452 -0.711,-0.76 -1.226,-0.833c-9.159,-1.299 -18.376,-2.191 -27.612,-2.692c-3.658,-0.199 -7.319,-0.336 -10.982,-0.412c0,0 0,0 0,0Z" style="fill:#faf3d2;stroke:#e9e9e9;stroke-width:1px;"/><path d="M424.207,40.324c-0.564,-0.952 -1.616,-1.508 -2.721,-1.437c0,0 0,0 0,0c-10.846,0.698 -21.658,1.937 -32.376,3.742c-0.001,0 -0.001,0 -0.001,0c-0.593,0.1 -1.105,0.472 -1.382,1.006c-0.278,0.533 -0.29,1.165 -0.032,1.708c1.42,2.999 2.771,6.029 4.063,9.084c0.375,0.885 0.744,1.772 1.109,2.661c1.431,3.479 5.035,5.549 8.761,5.03c8.384,-1.145 16.819,-1.925 25.27,-2.356c0.574,-0.029 1.149,-0.057 1.724,-0.083c1.19,-0.054 2.274,-0.699 2.89,-1.718c0.616,-1.019 0.683,-2.279 0.178,-3.357c0,0 0,0 0,-0.001c-1.969,-4.206 -4.078,-8.349 -6.381,-12.383c-0.362,-0.635 -0.729,-1.267 -1.102,-1.896Z" style="fill:#faf3d2;stroke:#e9e9e9;stroke-width:1px;"/><path d="M557.252,61.478c0.023,0.012 0.039,0.035 0.043,0.061c0.003,0.026 -0.005,0.052 -0.024,0.071c-0.562,-0.38 -1.144,-0.724 -1.716,-1.084c-0.002,-0.002 -0.005,-0.004 -0.008,-0.006c0,0 0,0 0,0c0.568,0.319 1.137,0.639 1.705,0.958Z" style="fill:#faf3d2;stroke:#e9e9e9;stroke-width:1px;"/></g></g></svg>
\ No newline at end of file
--- /dev/null
+<p>{{$status}}</p>
+{{include file="field_checkbox.tpl" field=$enable}}
+{{include file="field_checkbox.tpl" field=$bydefault}}
+{{include file="field_input.tpl" field=$client_id}}
+{{include file="field_input.tpl" field=$client_secret}}
+{{include file="field_input.tpl" field=$access_token}}
+{{if $authorize_url}}
+ <a href="{{$authorize_url}}">{{$authorize_text}}</a>
+{{/if}}
+{{if $disconn_btn}}
+ <div class="submit"><input type="submit" name="pnut-disconnect" value="{{$disconn_btn}}" /></div>
+{{/if}}